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

Автор Proof_by_QED, история, 7 месяцев назад, По-английски

Hello Codeforces.

We are introducing a new type of problem which may appear in future Codeforces rounds, called Communication problems!

In these problems, your program would be ran twice, with different input and output formats between the runs. All variables stored in the memory will be lost between runs. However, the information given to you on the first run may be important to you for completing the second run correctly. Therefore, one of the key challenges in these types of problems would be to find a way to use the limited amount of output you are given in the first run to communicate information to the second run. Below shows a flowchart.


2025-09-06-12-40-07
Flowchart for communication problems

In these problems, time and memory limits for both runs would be kept separately. For example, if a problem has a time limit of $$$2$$$ seconds, you will only get the Time Limit Exceeded if program runs for more than $$$2$$$ seconds on one of the runs, but not if both runs takes $$$1.5$$$ seconds.

It is also possible that a problem is both interactive and run-twice. There may be interaction on either run of your program. For these types of problems, it is especially important to read the problem statement carefully to ensure you are getting the input and interaction format correctly, especially regarding whether you must flush your outputs.

To give participants a feel of these new types of problems, we will hold Testing Round 20 (Unrated, Communication Problems), which will start on Nov/03/2025 17:35 (Moscow time). You will be given $$$1$$$ hour to solve $$$3$$$ run-twice problems. The problems are authored by cry, yse, SpyrosAliv, and chromate00. One problem on the set will be interactive, so you are recommended to read the guide for interactive problems if you are unfamiliar with these types of problems. Of course, this round will be unrated. Good luck, and I hope you will have fun with the new type of problem!

Edit: The contest will be in ICPC format with no pretests and hacks disabled.

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

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

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

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

$$$67$$$

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

Oh no...

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

So now we solve for alice and bob, yaay

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

As Competitive Programmers, we already have communication problems.

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

I'm Excited..

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

As a tester, wait where is the tester list.

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

Any good advice on how to test communication problems locally in a fast and simple manner? Because for interactive problems it's the most painful part despite problems themselves being fun.

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

    It will be better for communication problems than interactive ones. Because you just need to copy the data, run it once, copy the result, then run it again. There is no need to think what should be input like interactive problems.

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

    On olympiads the problem author gives an archive file containing a program that will test your code automatically for both interactive and communication problems, and I would definitely like seeing that implemented in codeforces. One can only hope.

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

My crush already ran twice (away from me)

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

This being posted one week after my run-twice problem in PHSCO is a pretty funny coincidence lol

Either way, run-twice is a very under-appreciated problem format in Codeforces and I'm excited for its debut in a future rated round!

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

    Also, will this contest mean that Codeforces will give better debugging feedback for run-twice problems (i.e. sample verdicts)? Because a big issue with run-twice right now is that the only judging information shown is the input during the first run and the output during the second run (first run output and second run input is notably hidden).

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

Will the run-twice problem(s) being announced in contest post like interactives? When will the first rated contest using this new setup of problem?

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

Would this format help combat AI? I think interactive problems are generally harder for chatGPT to figure out (is this true?). If we make interaction non-trivial, we have more potential choke points.

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

    Around half a year ago (probably before o3 and o4-mini) that might have been true. But now, judging from their performance at IOI 2025, I suppose we can't be so sure about it. Similar to interactive problems, the coordinators need not (and probably should not) care about AI when choosing such problems for rounds.

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

      It got the least amount of points on the communication problem. So, it might be correct to say that it performs worse on communication problems relatively to batch problems. And maybe it's due to the fact that #communication_problems << #batch_problems, thus less data for it to train on.

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

      Judging AI by just from their performence in IOI is wrong. Not because AI didn't do that, AI in fact did do that. But what's not being told is that google and microsoft consumed hundreds of thousands of dolars worth of electricity trying to get those scores, and no AI company is going to give access to that to a customer paying 20$ or so per month. Yes, AI is good. But it costs a lot. And there is no way in it's current state it's going to be solving IOI problems for the average customer.

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

        But what's not being told is that google and microsoft consumed hundreds of thousands of dolars worth of electricity trying to get those scores,

        Did I reject that? Everyone knows this and it's neither a secret nor a surprise. The point is not that the model is too strong, it's that their "expected rating" isn't any different with regard to problems with different formats.

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

WOW

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

Similar type of problem

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

it might be helpful to share approx difficulty level of these problems so that I can decide if I should take part ...

I am fascinated by this new problem type, but also curious about why authors conceived of this new problem type.

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

A very interesting problem type. Looking forward to seeing these problems in following codeforces rounds!

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

Seems interesting... Let me too register for this and help in testing

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

new type of interactive-like problem, yum yum

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

As a non-tester, I hope to be a part of this testing round. (Does that actually make me a tester?)

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

As fun as it might be, I'm definitely cooked. I still haven't gotten the hang of interactive

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

Dope!

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

As a participant, am I going to test?

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

DREAMS DO COME TRUE

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

This is a testing round, so if I participate, I will be a tester.

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

Finally, codeforces supports communication problems!

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

Nice

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

i dont understand this

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

    It’s basically that your program is going to run twice (during each run the memory is going to erase). The judge is going to take the output from the first run and going to use as input for the second run. Think about implementing an algorithm that could perfectly reconstruct the original data.

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

It would be nice to have a "Communication" tag for these problems

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

:fire:

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

So the only CF round where all participants are testers !?!?

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

Very interesting problem type. Next update to this would be 'run k+1' times where k would be decided in the first run.

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

Bold of you to assume i have any communication skills

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

Will the tasks be similar to oj.uz communication? For example https://oj.uz/problem/view/JOI21_shopping

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

Hopefully, Olympiad organizers in Syria won't see this as a chance and decide to organize our TST on codeforces

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

can someone provide communication based problems difficulty wise from various platforms please ? atleast 5-6?

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

It is also possible that a problem is both interactive and run-twice.

I can imagine that this will be very tedious to debug without a grader :'(

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

I absolutely have no idea how this will work. Could someone please explain how it differs from conventional contest problems?

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

Can we just solve the problem in the first run and then transfer it through compression algorithms to the second run and then decode? Is this solution meant for these problems or not? Or, both is okay?

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

    Depends. You can check out the various type of problems of this format on the contest I linked above. Sometimes it's about devising a compression method, sometimes it can be about devising a way to make the data resistant to error, or sometimes it can be something else!

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

What will we get in the future? Simulation Problems?

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

AI cheaters: sobs...

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

Are the problems going to be actual problems? Or will it be print a + b difficulty to test that the grader doesn’t explode?

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

Is the purpose of this new problem-type to prevent cheating ?

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

In the Russian community, such tasks are called "Double-run tasks" (Задачи с двойным запуском). The most popular of them is to implement the "Hamming code" (you must encode and decode binary string)

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

So basically, Codeforces just said, “your code has short-term memory loss, deal with it.” Time to teach my program how to leave notes for its future self. :)

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

As a Participant, I am really excited for this contest.

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

1392E - Omkar and Duck

Here is a nice run twice type problem

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

This was my first time doing communication problems and I hecking love these tasks but I'm an ICPC participant now 😭😭

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

I am a bit disapointed, because I allways get "Idleness limit exceeded on test 1" :/ No idea what is wrong.

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

This problem seems more like encryption and decryption kind of think..

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

This type of problem doesn’t have a corresponding error type, so you have no idea what went wrong.

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

This communication format is really awesome. Great to see CF trying out new stuff!

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

Someone please explain the approach for Problem C? Please give some hints.

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

    There's a problem D??

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

    There is no problem D. If you mean problem C, google Hamming code.

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

    Here's my approach.

    (First Phase) Use $$$1$$$ to $$$15$$$ bits to express $$$x$$$ (its binary expression) , then calculate the xor for these used bits. This will give you a number which is less than $$$16$$$ . So then save this number use $$$16$$$ to $$$19$$$ bits. Then finally, add $$$20$$$ when there is odd number of bits from $$$16$$$ to $$$19$$$ .

    (Second Phase) So, when change is at $$$16$$$ to $$$20$$$ , you can find it by calculate bits count of them. (Its parity will tell you whether it is changed or not) If it is changed, it tells us bits from $$$1$$$ to $$$15$$$ is right, then just calculate $$$x$$$ back. If it is not, calculate the xor for former $$$15$$$ bits using the same strategy and the value expressed by bits $$$16$$$ to $$$19$$$ . If the result is not $$$0$$$ , it will tell you the bit that is changed. Filp it and you will get the answer. If it is $$$0$$$ , then the set is unchanged(And of course you will know the answer then).

    Summing up the above,you are able to find the answer $$$x$$$ .

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

      Does this approach have a name? It is quite similar to Hamming code and almost as efficient as it (requires at most 1 more bit than Hamming codes).

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

        Well, I don’t know if it has a name or not because I think it up myself:) Actually, I would like to think that I was inspired by Hamming codes and the goals are similar.

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

