#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
int buff[101][101];
int ans[101];
int ask(int x, int y) {
if (buff[x][y] != -1) return buff[x][y];
return buff[x][y] = buff[y][x] = Flip(x, y);
}
int add(vector<int> &v) {
for (int i = 0; i < 4; i++) {
int cnt = 0;
for (int j = 0; j < 4; j++) {
if (i == j) continue;
cnt += (ask(v[i], v[j]) == ask(v[i], (i == 0 ? v[1] : v[0])));
}
if (cnt == 3) {
ans[v[i]] = ask(v[i], (i == 0 ? v[1] : v[0]));
return i;
}
}
return -1;
}
void Solve(int T, int n){
for (int i = 0; i < 2 * n; i++) {
for (int j = 0; j < 2 * n; j++) {
buff[i][j] = -1;
}
}
vector<int> v = {0, 1, 2, 3};
for (int i = 4; i < 2 * n; i++) {
v[add(v)] = i;
}
int rem = add(v);
vector<int> left;
for (int i = 0; i < 4; i++) {
if (i != rem) left.push_back(v[i]);
}
vector<int> queries;
queries.push_back(ask(left[0], left[1]));
queries.push_back(ask(left[0], left[2]));
queries.push_back(ask(left[1], left[2]));
if (queries[0] == queries[1]) {
ans[left[1]] = ans[left[2]] = queries[2];
ans[left[0]] = queries[0];
} else if (queries[0] == queries[2]) {
ans[left[0]] = ans[left[2]] = queries[1];
ans[left[1]] = queries[0];
} else if (queries[1] == queries[2]) {
ans[left[0]] = ans[left[1]] = queries[0];
ans[left[2]] = queries[1];
}
for (int i = 0; i < n; i++) {
pair<int, int> res = {-1, -1};
for (int j = 0; j < 2 * n; j++) {
if (ans[j] == i) {
if (res.first == -1) res.first = j;
else res.second = j;
}
}
Answer(res.first, res.second, i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
372 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |