#include "Memory2_lib.h"
#include <vector>
using namespace std;
struct asks {
int a, b;
};
vector<asks> mp[50];
void Solve(int T, int n) {
for (int i = 0; i < n; ++i) {
mp[Flip(i << 1, i << 1 | 1)].push_back({ i << 1, i << 1 | 1 });
}
vector<int> two;
for (int i = 0; i < n; ++i) {
if (mp[i].size() == 2) two.push_back(i);
}
while (!two.empty()) {
int t = two.back();
two.pop_back();
asks p = mp[t][0];
asks q = mp[t][1];
int x = Flip(p.a, q.a);
int y = Flip(p.a, q.b);
int z = Flip(p.b, q.a);
int w = Flip(p.b, q.b);
if (x != t) {
Answer(p.b, q.b, t);
mp[x].push_back({ p.a, q.a });
if (mp[x].size() == 2) two.push_back(x);
}
else if (y != t) {
Answer(p.b, q.a, t);
mp[y].push_back({ p.a, q.b });
if (mp[y].size() == 2) two.push_back(y);
}
else if (z != t) {
Answer(p.a, q.b, t);
mp[z].push_back({ p.b, q.a });
if (mp[z].size() == 2) two.push_back(z);
}
else if (w != t) {
Answer(p.a, q.a, t);
mp[w].push_back({ p.b, q.b });
if (mp[w].size() == 2) two.push_back(w);
}
mp[t].clear();
}
for (int i = 0; i < n; ++i) {
if (mp[i].size()) Answer(mp[i][0].a, mp[i][0].b, i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |