We will hold AtCoder Regular Contest 145.

- Contest URL: https://atcoder.jp/contests/arc145
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20220730T2100&p1=248
- Duration: 120 minutes
- Number of Tasks: 6
- Writer: nok0
- Tester: maspy, physics0523
- Rated range: — 2799

The point values will be 400-500-600-700-800-1200.

We are looking forward to your participation!

Looking forward to ARC !!

me too

As the writer, good luck and enjoy yourself! :D

As a contestant, I want to be blue :)

Can I do up-hack to my AC submission? This submission can be hacked by n=4 AAAA

What's the approximate rating of ARC's problems B & C according to CodeForces rating distribution?

math and counting round

I really suck at counting, but today I couldn't figure out what the 16 different permutations were in C, the most I found was 12 :P

Can anyone list those out please?

Code that printsCould someone point out what case am I missing in my submission for B?

Submission : https://atcoder.jp/contests/arc145/submissions/33632229

I believe you miss the cases where $$$N < A$$$.

Thanks for pointing that out.

My first AtCoder contest. The problems were good, it was interesting for me. Thanks !

D is just cantor set...

As a contestant, I was not a big fan of A,B,D. Those problems' ideas are not hard to get, but have very annoying corner cases...

Problem D is magic, but I want to know, why the set $$${1,2,4,7,11,...}$$$, which the differential sequence is $$${1,2,3,4,...}$$$ is not the optimal one.

The set $$$1,2,4,7,11,\dots$$$ has an $$$\mathrm{O}(n^2)$$$ value on the $$$n$$$-th element, while the optimal set has $$$\mathrm{O}(n^{\log_2 3}) \approx \mathrm{O}(n^{1.585})$$$ value on the $$$n$$$-th one ,which is enough to meet the constraint of $$$[-10^7,10^7]$$$ .

U R right.I tried that,and the number can be as large as 4e7

That doesn't even work, $$$1+7=2\cdot 4$$$

Sequence of pC can be found here.

My friend told me the problem C is in the OEIS, what do you think of it?

void jaiishriRam(){ ll n; cin>>n; string s; cin>>s; if(n==2) { if(s=="BA" || s=="AB") { cout<<"NO"<<endl; return; } } if(s[0]=='A' && s[n-1]=='B') { cout<<"NO"<<endl; return; }

cout<<"YES"<<endl;

} could anyone help me to know what thing I did wrong in A above is the code

You have to print "Yes", not "YES". Same for "No" and "NO"

Ohh tnx!

Can anyone plz tell me whats wrong here in my submission for problem B

Consider the test case :- 6 5 4 ,

Your O/P — 4

Correct O/P — 2

for value (5 and 6 only Alice will win )

Corrected that mistake but still getting WA on 3 test cases ;-; Here is my submission

I'm not sure if binary search is a good idea here. You can try

`30 10 3`

correct ans: 7 your code gives: 9Consider this test case :- 8 4 3

Your O/P — 6

Correct O/P — 4

Aice wins game (4,5,6 and 8)

Error is in line 58

loopthat you are multiplying . They will depend on remainder of (n%a).Thank you guys so much, my code got AC , there was implementation mistake at the end . In case anyone wants to see binary search solution — Here

your code doesn't handle the cases for $$$n$$$ in the range $$$a \le n < a+b$$$

Can anyone please tell me whats wrong here in my submission for problem D?

I don't know how your code works, but it fails at the input

`4 2`

thx.

It works in such way:

So the dfs is expected to stop in very low depth.

p.s. What about this one? It could pass

`4 2`

.It fails at

`10000 0`

.The output has these three integers:

Sorry, but it got

`9999991 -9999991 9999973 -9999973 9999971 ...`

here.Maybe there's some Undefined Behavior in my code?

It is not a UB, because the output is a set, and these three numbers are

init, which is against the constraint.Actually, they are not the first three numbers of the output on my computer as well.

Are you assuming primes don't have arithmetic sequences of length 3? Because that is not true, for example: $$$101, 107, 113$$$.

Oh, that's it.

Sincerely thanks for your help!

C could be solved by writing a brute force and searching the sequence on OEIS. Maybe those problems should be avoided by for example having problems parametrized by some more values, or making sure it isn't easy to find on the internet. It makes the contest experience less fun, if the answer is easily found on the internet. Problems A and B were fine. Problem D also suffered from this issue.

C is actually A152029(OEIS).

Whoa, i didn't brute force on the actual answer tho, I bruteforced on a subproblem of it, The Catalan Numbers

Catalan numbers are well known.

Why does this code give WA for problem A?

Here lng=long long, rtr=return 0, SZ=2e5+7

This was my first contest on AtCoder, Can someone tell me, when do the editorials be out ?

Here it is: https://atcoder.jp/contests/arc145/editorial

Thank you so much sir!

nok0 My submission for A get AC but can be hacked with n=4 AAAA My submission

In problem A:

Why is "AB" a valid palindrome or can be changed to a palindrome according to editorial and tests?

AB doesn't satisfy the first condition (s[0] == "B" or s[-1] == "A") in the editorial.

for D you can just use brute force to get a set meet the last restriction,and change the largest/smallest number,then add x to all numbers to get sum=M

base 3 solution is beautiful but not necessary

Can you share your submission?

My solution to B in the contest seems to be wrong.

When $$$n<a$$$, the answer is obvious 0, and when $$$a<b$$$, Alice can win when $$$n\geq a$$$, so the answer is $$$n-(a-1)$$$.

