atcoder_official's blog

By atcoder_official, history, 4 months ago, In English

We will hold UNIQUE VISION Programming Contest 2025 Christmas (AtCoder Beginner Contest 437).

We are looking forward to your participation!

  • Vote: I like it
  • +70
  • Vote: I do not like it

»
4 months ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

2 years later we can have abc on Christmas Day.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I wish i could solve 6 problems

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    The most of players solve 6 problems, but there are only few players solve G.

»
4 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Wow, good luck everyone

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope there'll be some interesting problems and a clear discussing environment.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

It's more silent than last time.That's good news.

»
4 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

Hope I can solve E

»
4 months ago, hide # |
 
Vote: I like it -16 Vote: I do not like it

有人么

»
4 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

I hope I do good this time. Good luck everyone!

»
4 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Why the comments is few?(Is there any Chinese person here?).

»
4 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Easy D.Hard C.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

all problems except G are easy. problemsetters have become too lazy. can't even put an intermediate problem on F

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Many people cleared the early problems at warp speed. I was two blocks behind just reading—anyway, good match, and Merry Christmas!

»
4 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

Typing competition to F

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    In the editorial its mentioned...

    This is a widely known trick when considering Manhattan distance: we can regard that we rotated the plane by 45 degrees.

    I don't know about it, and I want to know it in detail, want to solve more question related to it. Can you please share ?

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I am able to understand the editorial. I think, I can solve the problem without rotating plane...

      I seem to grasp the concept of the "Rotate the plane by 45 degree" . but why ? what are we accomplishing from that ?

      • »
        »
        »
        »
        4 months ago, hide # ^ |
         
        Vote: I like it +4 Vote: I do not like it

        That "tip" is (for this exercise) straight up useless. The exercise is solvable by noticing that the maximum manhattan distance can be written as the max of 4 expressions, each one computable with a single segment tree query. No need to understand plane rotations or anything.

        • »
          »
          »
          »
          »
          4 months ago, hide # ^ |
          Rev. 2  
          Vote: I like it +1 Vote: I do not like it

          yeah, abs(x1 - x2) + abs(y1 - y2) can be one of those 4:

          (x - x2) + (y - y2)

          (- x + x2) + (y - y2)

          (x - x2) + (- y + y2)

          (- x + x2) + (- y + y2)

          You can save most useful pairs for all those 4 cases if you seperate them as (x + y) + (- x2 - y2) etc. At the end you just need to find max of those 4 for the given (x, y).

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      You can read about it from here: cp-algorithms

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Great problem. Merry Christmas!

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E was a beautiful implementation problem but how tf does it have so many solves? It surely wasn't that easy to implement

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Hey I tried to do a conventional dfs by considering the thing as a graph, but I got WA. I don't see what could go wrong, it passed half the test cases.

    Could you help?

    #include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    
    using ld = long double;
    #define int long long int
    using vi = vector<int>;
    using vpii = vector<pair<int,int>>;
    using vvi = vector<vi>;
    
    #define pb push_back
    #define sz(x) (int)(x).size()
    #define loop(i, a, b) for(int i = a; i < b; i++)
    #define rloop(i, a, b) for(int i = b-1; i >= a; i--)
    #define F first
    #define S second
    #define print(...) print_helper(__VA_ARGS__)
    #define sum_(v) accumulate((v).begin(), (v).end(), 0LL)
    #define min(a, b) find_min(a, b)
    #define max(a, b) find_max(a, b)
    
    #define unordered_map gp_hash_table
    #define unordered_set gp_hash_table
    
    template<typename T>
    void print_helper(T t) { cout << t << "\n"; }
    
    template<typename T, typename... Args>
    void print_helper(T t, Args... args) {
        cout << t << " ";
        print_helper(args...);
    }
    
    int find_min(int a, int b) { return (a < b) ? a : b; }
    int find_max(int a, int b) { return (a > b) ? a : b; }
    
    void dfs(int source,vi &visited,vector<vector<pair<int,int>>> &nbrs,vi &result){
        visited[source]=1;
        int i=0;
        while(i<sz(nbrs[source])){
            int j=i;
            int y=nbrs[source][i].F;
            while(j<sz(nbrs[source]) && nbrs[source][j].F==y){
                int nbr=nbrs[source][j].S;
                if(!visited[nbr]){
                    result.pb(nbr);
                }
                j++;
            }
            for(int k=i;k<j;k++){
                int nbr=nbrs[source][k].S;
                if(!visited[nbr]){
                    dfs(nbr,visited,nbrs,result);
                }
            }
            i=j;
        }
    }
    
    
    signed main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
    
        #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
    
        int n;
        cin >> n;
        vector<vector<pair<int, int>>> edges(n+1);
        vi result;
        loop(i,0,n){
            int x, y;
            cin >> x >> y;
            edges[x].pb({y, i+1});
        }
        loop(i,0,n+1)
        sort(edges[i].begin(),edges[i].end());
        vi visited(n+1, 0);
        dfs(0, visited, edges, result);
        for(int x : result) cout << x << " ";
        cout << endl;
        return 0;
    }
    
»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could anyone give me a hint about problem E?

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

what was that 1 failing case on F ? anybody know ?

  • »
    »
    4 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    weird... but true... I use that basic recursive segtree and long long for most part, I stress test too with the accepted solution of participant to find bug, but couldn't find anything!!!!!! that make mine gave wa(bug in code)... 😭 so I will have to forever live not knowing why and have to always paranoid that 💀 my segment tree implementation was maybe wrong & actually bug all along and could fuck me up at some other random time like this 🥀🥀, maybe.. maybe not, I will never know why its bug..., this is truly a curse, I think I'm gonna have PTSD now every time I use it...

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it
»
4 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

In problem E, is it guaranteed that x_i would not reference to the seqeunce that was yet built during the input(i.e is input ordered)? I was sensing trie, but could not implement on time.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Regarding ABC G, is it possible to combine DP with divide and conquer?

Approach: In the DP part, use 8 states to represent the possible states in which this subtree can be disconnected from its parent node (the root of the subtree). For each node, evaluate the states of its child nodes to make a judgment.

In the divide-and-conquer part, recursively process from the root down to the child nodes. For a parent node, determine the disconnection state for each subtree by adding constraints, and split the subtree internally as well as the subtree from its parent based on these constraints.

Is this approach feasible?

Translate by deepseek.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I checked the submission records for problem G. Some of them contained heavily commented code that aligns with my approach, but the implementation, as I expected, was extremely complex. I don't think I could have completed them during the contest.

    However, those participants using AI have confirmed that my approach is correct.

    Translate by deepseek.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I don't know why the time complexity of F is O(n*logn), not O(n*logn^2) In other words, can the segment tree store only one number as information? It's supposed to be a whole set, and it carries a log

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    There's no need for any set. Four segment trees are enough.

    Build the 4 segment trees (s1, s2, s3, s4) such that

    s1[i] = +x+y

    s2[i] = +x-y

    s3[i] = -x+y

    s4[i] = -x-y

    And then you can compute the queries by querying minimum on [L, R] over all segment trees.

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      I got you. I was stupid then.

      I thought that when deleting a point, the seg-tree can't get the max when only storing one value. Only a deletable-priority-queue/set can handle that.

      however, only one point will be changed one time, and the seg-tree can push_up...

      As a result, I set up eight priority-queues(four are for deleting) at every node of the seg-tree.

      Thank you very much.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

According to the solution of question G, two points with edges can be matched 6 times. Why does this not lead to bugs

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good contest. I solved A-F

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think E is not easy enough for 1954(2%) of the competitors to solve....I believe 1/3 of them are GPTers.

And how E in a human view?

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How can we think to solve the D type question? Any hint would be really helpful !

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone help with why my solution to D fails :

int n, m; cin >> n >> m;
	vector<ll> a(n), b(m);
	vinp(n, a); vinp(m, b);

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	/*
	think of how many times to add a and b
	and how many times to subtract them
	for a[i], it will be added as many times as numbers smaller than it in b
	and subtracted for the remaining times

	I don't get what is wrong here
	*/

	ll res = 0;
	for(int i = 0; i < n; i++) {
		int idx = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
		res -= a[i] * (ll)(m - idx);
		res %= mod;

		idx = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		res += a[i] * (ll)(idx);
		res %= mod;
	}

	for(int i = 0; i < m; i++) {
		int idx = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
		res -= b[i] * (ll)(n - idx);
		res %= mod;

		idx = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		res += b[i] * (ll)(idx);
		res %= mod;
	}

	cout << res;