#include "Memory2_lib.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <tuple>
#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (105)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
int d[MAXN][MAXN];
int Ans[MAXN];
vector<int> AnsV[MAXN];
vector<int> V;
int BI = -1;
int C[MAXN];
int f(int a, int b) {
if(a > b) swap(a, b);
if(-1 != d[a][b]) return d[a][b];
return d[a][b] = Flip(a, b);
}
void Solve(int T, int N) {
srand(6974);
if(1 == N) { Answer(0, 1, 1); return; }
for(int i = 0; i < MAXN; i++) fill(d[i], d[i]+MAXN, -1);
for(int i = 0; i < 2*N; i++) C[i] = i;
for(int t = 0; t < 3000000; t++) {
int a = 0, b = 0;
while(a == b) {
a = rand()%(2*N);
b = rand()%(2*N);
}
swap(C[a], C[b]);
}
V.pb(C[0]); V.pb(C[1]); V.pb(C[2]);
for(int i = 3; i < 2*N; i++) {
V.pb(C[i]);
for(int j = 0; j < 4; j++) {
vector<int> A;
for(int k = 0; k < 4; k++) {
if(j == k) continue;
A.pb(f(V[j], V[k]));
}
if(A[0] == A[1] && A[1] == A[2]) {
clv(A); for(int k = 0; k < 4; k++) {
if(j == k) continue;
A.pb(V[k]);
}
swap(V, A);
break;
}
}
}
if(f(V[0], V[1]) == f(V[0], V[2])) { BI = V[1]; Ans[BI] = f(V[1], V[2]); }
else if(f(V[0], V[1]) == f(V[1], V[2])) { BI = V[0]; Ans[BI] = f(V[0], V[2]); }
else if(f(V[2], V[0]) == f(V[2], V[1])) { BI = V[0]; Ans[BI] = f(V[0], V[1]); }
for(int i = 2*N-1; ~i; i--) {
if(BI == C[i]) continue;
Ans[C[i]] = f(C[i], BI);
}
for(int i = 0; i < 2*N; i++) AnsV[Ans[i]].pb(i);
for(int i = 0; i < N; i++) Answer(AnsV[i][0], AnsV[i][1], i);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
2076 KB |
Output is correct |
2 |
Correct |
99 ms |
2076 KB |
Output is correct |
3 |
Correct |
93 ms |
2076 KB |
Output is correct |
4 |
Correct |
93 ms |
2076 KB |
Output is correct |
5 |
Correct |
86 ms |
2076 KB |
Output is correct |
6 |
Correct |
83 ms |
2076 KB |
Output is correct |
7 |
Correct |
86 ms |
2076 KB |
Output is correct |
8 |
Correct |
83 ms |
2076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
2076 KB |
Output is correct |
2 |
Correct |
89 ms |
2076 KB |
Output is correct |
3 |
Correct |
79 ms |
2076 KB |
Output is correct |
4 |
Correct |
86 ms |
2076 KB |
Output is correct |
5 |
Correct |
89 ms |
2076 KB |
Output is correct |
6 |
Correct |
86 ms |
2076 KB |
Output is correct |
7 |
Correct |
83 ms |
2076 KB |
Output is correct |
8 |
Correct |
86 ms |
2076 KB |
Output is correct |
9 |
Correct |
106 ms |
2076 KB |
Output is correct |
10 |
Correct |
83 ms |
2076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
2076 KB |
Output is correct |
2 |
Incorrect |
86 ms |
2076 KB |
Wrong Answer[2] |
3 |
Halted |
0 ms |
0 KB |
- |