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

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

Hello, Codeforces!

We are proud to invite you to participate in Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) which will be held on Aug/07/2025 17:35 (Moscow time).

The round will be rated for everyone. You will be given 8 problems, one of which is divided into two subtasks, and 3 hours to solve them. One of the problems will be interactive, so make sure to read the guide for interactive problems before the contest.

The problems are authored and prepared by Ali_BBN, Bahamin, _R00T, eren__, sweetweasel, and me.

We would like to thank:

Special thanks to [MVP] LMydd0225 for his invaluable help during testing!

The scoring distribution is below.

A B C D E F G1 G2 H
$$$500$$$ $$$1000$$$ $$$1500$$$ $$$2000$$$ $$$2500$$$ $$$3000$$$ $$$2750$$$ $$$2750$$$ $$$4000$$$

Now, a few words from our sponsor!

At Atto Trading, we are a science-driven quantitative trading firm where engineers, quants, and researchers combine their efforts to engineer cutting-edge trading systems that execute in nanoseconds, powering decisions at the speed of light in the world’s most competitive market. Many of our team members started their journey on platforms like Codeforces. We are thrilled to announce our own round on Codeforces platform.

Follow the link below and complete the application form to explore career opportunities with us.

Fill Form →

We prepared some exciting rewards for participants in this round.

  • Rank 1: Apple MacBook + backpack + branded T‑shirt + sports bag
  • Ranks 2-3: Apple iPad + backpack + branded T‑shirt + sports bag
  • Ranks 4-5: Apple Watch + backpack + branded T‑shirt + sports bag
  • Ranks 6-20: Backpack + branded T‑shirt + sports bag
  • Ranks 21-100: Branded T‑shirt + sports bag

If we encounter difficulties delivering your gift, we reserve the right to reimburse its value in cryptocurrency

Good luck!


UPD 1: Score distribution was released!

UPD 2: Editorial

UPD 3: Congratulations to the winners!

  1. ksun48

  2. jiangly

  3. turmax

  4. tourist

  5. jiangbowen

  6. zhoukangyang

  7. maspy

  8. ecnerwala

  9. Radewoosh

  10. 244mhq

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

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

as a tester, i can confirm the problems are "absolute cinema"

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

As a tester, “googooli” contest

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

Nice problems, recommend to participate

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

Hoping for a positive $$$\Delta$$$

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

Ayy, massive congratulations to Hamed_Ghaffari and eren__ for snagging silver medals at IOI2025! The GOAT has officially announced his round!

ORZ ORZ ORZ

And a huge shoutout to the entire Iranian National Computer Team for achieving the 7th global rank at IOI2025, with Hamed and Mani being a part of this incredible squad! What an outstanding achievement for all of you and our country!

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

As a tester, it would be fun for every participants, from gray to Nutella!

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

As a tester, this is one of the best rounds of the past 2yrs, I actually enjoyed solving the problems and didn't swear at the writers

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

As the "MVP", I want to copy Error_Yuan's words: Nice problems, recommend to participate :)

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

as a tester, my biggest regret is not being able to participate in this round

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

I think the problem statements should be short and easy.

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

"What is the probability of me winning an Apple MacBook?"

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

like this comment if you join this contest in order to miss gf :heartpulse :heartpulse

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

as a tester, this contest is "MAMAMIA MAMACITA COACHELA"!

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

August 7th is my birthday. Although I won't take part in the contest, best regards for everyone.

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

I'm new to comp. coding and this is my first contest, and I hope to give it my all. I love codeforces and the community so far :)

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

Why are the competitions held in my sleeping time?

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

Can kevin exceed tourist?

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

as a tester , I wish i could go back in time and choose to participate in this round instead of testing it ! :)

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

.

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

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

Wish interactive problem is D.

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

Rank 1 tourist.

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

It started with 9 rejected problems. It ended like this:

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

I originally planned but now I am unable to participate this round. Anyway, hope it has great problems and may it be cheater free!

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

Otto Round?

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

Thanks! Hamed_Ghaffari for providing this Information and I'm so much excited to participate in this contest.

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

It is essential to identify and prevent the use of AI-generated code. Dear author, please consider taking appropriate action regarding this issue.

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

It would be much better if you also gave away prizes for some of the ranks 100-1000. This would increase the competition.

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

as it is a round sponsored by quant company i guess this will be a math round

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

