Блог пользователя salyg1n

Автор salyg1n, 8 месяцев назад, По-русски

Привет, Codeforces! 🤯

green_gold_dog, ace5, bashkort и я salyg1n рады пригласить вас принять участие в Codeforces Round 897 (Div. 2), который состоится в понедельник, 11 сентября 2023 г. в 17:35.

Этот раунд будет рейтинговым для участников, чей рейтинг ниже 2100. Участники с более высоким рейтингом могут принять участие вне конкурса.

Вам будет предложено 6 задач и 2 часа на их решение. Советуем прочитать все задачи. В раунде могут встретиться интерактивные задачи. Рекомендуем прочитать этот пост.

Мы хотим поблагодарить:

Мы надеемся, что вам понравятся наши задачи! Удачи!

UPD. Разбалловка: $$$500 - 1000 - 1250 - 2000 - (2000 + 1000) - 4000$$$.

UPD2. Поздравляем победителей!

Div. 2

  1. candidatecandidatemaster

  2. Coreopsis

  3. iFFT

  4. Dorothy__

  5. wk______tzc

Div. 1

  1. Golovanov399

  2. Geothermal

  3. arvindf232

  4. Rubikun

  5. Vercingetorix

UPD3. Разбор.

  • Проголосовать: нравится
  • +280
  • Проголосовать: не нравится

»
8 месяцев назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

Auto comment: topic has been updated by salyg1n (previous revision, new revision, compare).

»
8 месяцев назад, # |
  Проголосовать: нравится +35 Проголосовать: не нравится

Finally ez rating

»
8 месяцев назад, # |
  Проголосовать: нравится -35 Проголосовать: не нравится

Автокомментарий: текст был обновлен пользователем salyg1n (предыдущая версия, новая версия, сравнить).

»
8 месяцев назад, # |
  Проголосовать: нравится -210 Проголосовать: не нравится

As a tester, I ask to downvote this comment instead of round announcement

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится -20 Проголосовать: не нравится

    i downvoted both , problem C gave tle on pretest 4 and same logic passed in c++

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится +53 Проголосовать: не нравится

      Yeah, I totally agree. You shouldn't give instructions on how to output in Java for a problem that's impossible to solve in Java if someone follows those instructions.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Problem C seemed so simple yet turned out to be the most painful one. Just wouldnt work with Java

»
8 месяцев назад, # |
  Проголосовать: нравится -45 Проголосовать: не нравится

Negative contribution :)

»
8 месяцев назад, # |
  Проголосовать: нравится +64 Проголосовать: не нравится

я гроссмейстер, но ради участия в этом раунде планирую стать кандидатом в мастера

»
8 месяцев назад, # |
  Проголосовать: нравится -14 Проголосовать: не нравится

i hope you learnt from round 893

»
8 месяцев назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

The hidden texts are cute :)

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

waiting for the challenge ......

»
8 месяцев назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

After round 896 div 2, I hope this makes me feel better about myself again. I'm looking forward to it :') Good luck everyone!

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

really Nice, thanks for this round ^^

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

omg, two contests in two days!

Good luck everyone!

»
8 месяцев назад, # |
  Проголосовать: нравится -7 Проголосовать: не нравится

score distribution?

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

After round 896 div 2, I hope this makes me feel better about myself again.

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится -8 Проголосовать: не нравится

score distribution?

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

    It will published later on...btw it is mentioned above...

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I’ve seen that, but I think it’s a little bit too late and also I want to determine whether to participate in this contest earlier.

»
8 месяцев назад, # |
Rev. 3   Проголосовать: нравится -8 Проголосовать: не нравится

good contest!

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

ez

»
8 месяцев назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

Hopefully I reach closer to cm

»
8 месяцев назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Given my past results in Division 2., I am hopeful that I can reach newbie rank again.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

ryskmax for being the only blue tester and giving valuable feedback. 🐳

Fair and equal testing moment.

»
8 месяцев назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

As a tester, I will write this round from my second acc 😈

»
8 месяцев назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

That cliff 1250-2000 :(

»
8 месяцев назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

Score distribution gives speedforces vibes.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

:((

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

MikeMirzayanov can you please check your inbox?

»
8 месяцев назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

so why the announcement is "P(G) is't a set" but not "P(G) isn't a set"
what does is't mean,,

»
8 месяцев назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

too interactive contest

»
8 месяцев назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

In my opinion problem C has an issue, if there are already $$$2*N+1$$$ queries, why am I not allowed to go to next case myself? Instead I have to input -1 to jump to next case. Why? Because of this, I had a big penalty.

»
8 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

Hopefully my 2.9s Python submission for C doesn't TLE

»
8 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Why the java language can't pass the C question, but the C++ language passes. Experience the worst race, hopefully not counting the rankings

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Same thing here. I first tried submitting various java solutions only to get TLE. Same logic in C++ passed in first go.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Sounds like a skill issue to me.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    Same issue.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    My best guess is for test like #4 where T = 100000, the system judge does not generate the input data for next test in stdin fast enough after the previous test complete.

    I tried to simulate stdin for 100000 tests each with n = 1 on local machine like below. It measured 185 msec. So the fact that test #4 always TLE in system tests suggest some kind of delay introduced by system test for Java submissions.

      static void simulateLargeNumOfTests() {
        long t0 = System.currentTimeMillis();
        {
          // Prepare stdin for 100000 tests each with n = 1 and mex 0.
          // In such case, an immediate -1 will follow after the input of each test.
          int T = 100000;
          StringBuilder sb = new StringBuilder();
          sb.append(T);
          sb.append('\n');
          for (int t = 1; t <= T; t++) {
            sb.append(1);
            sb.append('\n');
            sb.append(1 + RAND.nextInt(1000000000));
            sb.append('\n');
            sb.append(-1);
            sb.append('\n');
          }
          byte[] data = sb.toString().getBytes();
          InputStream fakeIn = new ByteArrayInputStream(data);
          System.setIn(fakeIn);
        }
    
        {
          MyScanner in = new MyScanner(true);
          int T = in.nextInt();
          OutputStream out = new BufferedOutputStream(System.out);
          for (int t = 1; t <= T; t++) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
              a[i] = in.nextInt();
            }
            solve(a, in, null, out);
          }
        }
        System.out.format("%d msec\n", System.currentTimeMillis() - t0);
        System.exit(0);
      }
    
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    After using a hack to workaround test #4 which always TLE in System Verdict, this submission https://codeforces.com/contest/1867/submission/223000398 is Accepted with runtime 1949 msec on test #6 where the input array has length 100000 and MEX 100000. It is unclear exactly how many IO interactions in test #6 as it depends on how greedily the Judge choose y each time.

    Overall, the interactive IOs delays of problem C is too much for the given limit of T and timeout, and the problem is partially to do with the System Test. Problem C should either use a smaller limit like 10000 for T or a bigger timeout so to accept legit Java solutions without losing any generality of the problem.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Problem C really pulled an UNO reverse card on me. I thought the solution wouldn't be the one I was thinking but it turned out it was.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Same for me. But at the end when I was done with coding, and I was trying some random cases and suddenly it hit me that this should be the accepted solution.

»
8 месяцев назад, # |
  Проголосовать: нравится +71 Проголосовать: не нравится

I think a lot of people got stuck on E since n odd and k even has no solution, until they realize that n and k are both even, and the problem becomes completely trivial. Not a great problem imo.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    same I almost wasted 30 minutes about thinking it and then I reread the question did it in 5 minutes and then went for e2 made the logic but guess what forgot to print ? in making query and didn't make it whole time I was thinking about my solution but the error was in my code :(

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +18 Проголосовать: не нравится

    Completely ruined my contest. But it's my fault, I missed "Even".

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    what???i completely didn't realize n and k are both even even at this time!!! sad about this...

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I don't know the completely trivial solution :(

    Can you explain it?

»
8 месяцев назад, # |
  Проголосовать: нравится +62 Проголосовать: не нравится

The problem E2 is such a good joke.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    How to progress from solution for E1 to E2?

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      Instead of querying all [i-k+1, i] for the remaining n%k, you can just query half of it first then the remaining half using only 51 queries.

»
8 месяцев назад, # |
  Проголосовать: нравится +34 Проголосовать: не нравится

Why problem C is unsolvable in java , even java legends like SecondThread and profchi used c++ for this problem.

if it's div2 E , F , then it can be beared but atleast div2 problem A B C should be solvable in java. I got 4 unnecessary penalties.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Never gonna attempt a contest with interactive problems again.

»
8 месяцев назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Problem E is kinda easy, right?

»
8 месяцев назад, # |
  Проголосовать: нравится +18 Проголосовать: не нравится

queueforces and I hate interactive problems

»
8 месяцев назад, # |
  Проголосовать: нравится +33 Проголосовать: не нравится

A: Arrange b[i] by the reverse order of a[i] so the value of {a[i]-b[i]} will be pairwise distinct.

B: For every pair of symmetrical positions i and j, if s[i]==s[j] then we can let l[i]==l[j]==0 or 1 (make 0 or 2 occurences of '1' in t), if s[i]!=s[j] we need let l[i]!=l[j] (make 1 occurence of '1' in t). If n is odd, we can let l[(n+1)/2]==0 or 1 (make 0 or 1 occurences of '1' in t). Let the number of first kind of pair is a, and second kind of pair is b, the answer is b+2*k (0<=k<=a) if n is even, and b+k (0<=k<=2*a+1) if n is odd.

C: In the first move alice choose x=MEX(S) (the initial MEX of S), and in after moves alice always add the number removed by Bob back, then the final value will be the second MEX of initial S. This is the optimal strategy.

D: If k==1, we can only make b[i]=i. If k>=2, we build a functional grpah from b (a graph with n nodes and add edges (i-->b[i]) for 1<=i<=n), and we only need to check if the size of every cycles in this graph is k.

E2: If n%k==0 we can query for n/k segments of length k. Otherwise, observe that if we let r=n%k and make such queries: query(1), query(1+r/2), query(1+r), we can get the xor sum of segment [1, k+r]. Then we can query for floor(n/k)-1 segments of length k for the remained part.

F: I've tried for random approach but got WA on testcase 24.

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    problem D : if a linear chain of size > k is connected to a k length cycle then how is possible to generate a pattern to get array B?

    • »
      »
      »
      8 месяцев назад, # ^ |
      Rev. 2   Проголосовать: нравится +15 Проголосовать: не нравится

      We can just build it in parts:

      Let $$$n = 5$$$, $$$k = 2$$$, $$$b = [2, 1, 2, 3, 4]$$$

      Graph

      Operations:

      • $$$l = [5, 4] \Rightarrow a = [0, 0, 0, 5, 4]$$$
      • $$$l = [4, 3] \Rightarrow a = [0, 0, 4, 3, 4]$$$
      • $$$l = [3, 2] \Rightarrow a = [0, 3, 2, 3, 4]$$$
      • $$$l = [2, 1] \Rightarrow a = [2, 1, 2, 3, 4]$$$

      Can you see how this can be generalised?

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Start from the beginning of the chain and set first $$$k-1$$$ elements. Continue until you reach the cycle, then set the cycle

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +13 Проголосовать: не нравится
    Diagram for E
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    Actually, I think quite easy to kill random approaches for F, one can just construct a tree with all possible subtrees of size k except for 1 which random will find it hard to find.

»
8 месяцев назад, # |
  Проголосовать: нравится +106 Проголосовать: не нравится

I see now that you have n and k as even integers in the interaction section. But why not mention that in the initial problem statement?

The $$$n \leq k^2 \leq 2500$$$ was weird as well. Also that has to be one of the easiest D2E ever once you notice all that.

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +11 Проголосовать: не нравится

    Ackchyually, you must know that $$$n$$$ and $$$k$$$ would be even, when the problem is E1.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится +6 Проголосовать: не нравится

      I saw that the numbers are even only after reading this comment. It's my own fault, and it's stupid to think about it now, but most likely I would have passed this task if I had seen it.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      lol this comment deserves most likes!

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится -11 Проголосовать: не нравится

Why bitwise operator in easy problems (such as A, B) again?

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    Where do you see bitwise operator that much. Xor in binary strings = flipping i-th digit. Problem A isn't about bitwise at all

»
8 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

Is it just me or problem E1 is actually easier than B and C :D

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Why is the C problem so TLE-constrained for python……

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    For Java as well

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I use python and got TLE on problem B testcase 11, problem C testcase 4 with default input() method during the contest. But after adding

    import sys 
    input=sys.stdin.buffer.readline
    

    They all passed the test.

    A really frustrated experience for me though.

»
8 месяцев назад, # |
  Проголосовать: нравится -15 Проголосовать: не нравится

The game ends when Bob cannot make a move or after 2⋅n+1 moves so why did i need to take another input after completing the 2*n+1 moves which resulted in me getting 4 runtime errors

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    Yeah, that was very confusing

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +80 Проголосовать: не нравится

    I don't think there was any ambiguity in the problem statement. The interaction guide says that after you output $$$x$$$, you should read an integer $$$y$$$. It never says that you should read $$$y$$$ only if the game is not already over or that you should read $$$y$$$ only if Bob is making a move: every time you output an $$$x$$$, you need to read a $$$y$$$.

    It's particularly easy to get tripped up on interactive problems by making incorrect assumptions about the I/O format, which is why you should always read the interaction section of the statement carefully before beginning to implement your solution.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      Whenever i encounter an interactive problem in the future this contest would remind me to read the I/O format completely before attempting it. Thnx

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      It was not clear enough, since it was mentioned in the problem statement that after 2n+1 moves, the last move would be of Alice's.

      • »
        »
        »
        »
        8 месяцев назад, # ^ |
          Проголосовать: нравится +17 Проголосовать: не нравится

        "To make a move, output an integer $$$x$$$ ($$$0 \le x \le 10^9$$$) — the number you want to add to the set $$$S$$$. $$$S$$$ must not contain $$$x$$$ at the time of the move. Then, read one integer $$$y$$$ ($$$−2 \le y \le 10^9$$$)."

        What about this is not clear? Remember that for implementation details, you should always trust the Interaction section instead of assumptions based on the statement of the problem.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I'm not complaining, as I didn't solve the problem myself, but it kinda is the job of the testers to remove the confusing parts of the problem statement, and personally, I feel like that is something they should have pointed out so it could've been edited.

»
8 месяцев назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

I am ecstatic about solving 1 problem in just 40 minutes this time. Huge improvement from the last contest where I spent 1+ hrs on 1 problem.

»
8 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

In problem C, the game is supposed to end after 2*n+1 moves right? so when I ran a loop till 2*n+1 it kept giving me Wrong Answer, when I ran a infinite loop it passed. Why is that? Can someone explain? If the game is supposed to end after 2*n+1 moves, then why should I go further and read y=-1 to end the game?

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +15 Проголосовать: не нравится

    "To make a move, output an integer $$$x$$$ ($$$0 \le x \le 10^9$$$) — the number you want to add to the set $$$S$$$. $$$S$$$ must not contain $$$x$$$ at the time of the move. Then, read one integer $$$y$$$ ($$$−2 \le y \le 10^9$$$)."

    Is it not clear that after every time you output $$$x$$$, you need to read in $$$y$$$?

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In this entire duration i somehow managed to solve A,wt shall i do, i am really getting depressed,i am soo weak, wt do i need to practice in order to be able to be good at cp .

»
8 месяцев назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится
»
8 месяцев назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Thought that the game in C literally ends after $$$2\cdot n + 1$$$ turns, turns out that it was needed to read the -1 from the input (couldln't solve D in time anyway, so w/e).

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

The first three questions are not difficult to distinguish, and the description of question B is too abstract, which is not a language that human beings can understand for me

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I am sure of my approach for C but still giving WA on test 2. Never solved an interactive problem before. I’d appreciate if someone can point out my mistake

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    According your code, I think when Nextmove = n; it will wrong. Like this: n = 2 a[] = 0 1 Step 1: A:2 B:1 Step 2: A:1 B:0 Step 3: A:0 B:-1 -> it need n+1 loops

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      my aproach was fine its just that I didn't take the input for the move after 2n+1

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Just tell me one thing, colors of high grades, in div2 D we just had to find out if k-1 going in a cycle like in union find will end up not visiting the same element again. Was this the answer to it? Like array 2 3 5 3 4 so going like 1 -> 2 -> 3 -> 5 -> 4 -> 3 ...

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Not necessarily, you can do this to k nodes without them being in a cycle, I will explain solution.

    Spoiler
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I just checked that every path from a non-zero element leads into a cycle of length $$$k$$$.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Lets take the sample test case. n.= 5, k = 3 2 3 5 3 4

      What cycle are you forming of length k can you mark?

      • »
        »
        »
        »
        8 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Well it's a functional graph where each node $$$i$$$ has an outward edge to $$$b_i$$$. So there is a cycle $$$3,5,4$$$. and if you start at any other node and keep following the outward edges, you will end up at that cycle, which has length $$$k=3$$$.

      • »
        »
        »
        »
        8 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Oh, and if $$$k=1$$$, then each non-zero must point to itself.

»
8 месяцев назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Great round, thanks a lot for making the interactive problem not the hardest one, this is the first time I was able to solve one and it made my day!

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Nice problems, I only wonder why couldn't you write simple and clear limitations in E, for me they were confusing and unclear tbh.

»
8 месяцев назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

E1 was so easy but i did x-- instead of x++ in a while loop and couldn't debug in 20 minutes.So disappointed .

»
8 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Can't see any passing Java solution for Problem C at all. Did anyone else checked?

»
8 месяцев назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

salyg1n Watch out for the TLE Java submissions of Problem C. Those submissions are very insightful and can easily tell that the problem wasn't properly tested for a language other than C++.

I even tried using fast I/O in Java.

Do something about that, as the same logic is getting passed in C++.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    System.out.println() is every slow so I used c++ for this task. If it was not interactive we can use fast output

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thank you for the awesome contest <3

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

from now whenever i will see Interactive tasks in blog... i will go to bed :(

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Best round ever!!! Thanks a lot!!! Why am i so stupid, that i didn't saw, that in E we have only even $$$n, k$$$... Waste like an hour with odd numbers, but solved for even in 20 minutes... Could have solved D...

Btw, i think you should have written in the statement, that $$$n, k$$$ are even not ONLY in input format... Or at least make a notification about it...

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится +13 Проголосовать: не нравится

I pass the C problem with great difficulty!!!Why python can't pass the C problem????

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Interactive Forces :)

»
8 месяцев назад, # |
  Проголосовать: нравится +23 Проголосовать: не нравится
»
8 месяцев назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

I don't know how many dislikes this will get but, is it normal if you start problem D when 1 hour 10 minutes is left and still not able to fully come up with a solution which has a logical background. Even if after 10 minutes my intuition said something to do with graph cycles, I was not able to come up with a logical solution to base my intuition. Does it happen to everyone and how you fix it? Doing more problems doesn't logically seems correct for solving problem D or is it? :')

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    I accidentally understood the proof of solution by YocyCraft while answering one of the comments, but I couldn't solve it myself. I guess practise makes perfect. At least you got the idea to use functional graphs

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I did not solve it during contest, but I did after the contest without looking at any hint/solution.

    $$$a_{l_i}$$$ to $$$l_{(i\%k)+1}$$$ looks like a complicated formula, maybe there is some special meaning behind it, so we should try to understand it better. It should be obvious that $$$(i\%k)+1$$$ means the next element, so for thinking's sake let's just assume it is $$$i+1$$$. Then $$$a[l[i]]=l[i+1]$$$ is the code equivalent of the formula. We also have $$$a[l[i+1]]=l[i+2]$$$, and if you substitute back you get $$$a[a[l[i]]]=l[i+2]$$$. Hopefully at this point it looks enough like a linked list and $$$a$$$ represents the next array.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Knowing properties of successor (functional) graphs may help, more specifically that in each component of a successor graph there is one and only one cycle (I completely forgot about that one during the contest).

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I loved problem D but I couldn't even think that it's graph and cycles xD, please anyone suggest to me good problems similar to this D.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    It only takes a few simulations of the operation on the sketchpad to discover the cyclic.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can anyone tell approaches of problem 2 xor palindrome

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Hints:

    Consider the indices $$$i=1,2,\dots,\big\lfloor\frac{N}{2}\big\rfloor$$$.

    If $$$s_i=s_{n+1-i}$$$, then we must use either $$$0$$$ or $$$2$$$ ones at these indices.

    If $$$s_i\ne s_{n+1-i}$$$, then we must use exactly $$$1$$$ one to flip one of these two bits.

    Furthermore, if $$$N$$$ is odd, then we can flip the bit in the middle if we want to.

    Solution
»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can someone pls tell why my C failed on system testing?

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

why this code by java get TLE ? 222937329 but this code by c++ get AC 222942899

They are exactly the same code

MikeMirzayanov

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится -17 Проголосовать: не нравится

    Because C++ > Java

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Not fair every code pass with c++ should pass by java

      • »
        »
        »
        »
        8 месяцев назад, # ^ |
          Проголосовать: нравится +14 Проголосовать: не нравится

        Where do rules say so?

        • »
          »
          »
          »
          »
          8 месяцев назад, # ^ |
            Проголосовать: нравится -19 Проголосовать: не нравится

          If it's fair Why Codeforces allow to use different languages One get ac because he know c++ And another one get tle because he write java?? The competition is for those who can solve the problems using any language allowed by the site

          • »
            »
            »
            »
            »
            »
            8 месяцев назад, # ^ |
              Проголосовать: нравится +10 Проголосовать: не нравится

            Well it's known that python is ~100 times slower than C++ and Java, yet it's allowed to use in competition. However a lot of problems can't be solved on python. Same with Java. I guess C++ is the best language for olympiad programming, that's why people use it and problems are made for C++ and MAYBE you can pass using other languages, but no one guarantees you that

            P. S. I don't know for sure, but maybe there are IO optimisations in Java which can make your solution pass

      • »
        »
        »
        »
        8 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Unfortunately that's not true.

        Our target is to get an accepted code within the given time and memory limit. It doesn't matter which language we use. If we use a slower language it is not their fault.

        The time limit and constraints are decided by the problem setter. In some problems, the setter wanted to allow some complexity and not allow slightly greater one. In these cases, they won't care about different/slower languages.

        Find a language faster than C++, it will become mainstream and they'll stop worrying about C++ time limits.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится -19 Проголосовать: не нравится

    UnfairForces

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится -25 Проголосовать: не нравится
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

    Problem C has either too big T or too tight time limit. For example, it could have a limit of T like 10000 instead of 100000. As a result, the problem would be more effective to accept Java solution with the right idea and algorithm. The way it is requires low level IO hacks to squeeze the last IO efficiency to possibly and barely meet the time limit, and as a result the IO code is messy and has poor readability etc, which is NOT the purpose no should be the focus of the problem.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The problem C said, The game ends when Bob cannot make a move or after 2*n+1 moves (in which case Alice's move will be the last one).

This code got the wrong answer during the contest as I wrote code according to the 2*n+1 move.

And after the contest, this one gets ac as I write code according to 2*n+2 move. Why does this happen?

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    IMHO:

    2*n+1 is Alice's last move, after this Bob replies with -1 (which goes to your "n" in the outer loop).

    2*n+2 reads "-1" and moves to the next test case.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Oops! I missed that thing. I thought the loop had done the job of the move-giving part, but forgot that after ending all the moves, Bob can send -1. That -1 may trigger something to process maybe on the judge-end.

      Thank you for the clarification.

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

E2 can be done in maximum of 51 queries ,right? Why is the constraint 57 then?

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    Because author studies in 57th school

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The constraint does not have to be at the tight lower bound. 51 might serve as a big hint; author might have other legit ideas to solve the problem etc.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    did you find that there're a lot of 57 in the problem set?

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

My O(n) code for B got rejected in PyPy but got accepted in python, same exact code . Look into my submissions: https://codeforces.com/submissions/jagan028

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    It seems PyPy struggles more with IO: 223000606

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    alwayss use FAST I/O with python , add this to your code and it will get AC :

    import sys

    input = lambda: sys.stdin.buffer.readline().decode().rstrip()

    t = int(input()) .........

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 3   Проголосовать: нравится +5 Проголосовать: не нравится

    Your code currently spend most time reading in data. What you need is a faster input:

    import sys

    input = sys.stdin.readline

    This is a must for all python/pypy coders, otherwise you will TLE a lot. Just copy the faster input into your template.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks for the help guys!

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I've just solved problem C, got the solution on paper already but didn't implement on time, this is my first time solving interactive problem during the contest.

Thanks guys for the contest!

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Back to back IND vs pak match and back to back contests

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Worst Cf round ever encountered. No announcements made during the ongoing contest to clarify various confusions in the statement.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What is negative contribution?

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Feels like C was forcefully made an interactive problem.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

bruh

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

bruh

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

is it just me or E1 and E2 are very easy??

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Dammn Bro, A Big Yes, in fact after solving E1, E2 was kinda obvious. I should have attempted these questions 1st before D :(

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Can someone explain how can't a be converted to b in examples test case 2 of b=[2,4,3,1] ,,,, using a=[3] and then a=[1,2,4] ? jai bholenath

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

constructive algorithms x7

»
8 месяцев назад, # |
  Проголосовать: нравится +34 Проголосовать: не нравится

Just upsolved E1 and E2, they both seem much much easier than the normal E of Div2, Anyone else who thinks the same?

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    Yeah it was very easy to observe and implement.I wasted all my time trying to solve D.It took me just 15 minutes to solve E after contest without any hint.Regret XD

»
8 месяцев назад, # |
Rev. 7   Проголосовать: нравится 0 Проголосовать: не нравится

Help me explain "Additionally, the number y must be strictly smaller than the last number added by Alice." in problem C div 2 with accepted test case:

1

5

1 2 3 5 7

0

7 7

5 5

-1

why Bob can remove 7 after Alice added 0? thanks everyone.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Please tell me what is wrong with this code (Submission for problem C) :- a) https://codeforces.com/contest/1867/submission/222960759

and how it is different from :- b) https://codeforces.com/contest/1867/submission/223030553

a) -> WA b) -> AC

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How many questions do I need to solve in a Div2 round to reach 1200? I solved 2 this time, that too without penalties and still rating affected negatively :)

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    You need to solve the question as soon as possible, then you will get a good score. Because with the time marks of a question will decrease.

    Example

    1st case:- If you solve question A in the first 5 minutes and get 490 marks but can not solve any other questions.

    2nd case:- You solve A and B in the last 5 minutes of the contest Then that time you will get approx 200 marks for A and 280 for problem B so your score will be around 480.

    So you will get a good rating in 1st case instead of solving 2 questions in 2nd case.

    Please keep in mind the below points

    1. If your rating is not getting increased don't worry, it is just competitive performance.

    2. Just try to solve more questions in the contest.

    3. The ultimate target is to solve more questions in less time.
»
8 месяцев назад, # |
Rev. 3   Проголосовать: нравится +8 Проголосовать: не нравится

MikeMirzayanov salyg1n geranazavr555

I registered to this contest when I was 2100+, so I was labeled as out of competition. The rating is not updated for me. Can you fix this?

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится +17 Проголосовать: не нравится

Maybe problem E2 is a bit easier than D?

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

i'm wondering why my solution to div2 d cannot pass the pretest#2 on the 568th input.

my solution:

  1. add edges: from i to b[i]

  2. check if every i is in a loop case: i is in a loop if the length of the loop is not k, "no" case: i is not in a loop

update: i know.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can someone Please help me what is wrong with my solution it is giving TLE, it's my first time with interactive problem.

https://codeforces.com/contest/1867/submission/222964246

»
8 месяцев назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Some one Please help me what wrong with my solution it is showing TLE, this is my first interactive problem.

EDIT: I found the issue it was mistake in logic

https://codeforces.com/contest/1867/submission/223039411

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain how can't a be converted to b in examples test case 2 of b=[2,4,3,1] ,,,, using a=[3] and then a=[1,2,4] ? fk this shit.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

такой сложный я хочу минус рейтинг

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

.

»
8 месяцев назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

Video Editorial for A — E2 I hope it will Helpful for Newbies and Pupils ... LINK TO YOUTUBE

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится -35 Проголосовать: не нравится

green_gold_dog ace5 bashkort salyg1n

screw this contest!! who the hell wrote the C problem ?!! the game ends after 2*n+1 MOVES so why do I have to take the input after n+1 moves for ALICE ???!!!! i hope the author starts learning simple ENGLISH !! ruined the whole contest for me !

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    pls read "interaction protocol" again: "To make a move, output an integer x — the number you want to add to the set. Then, read one integer y"

»
8 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

wheres the editorial?

»
8 месяцев назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

So, no editorial for this contest?

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

wants minus contribution

»
8 месяцев назад, # |
  Проголосовать: нравится -18 Проголосовать: не нравится

wants minus contribution

»
8 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

When will editorial be out?

»
8 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

RIP editorials

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can anybody give some hints for F?

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

I feel that the order of E needs to be swapped with D, both in terms of the difficulty of thinking about it and the difficulty of implementing it in code. I just started writing E after the contest, and realized that the difficulty of thinking about E is really not too high.

You can find this gap in the two codes I submitted: E2 D

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In problems C, I try to use the scan rather than cin to get the output of Bob. But I get the Idleness limit exceeded :) Can someone tell me why can't use scan?

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    it's not about the input, you have to do output correctly (fflush(stdout) for printf or cout << std::flush/cout << std::endl for cout)

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      that's too weird. The same code just changed the scanf to cin and got the AC. It's my first time to process the problem like this. Next time I will perform better

»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Interesting problems! I love it!!!

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Waiting for the tutorial

»
8 месяцев назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

div2D. how to prove that if there is a cycle of length x!=k, then the answer is NO? thanks in advance

ps: actually, that's not the main question. i just can't find mistake in my thoughts: it's obviously that we must have at least one cycle of length k. also, for every V that is not in cycle, we can place it to the right place using vertices that lie in cycle of length k. now consider vertices that are in cycle of length x!=k. for such vertices we can cut cycle by some edge and add some fake vertices and edges (that will fill the space for vertices that are in cycle of length k, because the last move is operation with cycle of length k and we don't care about such 'fake' numbers) so that our new cycle has length k or 2*k. thus the necessary and sufficient is just to have at least one cycle of length k. where am i wrong?

pps: nvm got it thanks <3

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Whenever you do a single "move", you write a cycle of length k into the array. Later, you can overwrite parts of that cycle with another cycle of length k. However, that doesn't allow you to create a cycle of length!=k, because if you overwrite any part of the old cycle then the old cycle is simply broken, it can't become a cycle of different length.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

please make good problems from next time

»
8 месяцев назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

E2 can be actually done in 51(49+2) operations instead of 57.

If n=2500 and k=50, then it takes n/k=50 operations.

Otherwise, my submission E2 handles something like n=2498 and k=50 in 51=49+2 operations.

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    BTW, you should maybe modify your comment. I read this as 51*(49+2) operations.

    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I meant 51 expressed as 49+2 and not 51*(49+2). Sorry, for the confusion.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why so few div2 contests this month? I can see only 2 div2 on calender for this month.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

please post the editorial of this contest

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

why am i getting runtime error @testcase3 que D. Any python charmers hlp!


for _ in range(int(input())): n,k=map(int,input().split()) arr = [x - 1 for x in map(int, input().split())] if k==1: if arr==list(range(n)): print('YES') else: print('NO') else: memo={} def dfs(node,c): if node in memo: return memo[node] count[node]=c ch=arr[node] if count[ch] is None: local=dfs(ch,c+1) else: if abs(count[node]-count[ch])+1==k: local=True else: local= False memo[node]=local return local final='YES' for i in range(n): count=[None for _ in range(n)] ans=dfs(i,0) if ans is False: final='NO' break print(final)
»
8 месяцев назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

Nice problems imo!

I liked that they had cute solutions with short implementations, and the proof difficulty is very appropriate.

»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

@MikeMirzayanov

My old Codeforces ID, Mussic has been blocked by Codeforces.

When I try to log into it, it shows me the message "Disabled by Administrator" due to "significantly coincident" matching of my solution for submission 222923273, 1867A - green_gold_dog, массив и перестановка and 222980969, 1867C - salyg1n и игра с MEX of this contest.

I can swear that I have neither copied any of my solution from anyone, nor shared my own solution with anyone.

The questions was very straight forward and and did have some standard ways of solving, like using storing the pair of vectors. So, the matching was purely coincidental and inevitable.

Kindly remove the restrictions on the Codeforces ID: Mussic, as it contains months of my hardwork.

»
2 недели назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I want to clarify that my solution matched with some one according to system but I don't think except the template anything has matched. Your solution 222949914 for the problem 1867C significantly coincides with solutions subodh.r/222945531, Mr.Roamer/222949914. This are the 2 solutions. And the template we both used is available here https://youtu.be/8ymiMHQPgZY Pls review the solutions if possible. I apologise for the delay in doing this comment.__