이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |