Submission #26116

# Submission time Handle Problem Language Result Execution time Memory
26116 2017-06-28T04:56:30 Z kajebiii None (JOI16_memory2) C++14
100 / 100
0 ms 2024 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 55;

vector<pi> Val[MAX_N];
queue<int> Same;
void Solve(int T, int N){
    for(int i=0; i<N; i++) {
        int val = Flip(i*2, i*2+1);
        Val[val].push_back(pi(i*2, i*2+1));
    }
    for(int i=0; i<N; i++)
        if(SZ(Val[i]) == 2) Same.push(i);

    while(!Same.empty()) {
        int v = Same.front(); Same.pop();
        pi a = Val[v][0], b = Val[v][1];
        int aa[2] = {a.one, a.two}, bb[2] = {b.one, b.two};
        for(int i=0; i<2; i++) for(int j=0; j<2; j++) {
            int val = Flip(aa[i], bb[j]);
            if(val != v) {
                Val[val].push_back(pi(aa[i], bb[j]));
                if(SZ(Val[val]) == 2) Same.push(val);
                Answer(aa[1-i], bb[1-j], v);
            }
        }
    }

    for(int i=0; i<N; i++)
        if(SZ(Val[i]) == 1)
            Answer(Val[i][0].one, Val[i][0].two, i);
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
9 Correct 0 ms 2024 KB Output is correct
10 Correct 0 ms 2024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
9 Correct 0 ms 2024 KB Output is correct
10 Correct 0 ms 2024 KB Output is correct