We will hold AtCoder Beginner Contest 247.

- Contest URL: https://atcoder.jp/contests/abc247
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20220410T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 8
- Writer: Nyaan, kyopro_friends, m_99, YoshikaMiyafuji
- Rated range: ~ 1999

The point values will be 100-200-300-400-500-500-600-600.

We are looking forward to your participation!

fun contest

i thought F is a dp problem, realizing it's related to graph in the last minutes made me took a wild guess and speedrun coding DSU. submitted 8 seconds before contest ended and as expected got WA

They had us in the first half ngl

I used dp to calculate the amount of valid subsets for a cycle. See https://atcoder.jp/contests/abc247/submissions/30895994 in the calc-method. Need to calculate twice (iterate

`first`

) to account for the adjency of $$$0$$$ and $$$c-1$$$.I think I overcomplicated most of my solutions :/ But still it's wonderful, when there are various approaches to a problem. Great contest)

WA (https://atcoder.jp/contests/abc247/submissions/30857193)

AC (https://atcoder.jp/contests/abc247/submissions/30873457)

`I think both are same in multiset of string`

if a[i]==b[i] your code might fail because you remove elements twice.

sorry,i didn't understand can you please elaborate

For the case a[i]==b[i] the one solution removes two elements from the mulitset, the other solution tries to remove one element twice.

how to solve E?

Iterate over all possible right endings. For each endings, we find the first X, Y, bad to the left. (Here we define a number bad as $$$(a[i] < Y || a[i] > X)$$$ If the order is one of the following (X, Y, bad, right), (Y, X, bad, right), (X, bad, Y, right), or (Y, bad, X, right), it is impossible to find a subsequence ending at right that contains both X and Y. If bad is leftmost relatively to X and Y, then the number of subsequences ending at right will be $$$min(index_X, index_Y) - index_{bad} + 1$$$ My submission

thanks a lot (:

Why are heuristic contests shown in red on main atcoder page and in black color on contests page? I get it confused with Atcoder Grand contests because they are shown in red.

The solution to F?

The idea is same as editorial but my dp states are a bit different. Please let me know if something is not clear.

SpoilerI find that Problems E and F in ABC round are always great practice for me. It turns out that it is quite a challenge for me to solve both of them within the contest. Hope that after more practice, I could be more comfortable with these problems.

Could anyone explain F. I'm unable to understand g(M)=f(M−1)+f(M−3) relation. Unable to understand "This problem is quite similar to “you must choose one of adjacent elements. How many ways are there to do so?” that we discussed right before." What is meany by adjacent elements? adjacent nodes or edges?

Can't answer the first question . While solving problem I was looking for pattern and then brute forced for some values and found out that f[i]=f[i-1]+f[i-2] where i is the size of the cycle .

For the second part , try naming each edge and vertex 0 to n-1 , u will notice that when you colour edge j , vertex j and (j+1)%n gets colored , I think this is exactly what is meant by the "you must choose one of adjacent elements. How many ways are there to do so?"

It was a very good contest.

can anyone tell me what is best time complexity in which problem C(1 2 1 3..) can be solved?

Link for Problem C

Suppose that $$$T(x)=$$$ the number of numbers we should print when $$$N=x$$$, then we have $$$T(x)=2T(x-1)+1(x>1),T(1)=1$$$. So $$$T(x)=O(2^x)$$$.

THANK YOU!

I have got a very interesting solution to this problem. I don't know how it got

ACCEPTEDbut my solution is inspired by a similar problem inCodeforces ProblemSetMY SOLUTIONint n;

cin>>n;

for(int i=1;i<(1<<n);i++){ cout<<(__builtin_popcount(i^(i-1)))<<" "; }

Can you kindly explain how is it working?

Someone solved it in O(1), because there are only 16 possibilities: Submission

I solved E with Sparse table and Binary Search. Kind of overkilled the problem. Code