Submission #775833

# Submission time Handle Problem Language Result Execution time Memory
775833 2023-07-07T04:50:17 Z 박상훈(#9990) The Collection Game (BOI21_swaps) C++17
100 / 100
4 ms 440 KB
#include "swaps.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int n0, ans[1010];
vector<pair<int, int>> E;

void add(int x, int y){
    if (x>n0 || y>n0) return;
    schedule(ans[x], ans[y]);
    E.emplace_back(x, y);
}

void layer(int n){
    auto ret = visit();
    for (int i=0;i<(int)ret.size();i++) if (!ret[i]) swap(ans[E[i].first], ans[E[i].second]);
    E.clear();
}

void solve(int N, int V) {
    int n = 1;
    n0 = N;

    while(n<n0) n *= 2;
    for (int i=1;i<=n;i++) ans[i] = i;

    // for (int z=1;z<=n;z++){
    //     for (int i=2-(z&1);i+1<=n;i+=2){
    //         schedule(ans[i], ans[i+1]);
    //     }

    //     auto ret = visit();
    //     for (int i=2-(z&1),j=0;i+1<=n;i+=2,j++){
    //         if (!ret[j]) swap(ans[i], ans[i+1]);
    //     }
    // }

    for (int z=1;z<n;z*=2){
        for (int len=z;len>=1;len/=2){
            for (int i=1;i<=n;i+=z*2){
                if (len==z){
                    for (int s=0;s<len;s++){
                        add(s+i, s+len+i);
                    }
                }
                else{
                    for (int p=len;p+len*2-1<z*2;p+=len*2){
                        for (int s=0;s<len;s++){
                            add(p+s+i, p+s+i+len);
                        }
                    }
                }
            }

            layer(n);
        }
    }

    vector<int> rans;
    for (int i=1;i<=n0;i++) rans.push_back(ans[i]);
    answer(rans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 320 KB Correct
5 Correct 3 ms 316 KB Correct
6 Correct 3 ms 372 KB Correct
7 Correct 3 ms 316 KB Correct
8 Correct 3 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 3 ms 316 KB Correct
5 Correct 3 ms 324 KB Correct
6 Correct 3 ms 308 KB Correct
7 Correct 3 ms 312 KB Correct
8 Correct 3 ms 328 KB Correct
9 Correct 3 ms 316 KB Correct
10 Correct 4 ms 320 KB Correct
11 Correct 4 ms 316 KB Correct
12 Correct 4 ms 316 KB Correct
13 Correct 3 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 0 ms 208 KB Correct
4 Correct 1 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 304 KB Correct
4 Correct 3 ms 320 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 304 KB Correct
4 Correct 3 ms 320 KB Correct
5 Correct 1 ms 208 KB Correct
6 Correct 1 ms 304 KB Correct
7 Correct 2 ms 308 KB Correct
8 Correct 4 ms 308 KB Correct
9 Correct 4 ms 312 KB Correct
10 Correct 3 ms 316 KB Correct
11 Correct 4 ms 336 KB Correct
12 Correct 4 ms 316 KB Correct
13 Correct 1 ms 208 KB Correct
14 Correct 1 ms 300 KB Correct
15 Correct 2 ms 336 KB Correct
16 Correct 3 ms 320 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 272 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 3 ms 296 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 272 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 3 ms 296 KB Correct
6 Correct 0 ms 208 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 2 ms 208 KB Correct
9 Correct 3 ms 440 KB Correct
10 Correct 3 ms 304 KB Correct
11 Correct 3 ms 312 KB Correct
12 Correct 3 ms 312 KB Correct
13 Correct 3 ms 312 KB Correct
14 Correct 4 ms 308 KB Correct
15 Correct 4 ms 316 KB Correct
16 Correct 3 ms 312 KB Correct
17 Correct 3 ms 320 KB Correct
18 Correct 3 ms 320 KB Correct
19 Correct 1 ms 208 KB Correct
20 Correct 1 ms 208 KB Correct
21 Correct 2 ms 208 KB Correct
22 Correct 3 ms 320 KB Correct
23 Correct 3 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 304 KB Correct
3 Correct 2 ms 312 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 3 ms 276 KB Correct
6 Correct 3 ms 276 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 304 KB Correct
3 Correct 2 ms 312 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 3 ms 276 KB Correct
6 Correct 3 ms 276 KB Correct
7 Correct 0 ms 208 KB Correct
8 Correct 1 ms 208 KB Correct
9 Correct 2 ms 308 KB Correct
10 Correct 3 ms 316 KB Correct
11 Correct 3 ms 308 KB Correct
12 Correct 3 ms 316 KB Correct
13 Correct 3 ms 316 KB Correct
14 Correct 3 ms 316 KB Correct
15 Correct 3 ms 312 KB Correct
16 Correct 4 ms 336 KB Correct
17 Correct 3 ms 312 KB Correct
18 Correct 3 ms 408 KB Correct
19 Correct 3 ms 312 KB Correct
20 Correct 1 ms 208 KB Correct
21 Correct 1 ms 292 KB Correct
22 Correct 2 ms 208 KB Correct
23 Correct 4 ms 324 KB Correct
24 Correct 3 ms 292 KB Correct
25 Correct 3 ms 284 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 316 KB Correct
5 Correct 3 ms 312 KB Correct
6 Correct 4 ms 272 KB Correct
7 Correct 4 ms 288 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 316 KB Correct
5 Correct 3 ms 312 KB Correct
6 Correct 4 ms 272 KB Correct
7 Correct 4 ms 288 KB Correct
8 Correct 0 ms 208 KB Correct
9 Correct 1 ms 208 KB Correct
10 Correct 1 ms 208 KB Correct
11 Correct 2 ms 208 KB Correct
12 Correct 4 ms 308 KB Correct
13 Correct 4 ms 320 KB Correct
14 Correct 3 ms 312 KB Correct
15 Correct 4 ms 320 KB Correct
16 Correct 3 ms 312 KB Correct
17 Correct 3 ms 316 KB Correct
18 Correct 4 ms 312 KB Correct
19 Correct 4 ms 312 KB Correct
20 Correct 3 ms 308 KB Correct
21 Correct 4 ms 320 KB Correct
22 Correct 0 ms 208 KB Correct
23 Correct 1 ms 208 KB Correct
24 Correct 2 ms 208 KB Correct
25 Correct 3 ms 308 KB Correct
26 Correct 4 ms 300 KB Correct
27 Correct 3 ms 292 KB Correct
28 Correct 3 ms 276 KB Correct