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

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

We will hold AtCoder Regular Contest 207 (Div.1).

The point values will be 800-800-800-800-800.

Please note that the rules against generative AI were updated on October 3, 2025. Please make sure to read this post and the rules.

We are looking forward to your participation!

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

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

contest duration: 2025-10-05(Sun) 20:00 — 2025-10-05(Sun) 22:30 (local time) (150 minutes)

but meanwhile, down here:

duration: 120 minutes

so what's the true duration.

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

Interesting score distribution.

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

Why (Do you live in Japan?* -> No) still need Date of birth* ?

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

AtCoder's point values sum (×)

Another ACM-ICPC mode (√)

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

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

That one guy who has the best strat to get most points: WHY IS EVERYTHING 800 >-<

I am the opposite of that one guy :)

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

horrible 800

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

When you want to decide your order of solving problems: 800-800-800-800-800

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

Yet another ICPC round.

ICPC * 800.

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

Welp I failed. Gj to those who even did 1 Q

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

For D, a better way of thinking is to observe that, assume $$$n$$$ is odd, then the winner of the medium row always wins the whole game. In this way, one can naively write a simple dp to calculate the result of the medium row without any further thinking needed.

upd: this solution is not correct, we should keep the medium $$$3$$$ rows and do the dp.

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

    On this test:

    3 2
    11
    00
    11
    

    Second wins on the medium row. However, if First starts by eating a column, they can repeat whatever Second does after, and win the game.

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

      Oh sorry, the 1 column case should take $$$3$$$ rows into consideration. We should keep the medium $$$3$$$ rows instead of $$$1$$$.

      Actually I proved the $$$3$$$ row case in contest and implemented it. I naively thought this could be brought to the $$$1$$$ row case as well, but it seems not.

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

I reduced Problem A to the following task:

Let $$$w=\sum a - X$$$. Count the number of permutations $$$p$$$ of length $$$n$$$ such that $$$\sum \min(a_i,p_i-1)\ge w$$$.

Clearly $$$w \lt n^2$$$. Since we are counting permutations, this can be converted into counting matchings in a bipartite graph between $$${a_1,a_2,\dots,a_n}$$$ and $$${0,1,2,\dots,n-1}$$$. So I place these $$$2n$$$ numbers together, sort them in nonincreasing order, and decide them one by one. I design a DP state $$$f_{i,j,k,l}$$$ meaning that after processing the first $$$i$$$ elements, there are $$$j$$$ unmatched $$$a_i$$$-type elements and $$$k$$$ unmatched index-type elements; the transitions are:

if (a[i].second == 0) {
    // it means it comes from a[i]
    
    if (k) Add(g[j][k - 1][l + a[i].first], mul(f[j][k][l], k));  // match with an index (p_i-1)
    Add(g[j + 1][k][l], f[j][k][l]); // leave this a[i] unmatched
} else {
    // it means it comes from an index (value i-1)

    if (j) Add(g[j - 1][k][l + a[i].first], mul(f[j][k][l], j));  // match with an a (a_i)
    Add(g[j][k + 1][l], f[j][k][l]); // leave this index unmatched
}

This is $$$O(n^5)$$$. However, if I record which DP states are nonzero and only perform transitions from those states, it surprisingly passes.

Does anyone know why that is? Thanks.

Submission record: https://atcoder.jp/contests/arc207/submissions/69911719

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

How I solved D...

I got stucked on C and went to D.

I remembered that in the 1D version we only need to look at the (at most) $$$3$$$ characters in the middle.

Then I guessed that we also can just look at the central $$$3\times 3$$$ area in the original problem.

I submitted that algorithm but got WA.

I was disappointed. I thought my algorithm was completely wrong and hopelessly changed the area to $$$4\times 4$$$ then submitted it again.

...Then I got Accepted!

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

    I solved D in the same way.

    I knew the condition is related to the central grids, and I just took a central rectangle(the size was big enough, like $$$16 \times 16$$$) and run brute force and passed.

    So can anyone prove what size of rectangle is enough?

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

      When $$$n$$$ is even, keep the middle $$$4$$$ rows; when $$$n$$$ is odd, keep the middle $$$3$$$ rows ($$$m$$$ is same). This should be the minimal rectangle.

      According to the official editorial, when exactly one of $$$n$$$ and $$$m$$$ is odd, the answer depends only on the central $$$2\times 3$$$ rectangle.

      When both $$$n$$$ and $$$m$$$ are odd, if the center cell is 0 or the three middle cells are 010, then the second player wins. That means that answer is related to the cross in the middle, which is a central $$$3 \times 3$$$ rectangle; otherwise, by shrinking from one of the four directions to reach a situation where only one side length is odd, one finds that the central $$$2\times 3$$$ rectangle after shrinking corresponds to a contiguous subrectangle of the original central $$$3\times 3$$$ rectangle.

      When both $$$n$$$ and $$$m$$$ are even, we shrink from one of the four directions to obtain a one odd one even case; in that case the central $$$3\times 3$$$ rectangle after shrinking corresponds to a contiguous subrectangle of the original central $$$4\times 4$$$ rectangle.

      Therefore, keeping the middle 4 rows when $$$n$$$ is even and the middle 3 rows when $$$n$$$ is odd is sufficient for this problem.

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

I wrote a strange solution for C and it got AC.Can anybody tell me why the probability of WA is sufficiently low?

Here is the code:

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

For Problem C, I have a solution with a superior time complexity of O(n log V), where V represents the value range, which is more efficient than the one provided in the Editorial. For details, please refer to: https://atcoder.jp/contests/arc207/submissions/69905415

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

In problem B, I wrote a brute-force to get an answer from 2 to 8. And I find it can be solved by bipartite graph.

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

It could be less rating critera

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

In problem C, I used a very simple approach: let $$$f_i$$$ denote the length of the longest non-decreasing subsequence ending at $$$i$$$, and $$$g_i$$$ denote the minimum value of the last segment in such a subsequence. Then, I performed direct transitions using binary search. This solution passed all test cases, and I want to ask about the correctness of this approach.

Code

#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb emplace_back
#define ll long long
#define all(b) b.begin(),b.end()
using namespace std;
const int N=2e5+10;
int n,f[N],g[N],a[N],cnt[31][N];
int l1[N],r1[N];
void ck(int i,int w,int d)
{
    if(w>f[i]) f[i]=w,g[i]=d;
    else if(w>=f[i]&&d<g[i]) g[i]=d;
}
void init(int x,int w)
{
    for(int i=0;i<30;i++) cnt[i][x]+=(w>>i&1);
}
inline int calc(int l,int r)
{
    int ans=0;
    for(int i=0;i<30;i++) if(cnt[i][r]-cnt[i][l-1]) ans+=(1<<i);
    return ans;
}
bool check(int i,int x)
{
    int l=l1[x],r=r1[x],ans=-1;
    while(l<=r)
    {
        int mid=l+r>>1;
        if(calc(mid+1,i)>=g[mid]) ans=mid,l=mid+1;
        else r=mid-1;
    }
    if(ans==-1) return 0;
    ck(i,f[ans]+1,calc(ans+1,i));
    return 1;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],init(i,a[i]);
    for(int i=0;i<30;i++) for(int j=1;j<=n;j++) cnt[i][j]+=cnt[i][j-1];
    for(int i=1;i<=n;i++)
    {
        ck(i,f[i-1],a[i]|g[i-1]);
        if(!check(i,f[i-1])) check(i,f[i-1]-1);
        if(f[i]==f[i-1]) r1[f[i]]=i;
        else l1[f[i]]=r1[f[i]]=i;
    }
    cout<<f[n];
    return 0;
}