제출 #199609

#제출 시각아이디문제언어결과실행 시간메모리
199609abra_stoneMemory 2 (JOI16_memory2)C++14
60 / 100
6 ms380 KiB
#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); while (a.size() >= 4) { 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) { Answer(ans[0], ans[1], flip(ans[0], ans[1])); // 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; }

컴파일 시 표준 에러 (stderr) 메시지

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:68:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j = 0; j < a.size(); j++) {
               ~~^~~~~~~~~~
memory2.cpp:72: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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...