Submission #668908

# Submission time Handle Problem Language Result Execution time Memory
668908 2022-12-05T07:28:30 Z mychecksedad The Collection Game (BOI21_swaps) C++17
0 / 100
4 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int M = 505;

void schedule(int, int);

vector<int> visit();

void answer(std::vector<int>);

int n;
bitset<M> is[M];
vector<bool> used(n+1);
pair<int, int> c[M];

int find_next(int i){
    for(int j = 1; j <= n; ++j){
        if(i!=j && !is[i][j] && !used[j]){
            is[i][j] = 1;
            is[j][i] = 1;
            return j;
        }
    }
    return -1;
}

void solve(int NN, int V){
    n = NN;
    if(n%2==0){
        for(int i = 1; i <= n; ++i) c[i] = {0, i};
        bool ok = 1;
        for(int i = 1; ok; ++i){
            used.clear();
            used.resize(n+1);
            vector<array<int, 2>> v;
            ok = 0;
            for(int j = 1; j <= n; ++j){
                if(!used[j]){
                    int nxt = find_next(j);
                    if(nxt==-1){
                        continue;
                    }
                    ok = 1;
                    used[nxt] = used[j] = 1;
                    schedule(j, nxt);
                    v.pb({j, nxt});
                }
            }
            if(!ok) break;
            vector<int> ans = visit();
            for(int i = 0; i < n/2; ++i){
                c[v[i][!ans[i]]].first++;
            }
        }
    }else{
        for(int i = 1; i <= n; ++i) c[i] = {0, i};
        bool ok = 1;
        for(int i = 1; ok; ++i){
            used.clear();
            used.resize(n+1);
            vector<array<int, 2>> v;
            ok = 0;
            for(int j = 1; j <= n - 1; ++j){
                if(!used[j]){
                    int nxt = find_next(j);
                    if(nxt == -1) continue;
                    ok = 1;
                    used[nxt] = used[j] = 1;
                    schedule(j, nxt);
                    v.pb({j, nxt});
                }
            }
            if(!ok) break;
            vector<int> ans = visit();
            for(int i = 0; i < n/2; ++i){
                c[v[i][!ans[i]]].first++;
            }
        }
        for(int i = 1; i < n; ++i){
            schedule(i, n);
            vector<int> ans = visit();
            ans[0] ? c[i].first++ : c[n].first++;
        }
    }



    sort(c + 1, c + 1 + n);
    vector<int> a;
    for(int i = n; i >= 1; --i) a.pb(c[i].second);
    answer(a);
}
# 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 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 300 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 300 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 4 ms 208 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 3 ms 336 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Incorrect 3 ms 336 KB Not correct
3 Halted 0 ms 0 KB -