#include "Memory2_lib.h"
#include <vector>
#define N 105
using namespace std;
int me[N][N];
vector<int> a, b, t, ans;
int flip(int p, int q) {
if (me[p][q] > -1) return me[p][q];
return me[p][q] = me[q][p] = Flip(p, q);
}
int fcnt(int p, int q) {
int i;
for (i = 0; i < 4; i++) {
if (b[(q + i) % b.size()] != p) return i;
}
return 4;
}
void f(int p) {
int i;
for (i = 0; i < b.size(); i++) {
if (fcnt(p, i) == 4) {
ans.push_back(a[(i + 1) % a.size()]);
ans.push_back(a[(i + 3) % a.size()]);
return;
}
}
for (i = 0; i < b.size(); i++) {
if (fcnt(p, i) == 3) {
ans.push_back(a[(i + 1) % a.size()]);
ans.push_back(a[(i + 2) % a.size()]);
return;
}
}
for (i = 0; i < b.size(); i++) {
if (fcnt(p, i) == 2) {
ans.push_back(a[(i + 1) % a.size()]);
return;
}
}
}
void Solve(int T, int n){
int i, j;
for (i = 0; i < 2 * n; i++) {
for (j = 0; j < 2 * n; j++) me[i][j] = -1;
}
a.clear();
for (i = 0; i < 2 * n; i++) a.push_back(i);
for (i = 0; i < n - 1; i++) {
b.clear(); t.clear(); ans.clear();
for (j = 1; j < a.size(); j++) {
b.push_back(flip(a[j - 1], a[j]));
}
b.push_back(flip(a[0], a[a.size() - 1]));
f(i);
if (i == n - 2) Answer(ans[0], ans[1], flip(ans[0], ans[1]));
else Answer(ans[0], ans[1], i);
for (j = 0; j < a.size(); j++) {
if (a[j] != ans[0] && a[j] != ans[1]) t.push_back(a[j]);
}
a.clear();
for (j = 0; j < t.size(); j++) a.push_back(t[j]);
}
Answer(a[0], a[1], flip(a[0], a[1]));
return;
}
Compilation message
memory2.cpp: In function 'void f(int)':
memory2.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < b.size(); i++) {
~~^~~~~~~~~~
memory2.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < b.size(); i++) {
~~^~~~~~~~~~
memory2.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < b.size(); i++) {
~~^~~~~~~~~~
memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:55:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 1; j < a.size(); j++) {
~~^~~~~~~~~~
memory2.cpp:62:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < a.size(); j++) {
~~^~~~~~~~~~
memory2.cpp:66:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < t.size(); j++) a.push_back(t[j]);
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Wrong Answer[3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Wrong Answer[3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |