#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()]);
}
}
}
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();
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]));
for (j = 0; j < n; j++) {
ans.clear();
f(j);
if (ans.size() == 2) {
if (i == n - 2) Answer(ans[0], ans[1], flip(ans[0], ans[1]));
else Answer(ans[0], ans[1], j);
break;
}
}
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:54:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 1; j < a.size(); j++) {
~~^~~~~~~~~~
memory2.cpp:67:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < a.size(); j++) {
~~^~~~~~~~~~
memory2.cpp:71:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < t.size(); j++) a.push_back(t[j]);
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
380 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
248 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Incorrect |
6 ms |
376 KB |
Wrong Answer[3] |
4 |
Halted |
0 ms |
0 KB |
- |