Standings/leaderboard is broken? I can't open it

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

I HOPE I GOT + Δ

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

B>>

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

aaaaaahhhhh !!! got idea of D so quickly .. but the WA -> WA -> WA -> WA -> WA ..... -> WA -> AC

and 1 to 3 is CASEWORKforces

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

Struggled alot to understand questions :<

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

can anyone please explain how they solved D?

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

    It may not be difficult to implement, but it requires careful analysis of the problem For the problem to have a solution: 1. The graph must not be a circle (it must be a tree) 2. If we root the tree from a leaf, all children except one must be leaves (you can check) Then you have to go and multiply your answer by the following value at each step: (count is the number of leaves) ans *= count! ans %= mod Finally multiply by 4 (horizontal and vertical symmetry) We also have an exception!!! If the graph is star-shaped (all vertices are connected to one vertex) Then the answer is 2 * (n-1)!

    #include <bits/stdc++.h>
    using namespace std;
    
    /* Besme allahe alrahman alrahim */
    
    #define mod 1000000007
    
    struct Node {
        char color='w';
        int h;
        int par;
        bool barg=false;
        vector<int> hamsa;
    };
    vector<Node> nodes;
    int n;
    bool mishe=true;
    bool canzarb=true;
    long long ans=1;
    
    long long fac(int x) {
        long long ani=1;
        for(int i=1; i<=x; i++) {
            ani*= 1ll*i;
            ani%= mod;
        }
        return ani;
    }
    
    void dfs(int x) {
        nodes[x].color='r';
    
        if(nodes[x].hamsa.size()==1) {
            nodes[x].barg=true;
        } if(nodes[x].hamsa.size()==n-1) {
            canzarb=false;
        }
    
        for(int i: nodes[x].hamsa) {
            if(nodes[i].color=='w') {
                nodes[i].h=nodes[x].h+1;
                nodes[i].par=x;
                dfs(i);
            } else {
                if(i!=nodes[x].par) {
                    mishe=false;
                }
            }
        }
    }
    
    void dfs2(int x) {
        nodes[x].color='r';
        int all=(int)nodes[x].hamsa.size();
        int count=0;
    
        for(int i: nodes[x].hamsa) {
            if(nodes[i].barg) {
                count++;
            }
            if(nodes[i].color=='w') {
                dfs2(i);
            }
        }
    
        if(all-1-count>1) {
            mishe=false;
        }
        ans*= fac(count);
        ans%= mod;
    }
    
    
    void solve() {
        int m;
        cin>>n>>m;
    
        for(int i=0; i<n; i++) {
            nodes.push_back(Node());
        }
        for(int i=0; i<m; i++) {
            int a,b; cin>>a>>b; a--; b--;
            nodes[a].hamsa.push_back(b);
            nodes[b].hamsa.push_back(a);
        }
    
        if(n==2) {
            cout<<2<<endl; return;
        }
    
        nodes[0].h=0;
        dfs(0);
    
        if(mishe==false) {
            cout<<0<<endl; return;
        }
        for(int i=0; i<n; i++) {
            nodes[i].color='w';
        }
    
        for(int i=0; i<n; i++) {
            if(nodes[i].barg) {
                dfs2(i);
                break;
            }
        }
        if(mishe==false) {
            cout<<0<<endl; return;
        }
    
        if(canzarb) {
            cout<<(4ll*ans)%mod<<endl;
        } else {
            cout<<(2ll*fac(n-1))%mod<<endl;
        }
    
    }
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int t; cin>>t;
        while(t--) {
            solve();
            nodes.clear();
            mishe=true;
            canzarb=true;
            ans=1;
        }
    
        return 0;
    }
    
  • »
    »
    8 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    First, note that if the graph isn't a tree (or a forest, but statement says it's connected), the answer is $$$0$$$, because there's no way to build a cycle of bridges without a self-intersection or a bridge connecting two houses on the same side. Then, note that assuming the answer is $$$ \gt 0$$$, in the tree, every vertex can have at most $$$2$$$ neighbors which aren't leaves, otherwise there is a non-leaf neighbor fully cut off by remaining bridges from this vertex, a contradiction. Thus, the non-leaf vertices of the tree form a path (assuming a non-leaf vertex exists, but otherwise $$$n=2$$$ and the answer is clearly $$$2$$$)). Then, note that there are either $$$2$$$ or $$$4$$$ "distinct" ways to create the path, depending on whether it's size is at least $$$2$$$ (choices are first riverbank and "direction"), and then for each vertex on the path neighboring $$$d$$$ leaves, they all have to be between the neighbors on the path in any order, so we get $$$d!$$$ options for each. Just multiply everything and we're done.

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

    I was trying this, but only passed the given test case

    1. First assign 0/1 colours to all nodes; two nodes with an edge should have opposite colours. if not possible -> return 0
    2. Second, start with a node having degree 1, traverse all nodes, and only one of these nodes should have a degree > 1 to prevent the crossing

    If both of the above conditions are satisfied, then only we can have an arrangement

    For the total number of arrangements

    1. For every node having degree > 1, find how many nodes are connected with degree 1, because we can permute them. Let's say it is x1, x2, x3 and so on — then total arrangements would be x1! * x2! * x3! * ...
    2. Then we can flip up and down so multiply by 2 ( this is only applicable when there are at least 2 nodes with degree > 1)
    3. Then we can flip right, left, so again multiply by 2

    Not sure what is wrong with this approach. Can someone please point out the mistake

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

      Based on what you've written (haven't seen the code), you appear to be incorrectly answering the case when there's only one vertex with degree $$$ \gt 1$$$, and therefore the right-left flip doesn't do anything. EDIT: Checked the code and you did take care of that, so I don't know.

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

        no that case is correct when only 1 node with degree > 1 then x1 will be n-1 I do not consider the up-down flip, so skips multiplying by 2 But I am considering a left-right flip, so multiply by 2

        The final answer comes out to be 2 * (n-1)!

        One clarification -> I am considering the right-left flip to be across the river — different from the picture given in the question

        -- I feel like my approach is correct, but I have made it unnecessarily complex, and must've made some implementation error

        Your explanation makes it much easier — thinking in terms of a tree. Thanks, will try to implement that

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

          first off labeling nodes with colors isnt needed because the graph must be a tree, and all trees are bipartite graphs so you can check if $$$n = m-1$$$ instead. Second your "one of these nodes should have a degree >1 to prevent the crossing" is either wrong or worded badly. The right condition is that "at most 2 neighbors of any node can have a degree >1". There are only 2 places for a neighbor with degree >1 to fit (right and left) and any middle spot will cause a cross.

          Looking at your code, your counting seems right but you don't make sure the graph has no cycles and your double bfs for degree counting is funky.

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

Was I the only one unable to access standings throughout the whole duration of the contest?

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

Great problems! But sadly problem F is chatgpt-solvable. Proved by BinaryPhoenix10 and other talented participants. Bless them!

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

    You are right! I couldn't find a solution better than O(nk) then I just search on chatgpt on find number of n-element arrays of sum y such that each element is at most k, and it gives me the closed solution using exclusion-inclusion. Then, I ask to do the same on number of n-element arrays of sum at most y and each element at most k, and it gives me a very clean solution computable in O(k) time (by using some combinatoric magic) which gives us a O(nlogn) solution! Too bad, I only read your comment after the contest!

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

OHH MAN B WAS SO TOUGH . IS IT SAME FOR OTHERS?

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

    istg same

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

    literally got me brainstorming with pen and paper for an hour. When I finally got AC, I was so happy.

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

      HOW DID YOU SOLVE IT CAN YOU PLEASE HELP

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

        the formula is

        optimal = min(minCover + canCover, maxCover) + 1

        here minCover is the minimum of leftCovered and rightCovered. maxCover is max of leftCovered, rightCovered. leftCover is the distance between left most index (0) to the closest left side wall from the position of hamid, similarly rightCover is the distance between the right most index(n-1) and the closes right side wall. canCover is the distance between left closest wall and hamid, if leftCover is minCover or it is the distance between right closest wall and hamid if rightCover is minCover. The entire problem is based on which side will Mani put the first wall, once that is found, the problem will naturally be easy. The formula i told is based on which is the most optimal side to place the wall at

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

My code for C Can anybody tell me where I m wrong

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define PB push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;

int gainFromPair(int a1, int a2, int b1, int b2) {
    vector<int> v = {a1, a2, b1, b2};
    int original = abs(a1 - b1) + abs(a2 - b2);
    int maxGain = original;
    sort(v.begin(), v.end());
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (i == j) continue;
            int a_i = v[i];
            int b_i = v[j];
            vector<int> remaining;
            for (int k = 0; k < 4; k++) {
                if (k != i && k != j) remaining.push_back(v[k]);
            }
            int a_j = remaining[0];
            int b_j = remaining[1];
            int val = abs(a_i - b_i) + abs(a_j - b_j);
            maxGain = max(maxGain, val);
        }
    }

    return maxGain - original;
}

void solve(){
    int n, k;
    cin>>n>>k;
    vector<pair<int, int>> a(n + 1), b(n + 1);
    for(int i = 1; i <= n; i++){
        int x;
        cin>>x;
        a[i] = {x, i};
    }
    for(int i = 1; i <= n; i++){
        int x;
        cin>>x;
        b[i] = {x, i};
    }
    
    int mini = 0;
    for(int i = 1; i <= n; i++){
        mini += abs(a[i].first - b[i].first);
    }
    
    vector<pair<int, int>> helpA = a;
    sort(all(a));
    int increase = 1e9;
    
    for(int i = 1; i < n; i++){
        int a1 = a[i].first, a2 = a[i + 1].first;
        int b1 = b[a[i].second].first, b2 = b[a[i + 1].second].first;
        increase = min(increase, gainFromPair(a1, a2, b1, b2));
    }
    
    a = helpA;
    sort(all(b));
    
    for(int i = 1; i < n; i++){
        int b1 = b[i].first, b2 = b[i + 1].first;
        int a1 = a[b[i].second].first, a2 = a[b[i + 1].second].first;
        increase = min(increase, gainFromPair(b1, b2, a1, a2));
    }
    
    cout<<mini + increase<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}
»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

I GOT THE BEST RANK I'VE EVER GOTTEN IN CF TODAY. I'M SO HAPPY.

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

guys what this error Compilation error this is first time This appears to me

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

How to do C guys? I can't think anymore

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

    You can take some (i, j) pair over and over again so its basically solve for k = 1 everytime. Then u just need to find (i, j) pair that adds least amount to original answer and just take that all the time. Furthermore if u have a[i], b[i] and a[j], b[j] then this pair only adds extra if max(a[i], b[i]) < min(a[j], b[j]) or vice versa and it adds 2*(min-max). So we sort pairs {min(a[i], b[i]), max(a[i], b[i])} check if there exists any adjacent pairs such that min < max(basically add 0) and if none exist take the minimum of min-max of adj pairs.

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

    First thing first, only 1 round matters, because Ali can keep choosing the same i and j and only one time Bahamin can gain points. Now, If you have i and j, such that max(ai, bi) >= min(aj, bj), then there will no score gain from this pair and Ali can choose this pair, otherwise try to minimise gain, which you can see here: 332903480

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

how C?

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

too hard -_-

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

B was really easy in retrospect, but I was in off-by-one indexing hell during the contest. Also didn't help that I misread at first and thought you could only move one space at a time :|

C was interesting, it was pretty funny that K didn't matter at all (noticed this <5min lol)

Overall good problems in retrospect and orz to the problemsetters, even if I trolled

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

Thank you for these problems! I don't remember the last time I enjoyed solving a codeforces round as much as I did today (:

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

E was nice, proving that adding additional color to a subtree(if the subtree doesn't already have that color) doesn't improve the cost was the key!

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

What's up with H limitations? Is the model solution exponential in $$$n$$$?

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

Enjoyed D a lot. Literally the first time to go through an hour of thinking to get to a correct answer, and the trill of seeing the pretests passed is just incomparable!

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

I can't remember a codeforces round where the problems were as enjoyable as today. Thank you!

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

H is the worst problem in the history of cf. Just random shuffle the edges 1e5 times and choose greedily(as the order of the edges) passes. 332898118

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

I loved this contest, thank you for such great problems.

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

Amazing contest... thank you very much!

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

I need 29 rank to become red... And predictor shows +29... Hope

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

rk103… No!!! My tshirt!

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

sad/(ㄒoㄒ)/~~

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

C Good problem.

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

I don't understand whats wrong with my code for problem B.

// this is code
int main() {
	long long t;
	cin>>t;
	while(t--){
	    long long n,x,c=0;
	    cin>>n>>x;
	    char a[n];
	    for(long long i=0;i<n;i++){
	        cin>>a[i];
	        if(a[i]=='#') c++;
	    }
	    x--;
	    if(x==0 || x==n-1 || c==0) cout<<"1\n";
	    else if(a[x-1]=='#' || a[x+1]=='#')cout<<min(x+1,n-x)<<'\n';
	    else{
	        long long l=-1,m=n;
	        for(long long i=x;i>=0;i--){
	            if(a[i]=='#'){
	                l=i+2;
	                break;
	            }
	        }
	        for(long long i=x;i<n;i++){
	            if(a[i]=='#'){
	                m=i+1;
	                break;
	            }
	        }
	        if(l==-1) cout<<min(x+1,n-m+2)<<'\n';
	        else if(m==n) cout<<min(l,n-x)<<'\n';
	        else cout<<max(l,n-m+2)<<'\n';
	    }
	}
}

Anyone please explain.

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

    I was doing something similar but I can suggest you not to use x--. Anyway, if you count based on the position of x (not x--), the answer is either x or n-x+1, while if you count based on the position p of the wall you place, the answer is either p+1 or n-p+2

    import sys, random, bisect
    from collections import deque, defaultdict
    from heapq import heapify, heappop, heappush
    from itertools import permutations
    from math import gcd, log, sqrt, isqrt
    
    input = lambda: sys.stdin.readline().rstrip()
    
    
    def solve():
        n, x = map(int, input().split())
        a = input()
        c = 0
        for i in range(n):
            if a[i] == "#":
                c += 1
        if c == 0:
            print("1")
            return
        indl = float("+inf")
        indr = float("+inf")
        for i in range(n):
            if i < x - 1 and a[i] == "#":
                indl = i + 1
            elif i > x - 1 and a[i] == "#":
                indr = min(indr, i + 1)
        if x == 1 or x == n:
            print(1)
            return
        if indl == x - 1 or indr == x + 1:
            print(min(x, n - x + 1))
            return
        if indl == float("+inf"):
            print(min(x, n - indr + 2))
            return
        if indr == float("+inf"):
            print(min(indl + 1, n - x + 1))
            return
        res1 = min(n - x + 1, indl + 1)
        res2 = min(x, n - indr + 2)
        print(max(res1, res2))
    
    
    for _ in range(int(input())):
        solve()
    
»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится -20 Проголосовать: не нравится
const int maxn = 2e5+100;
int mod = 10e9+7;
ll fact[maxn];
void init() {
    fact[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fact[i] = ((i % mod) * (fact[i - 1] % mod)) % mod;
    }
}

ll mul(ll a, ll b) {
    return (a * b) % mod;
}

struct test {
    vector<vector<int>> adj;
    vector<bool> is_leaf;
    vector<int> deg, leaf, non_leaf;

    void solve() {
        int n, m; cin >> n >> m;
        adj.resize(n);
        deg.assign(n, 0);
        is_leaf.assign(n, false);
        non_leaf.assign(n, 0);
        leaf.assign(n, 0);

        for (int i = 0; i < m; i++) {
            int u, v; cin >> u >> v;
            u--, v--;
            adj[u].pb(v);
            adj[v].pb(u);
            deg[v] += 1;
            deg[u] += 1;
        }

        if (m != n - 1) {
            cout << 0 << endl;
            return;
        }

        for (int i = 0; i < n; i++) {
            is_leaf[i] = deg[i] == 1;
        }

        for (int i = 0; i < n; i++) {
            for (auto ch : adj[i]) {
                leaf[i] += is_leaf[ch];
                non_leaf[i] += !is_leaf[ch];
            }
        }

        ll ans = 1;
        for (int i = 0; i < n; i++) {
            if (non_leaf[i] > 2) {
                cout << 0 << endl;
                return;
            }
            ans = mul(ans, fact[leaf[i]]);
        }

        int cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += !is_leaf[i];
        }

        if (cnt >= 2) {
            ans = mul(ans, 2) % mod;
        }

        cout << mul(ans, 2) % mod << endl;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

   	// file IO
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
    init();
    int tt = 1;
    cin >> tt;
    while (tt--) {
        test().solve();
    }
}

I couldn't figure out where I messed up on D

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

Successful hacks in A are not put in to main test? There are 6 successful hacks in A during contest but no fst!

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

    Hacks were added to the main tests before system testing. This problem has ~10 tests now.

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

      I filtered the submissions with more or equal to 5 test cases and sorted them by judging time in desending order, and it seems only codes that are submitted after contest are tested in 10 test cases. And when I open my own A code which submitted during contest, it only has 4 tests.

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

      I was also wondering why there are so few FSTs when people managed to hack 6 submissions just during the contest time (which highly suggests that many, possibly hundreds or even thousands of solutions will fail with the hacks).

      I think this really requires rejudging the solutions of A... Why is rating already udpated before addressing this issue?

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

Great contest, thanks to the authors!

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

Can my A be judged please? It is still at "pretest passed", and my position in the standings does not include my points on problem A

Hamed_Ghaffari sweetweasel eren__

https://mirror.codeforces.com/contest/2127/submission/332803312

Update: Thanks for the help

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

I love the round! Thanks...

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

deleted

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

I wasted like 1 hour in A and ended up not solving it anyway i guess it happens ???

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

I've found the tree cute in the cutie points problem!

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

The questions are quite interesting, especially question C. Thank you to everyone for their contributions! (Please forgive me for commenting using a translation software. My English is not very good QAQ)

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

Excluding the issues on H, I think the round was pretty nice. Thanks to the authors.

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

Very good round, thanks for brilliant problems

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

Could you give me a +1 in rating after the rollback? Thanks in advance!

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

What the hell was question D my gawd wasn't able to configure it out at all

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

D problem was very good

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

Hello, My handle is 10_Mahen. I received a warning about solution 332893401 coinciding with others. I did not knowingly share my solution publicly, but a friend (handle: madhurdingalwar123) copied it without me understanding that this was against the rules. I now understand that even unintentional leaks are not allowed, and I take responsibility for being careless. This won’t happen again, and I ask that you please consider this as a first-time mistake. Thank you for your understanding.

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

I would like to sincerely apologize for violating the Codeforces rules in Round 2127A. I submitted a solution (ID: 332894758) that was copied from my friend, not fully realizing that this constitutes a serious rules violation, including unintentional sharing. I now understand that Codeforces does not allow any form of code sharing or copying during contests, even between friends.

This was my mistake, and I take full responsibility for it. I assure you it won’t happen again in the future. I’ve read the rules and guidelines at http://mirror.codeforces.com/blog/entry/8790 to make sure I understand them clearly now.

Please accept my apology, and I respectfully request leniency this time as I was unaware of the seriousness of this action. I am committed to fair and honest participation going forward.

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

I(Darsh_01) recieved a mail regarding that my solution of problem 2172B coincides with many others solution but I have not used any third-party apps or shared my code with anyone. I think it is because of those people also thought of the same logic for the problem which is a legitimate case in my opinion. I have not copied my code from anywhere and I give all my contests honestly. If there are any further clarifications needed I am open to give as I have written a genuine code by myself. Thank You

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

I just received the prize from Atto Round. It indeed contained some nice gifts, thank you for that.

However, I have one concern. I was asked by the delivery person to pay a tariff and tax in cash then. Although the amount was small this time (around $2), such payment without any prior notice does not seem appropriate to me. I would appreciate it if future shipment situation is improved.

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

    Yeah, that's something I've ran into with prizes before as well.

    Problem is the sender can't afford to make sure everything is ok on your end. Import authorities are rather harsh on prizes/gifts — sometimes they demand an extra fee, sometimes a declaration that you really only received it for free and its value is low enough, etc. It depends on the country and on how an import/export officer woke up that day. The sender can try to pay what they understand as correct for your country, but it's imperfect and they're not going to know if everything went ok unless you tell them since communicating with various imports offices is tough and tracking package status doesn't give that much info.

    It's not on the contest organiser. Your import/export office may be at fault, or otherwise it's just that there are too many rules for these things in the world for a tech company to watch out for. Maybe an intermediary company dedicated to sending the prizes correctly could be found... or there was one here and then it's their fault.

    What are the import rules for material prizes in Japan? They're not free under a certain value limit?

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

      Then I'm so lucky that I haven't ran into this kind of issues for $$$\ge15$$$ years.

      Thanks for the explanation, sounds true. I even heard that the payment differed for another recipient this time. I don't think these issues are common sense and the "without any prior notice" part in my comment still makes sense.

      What are the import rules for material prizes in Japan? They're not free under a certain value limit?

      I can't say for sure as I'm not a law expert (and Japanese official site for this seems down for some time now...), but my understanding is that there is a tax exempt for <=10000JPY in this case. I received much valuable prize without an issue recently.