Submission #775831

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

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

void add(int x, int y){
    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 = N;
    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<=n;i++) rans.push_back(ans[i]);
    answer(rans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -