제출 #56700

#제출 시각아이디문제언어결과실행 시간메모리
56700top34051Memory 2 (JOI16_memory2)C++17
0 / 100
3 ms720 KiB
#include "Memory2_lib.h"
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e3 + 5;

int bad[maxn];
vector<int> pos[maxn];

void Solve(int T, int N) {
    int x = 0;
    while(1) {
        int ok = 0;
        for(int y=x+1;y<2*N;y++) {
            if(bad[y]) continue;
            int tmp = Flip(x,y);
            pos[tmp].push_back(y);
            if(pos[tmp].size()==3) {
                x = pos[tmp][0];
                for(int i=0;i<N;i++) {
                    if(i==tmp) continue;
                    for(auto t : pos[i]) bad[t] = 1;
                }
                for(int i=0;i<N;i++) pos[i].clear();
                ok = 1;
                break;
            }
        }
        if(!ok) break;
    }
    for(int i=0;i<2*N;i++) {
        if(i!=x) pos[Flip(i,x)].push_back(i);
        else pos[N-1].push_back(i);
    }
    for(int i=0;i<N;i++) Answer(pos[i][0],pos[i][1],i);
    return ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...