Not sure if this has been mentioned before, but it would be nice to maybe introduce the communication problem tag!

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

I think the problems were very easy. But considering it was for testing purpose, its fine. But loved the theme anyways.

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

Kept on getting WA on test 9

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

I enjoyed those new types of questions, codeforces should really add these in regular contests

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

Loved this Round, and the new concept ggs!!

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

How to solve B and how to use x?

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

    Without using x you can easily find [l, r] such that a[l] and a[r] are 1 and n or vice versa using binary search. You can use x to tell if l is 1 or n by setting x to 1 if the position of 1 is lesser than n in the original array

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

Really enjoyed the problems a lot. This is really interesting task type.

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

Why do you need to shuffle tests in B? And if this becomes a common practice in problemsetting, can you please not say the number of shuffled test in verdict?

I had wa1 in B with this message: "Second run message: wrong answer Guessed 2, Expected 1 (test case 2)". The tests look like this

first 3 3 3 2 1 5 1 2 3 4 5 5 4 2 3 5 1

But the answer to the second test is 5, not 1 nor 2. Turns out second case in the second run was [3, 2, 1] which is the first test in preview.

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

    Tests are shuffled in order to prevent sending information about what test case it is in the first run. But yes, we will ensure that this issue will not happen in communication problems in actual rounds.

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

      In order to prevent sending information wholly using multi-cases, you can also secretly split tests in the first phase into two or more parts and run them separately. For time limit, just sum them up(or maybe a max in case there’s initializations). I believe that adopt this strategy or mix them(I mean, both shuffle and split) together will block this method better.

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

Can we see how to set the tasks of TR20 with Polygon, as a sample?

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

I think it's time to add this line into our template:

while (t--)
{
    #ifdef MULTI_RUN
    string s; cin >> s; if(s.compare("first") == 0) solve(); else solve2();
    #endif
}
  • »
    »
    6 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    That fails for the problem B where the no. of test cases $$$t$$$ comes after the phase "first" or "second". The phase string will always come before the test case count because only one particular phase is expected per execution.

    Also, if (s == "first"sv) works fine, or you can also just compare the length of the string but that would lose clarity.

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

nice i am excited

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

i am excited

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

That seems brilliant and will introduce many new ideas and problems!

I just have a question for Proof_by_QED of any of who started this brilliant initiative: why limit to one-round communication? Is it possible that the problems will have multiple rounds as well? (May be $$$k \leqslant 20$$$ determined by the judge at the beginning of the problem)

Communication is a standard idea in Algorithms and Complexity Theory, so I'm excited for what this has to offer (for example, C in the testing round introduced the idea of error-correcting codes!)

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

Cool ideas Can anyone give some brief on the creative side of problems that could unlock or kind of a why such class of problems exist in general?

For A2,You can simply encode each digit to corresponding character, so at max 10 digits+ a separation character(to understand that was a number ending there), exactly fitting in the length(10^4*10), except for 10**9 you need to encode a separate character(otherwise wa on 9).

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

People working in different computational fields of computer science should try involving real-world applications in competitive programming on codeforce. It helps you grow in all directions, and such problems are really fun!

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

one more annoying type of problems! 2 times bigger code... O_o

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

Ok, so to be honest, at first I was very hesitant about communication problems and failed to see why they would be interesting at all, in fact both a and b were extremely easy and overall boring, quick to figure out, and nothing interesting. However, I admit C was cool, maybe one of my favourite problems of recent times

It was pretty easy to figure out

Spoiler

The

Spoiler

However then I got stuck as

Spoiler

Overall, very nice problem, and completely changed how I view communication problems, I think these are a welcome change to CF as long as they require creative never-before-seen (in cf) ideas

However, I still think B is a useless problem and I question why it exists? Its trivial and does not require any neat tricks in the first place.

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

Will there be communication problems in future rounds?

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

The new Communication Problems are one of my favorite type of problems. I can suggest you to look to the Ejoi 2020 day 2 Problem B Card Trick, if you want to solve more Communication Problems. https://eolymp.com/en/compete/c008c563-2b60-42ca-a5cf-1881ed4e2195/problem/2

Here is my solution.

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

hi

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

In C can there be multiple second runs? (I see that it runs exactly twice but can this be implemented?)

For example for each first run there are 21 second runs, one for each possible change. Or maybe just put everything in one run with 21x more testcases, but if there are no multiple testcases then that doesn't work.

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

Try CF Submitter : https://marketplace.visualstudio.com/items?itemName=DevXSayan.cf-submitter - Fetch all the problems of a contest inside vscode, run test cases, and submit in one click, all without leaving vscode

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

So it is interactive but not interactive also

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

Wow, this idea is really interesting. Now I’m thinking about a type of problem that involves executing the code K times (possibly more than twice). For instance, manually running a CNN. It might take a week for a submission to be judged. :)

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

I didn't really understand anything, but I'll pretend like I did... By the way, how do we solve communication problems? I mean, we are programmers...

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

Can someone explain what is the difference between just these types of problems and the previous already existing problem. We know that if the run is first then execute solve1 else execute solve2.

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

    The behavior of solve2 heavily depends on the behavior of solve1, it is not like you are solving two completely independent problems.

    One example, a task that requires you to prove that there is a bijection between two sets by constructing one can't be easily evaluated without this format.

    Check the problems in this contest: https://contest.ucup.ac/contest/1465

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

Hello, respected Codeforces coordinators. I received a plagiarism warning for submission 346344726 . I assure you that I did not share my code with anyone or copy from others intentionally. I might have used a similar approach or template that could have caused this similarity. If needed, I can provide my code history, local editor files, or screenshots showing my development process. I kindly request a recheck or reconsideration of this case. Thank you for your understanding and for maintaining fairness on the platform.[user:c231080_masrur][submission:346344726] ~~~~~ Your code here... ~~~~~

include <bits/stdc++.h>

using namespace std; using ll = long long;

int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; if (!(cin >> T)) return 0; while (T--) { int n; ll k; cin >> n >> k; vector<vector> adj(n+1); for (int i = 0; i < n-1; ++i) { int u,v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } vector parent(n+1, 0), order; order.reserve(n); parent[1] = 0; order.push_back(1); for (size_t i = 0; i < order.size(); ++i) { int u = order[i]; for (int v : adj[u]) if (v != parent[u]) { parent[v] = u; order.push_back(v); } } vector sz(n+1, 0); for (int i = n-1; i >= 0; --i) { int u = order[i]; sz[u] = 1; for (int v : adj[u]) if (v != parent[u]) sz[u] += sz[v]; } ll total = 0; for (int v = 1; v <= n; ++v) { ll cnt = 0; if (n >= k) cnt += 1; for (int u : adj[v]) { ll s_u; if (u == parent[v]) s_u = n — sz[v]; else s_u = sz[u]; if ((ll)n — s_u >= k) cnt += s_u; } total += cnt; } cout << total << '\n'; } return 0; }

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

I think that communication problems have good potential and I am looking forward to seeing them in future contests.

As others have mentioned it is now time to update code templates to handle them. I have also written some shell command lines that allow easier testing.

For problem A I have used:

./a.out < example.in | tee first.out && (echo "second" && cat first.out) | ./a.out

Where example.in is the input of the first execution. And a.out is the compiled binary.

For problem C we need to pass the number of test cases to the second program. The command now looks as follows:

./a.out < example.in | tee first.out && (echo "second $(sed -n '2p' < example.in)" && cat first.out) | ./a.out

It doesn't do communication mangling which was in C, and interactive problems still require special handling. However, I believe this should at least be helpful for most of such programs.

Feel free to use it and share your commands if you came up with something better.

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

tung tugnb tung saHUR

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

It seems that will have more great problem

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

orz

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

okay