When $$$a>b$$$, Alice can win when $$$(n\bmod a)<b$$$, so between Game $$$ka$$$ to Game $$$(k+1)a-1$$$, Alice can win $$$b$$$ games. Consider unexisted Game 0,There are $$$\left(\lfloor\frac{n+1}{a}\rfloor-1\right)$$$ groups of games, and there are $$$(n+1)\bmod a$$$ ungrouped games, which Alice can win $$$\min ( (n+1)\bmod a,b ) $$$ games. Therefore, the answer is

But it seems to be wrong and Here's my submission. I also found another AC submission with formula

I wonder what makes the answer passed and mine failed.

I have different approaches for problem D and E:

D:

Ingore the limit of sum for now. Let $$$f(n)$$$ be the set of integers, one can find that

is good. Now consider the limit of sum. One can find that if we change the $$$\color{red}1$$$ into $$$2$$$, and add $$$1$$$ to some greatest elements in $$$f(n)$$$, it is still good.

E:

We can change $$$A_j$$$ to $$$A_i\oplus A_j$$$ ($$$i<j$$$) by performing operations $$$j,i+2,i+3,\ldots,j$$$ in order.

Now we change $$$A_i$$$ into $$$B_i$$$ from right to left, taking the lexicological largest basis each time. It turns out that the number of operations is OK. (It can take up to $$$N-1$$$ operations to change a single number, but each operation will move some basis vectors to the right)

Your code on E submitted during contest can be hacked using the data generated by the code below.

Thanks for pointing this out! I tried to add some randomization and it worked pretty good.

My randomized solution for E:

If the answer is Yes, we first randomly manipulate the sequence for a small number of times, and then operate on index $$$n$$$ more than $$$n$$$ times repeatedly. Then we can (roughly) assume that $$$a_n \oplus b_n$$$ is a linear combination of $$$a_{n-r+1 \cdots a_{n-1}}$$$, where $$$t$$$ is about $$$60$$$.

We can then solve $$$a_n \oplus b_n = \bigoplus_{j \in S} a_j$$$ with Gaussian elimination. If $$$a_{n-1} \not \in S$$$, operate on $$$n$$$ so that $$$a_{n-1} \in S$$$.

Then we operate on the second minimum element $$$t$$$ in $$$S$$$. Then $$$\min S$$$ is removed from $$$S$$$ and all indices between $$$\min S$$$ and $$$t$$$ are added. Repeat this process until $$$S = {a_{n-1}}$$$ and operate on $$$n$$$. Do this for $$$n - 1 \dots 2$$$ and we are done. This solution uses ~60000 operations in randomly generated inputs.

implementation

UPD: More than 1000 random operations at first are needed to guarantee randomness.Can somebody explain here problem D, how exactly are we constructing the required set after we have figured out the base 3 condition where each digit should be 0/1.

F is some wild generalization of IMO 1995 P6. I like it

Such a magical problem D!

Base-3 representation is such a trick that could perfectly beat the rule of $$$2y \neq x + z$$$.

Next, by first keeping the rightmost digit of all n integers as zero and then change some of them to 1, so that $$$|m - sum| \% n = 0$$$. At the same time, all n integers are still distinct and satisfy the "good set" rule.

Finally, add $$$(m - sum) / n$$$ to each integer so that $$$sum = m$$$, and at the same time, adding the same integer will not lead to any $$$2y = x + z$$$, although they may not belong to the "good set" anymore.

Thanks to the problem writer for coming up with such a clever and unbelievable construction problem!

Was only able to solve A, although I misread the problem at first and somehow thought that I could use the operation only when adjacent characters are equal, lead to 3 WAs but we move....

In terms of codeforces ratings, what would be the difficulty rating for problem A?

can anyone explain logic of c plz?

This round is good, arc should contain magical counting and constructing problems like this.

A different way to think for D.

We can construct as follow (P is a set,initial $$$P={1},len=1$$$): $$$P\to P\cup (P+(2len-1)),len\to 3len-1$$$

$$$P+a$$$ means add $$$a$$$ to all elements in $$$P$$$.

And it can prove that $$$y−x\not=z−y$$$ for every triple $$$x,y,z (x<y<z)$$$ of distinct elements in $$$P$$$.

(Which is similar to the official editorial)

and we can construct the set with $$$n+2$$$ elements, and enumerate which two to delete. It can solve the problem.

Could you please talk more about why your construction will not lead to 2y=x+z? And, how to construct these n+2 elements, and how to determine which two to delete?

Thank you so much for providing such a clever idea.

Let $$$P'=P+(2len-1),\forall x\in P,y\in P,z\in P',$$$ we can found that $$$|x-y|<len,|x-z|\ge len$$$.

This is my submission for D.

Sorry for asking it late,

Can any one please the explain this line of editorial :

Here, if the elements in P are scanned from left to right, there must always be more left elements than right elements. The number of such arrangements corresponds to that of parenthesis sequences.

What I understood is that, lets say we have (1,2),(3,4),(5,6),(7,8) as corresponding (ai and bi).

Permutation : (1,2,4,3,5,6,7,8) have more right elements(2) than left elements(1) in first 3 elements (1,2,4) but still it can be divided it into two sequences A(1,3,5,7) and B(2,4,6,8), but in editorial it is told that it should not be possible ( as per I understood ) .

I know I have understood it wrong.

Anyone who did this problem or got the editorial please explain the line in blue

Editorial link : Link