Submission #894609

# Submission time Handle Problem Language Result Execution time Memory
894609 2023-12-28T14:21:57 Z esomer The Collection Game (BOI21_swaps) C++17
35 / 100
37 ms 1684 KB
#include <bits/stdc++.h>
#include "swaps.h"

using namespace std;

mt19937 gen(time(0));

void add(vector<int>& a, vector<pair<vector<int>, vector<int>>>& all){
    int n = (int)a.size();
    int sz = (n + 1) / 2;
    shuffle(a.begin(), a.end(), gen);
    all.push_back({{}, {}});
    for(int i = 0; i < sz; i++) all.back().first.push_back(a[i]);
    for(int i = sz; i < n; i++) all.back().second.push_back(a[i]);
}

void solve(int N, int V) {
    vector<pair<vector<int>, vector<int>>> all;
    int sz = (N+1) / 2;
    vector<int> a(N);
    for(int i = 0; i < N; i++) a[i] = i + 1;
    add(a, all);
    bool stop = false;
    while(!stop){
        int mx = 0;
        for(auto p : all){
            mx = max(mx, (int)p.second.size());
        }
        for(int change = 0; change < mx + 1; change++){
            for(auto& p : all){
                for(int i = 0; i < (int)p.second.size(); i++){
                    schedule(p.second[i], p.first[(i + change) % (int)p.first.size()]);
                }
            }
            vector<int> rep = visit();
            int curr = 0;
            for(auto& p : all){
                for(int i = 0; i < (int)p.second.size(); i++){
                    if(rep[curr] == 1) swap(p.second[i], p.first[(i + change) % (int)p.first.size()]);
                    curr++;
                }
            }
        }
        vector<pair<vector<int>, vector<int>>> nw;
        for(auto p : all){
            add(p.first, nw);
            add(p.second, nw);
        }
        all = nw;
        if(sz == 1) stop = true;
        sz = (sz + 1) / 2;
    }
    vector<int> r;
    for(auto p : all){
        for(int x : p.first) r.push_back(x);
        for(int x : p.second) r.push_back(x);
    }
    answer(r);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 460 KB Correct
3 Correct 8 ms 460 KB Correct
4 Correct 31 ms 1428 KB Correct
5 Correct 34 ms 1208 KB Correct
6 Correct 30 ms 752 KB Correct
7 Correct 31 ms 1004 KB Correct
8 Correct 30 ms 952 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 2 ms 460 KB Correct
3 Correct 10 ms 476 KB Correct
4 Correct 33 ms 752 KB Correct
5 Correct 36 ms 924 KB Correct
6 Correct 32 ms 1440 KB Correct
7 Correct 34 ms 948 KB Correct
8 Correct 36 ms 1012 KB Correct
9 Correct 33 ms 932 KB Correct
10 Correct 35 ms 1260 KB Correct
11 Correct 32 ms 1192 KB Correct
12 Correct 32 ms 956 KB Correct
13 Correct 33 ms 932 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
3 Correct 0 ms 344 KB Correct
4 Correct 2 ms 460 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
3 Correct 10 ms 464 KB Correct
4 Correct 34 ms 1184 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
3 Correct 10 ms 464 KB Correct
4 Correct 34 ms 1184 KB Correct
5 Correct 0 ms 344 KB Correct
6 Correct 2 ms 460 KB Correct
7 Correct 9 ms 456 KB Correct
8 Correct 33 ms 940 KB Correct
9 Correct 33 ms 928 KB Correct
10 Correct 34 ms 1264 KB Correct
11 Correct 34 ms 1180 KB Correct
12 Correct 34 ms 1428 KB Correct
13 Correct 0 ms 344 KB Correct
14 Correct 2 ms 444 KB Correct
15 Correct 9 ms 460 KB Correct
16 Correct 37 ms 1444 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 452 KB Correct
3 Correct 12 ms 480 KB Correct
4 Correct 32 ms 1012 KB Correct
5 Runtime error 32 ms 1684 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 452 KB Correct
3 Correct 12 ms 480 KB Correct
4 Correct 32 ms 1012 KB Correct
5 Runtime error 32 ms 1684 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 3 ms 448 KB Correct
3 Correct 10 ms 460 KB Correct
4 Correct 32 ms 1180 KB Correct
5 Runtime error 33 ms 1196 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 3 ms 448 KB Correct
3 Correct 10 ms 460 KB Correct
4 Correct 32 ms 1180 KB Correct
5 Runtime error 33 ms 1196 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
3 Correct 9 ms 484 KB Correct
4 Correct 32 ms 1188 KB Correct
5 Runtime error 35 ms 1208 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 2 ms 444 KB Correct
3 Correct 9 ms 484 KB Correct
4 Correct 32 ms 1188 KB Correct
5 Runtime error 35 ms 1208 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -