제출 #628846

#제출 시각아이디문제언어결과실행 시간메모리
628846c28dnv9q3죄수들의 도전 (IOI22_prison)C++17
56 / 100
16 ms1160 KiB
#include "prison.h" #include <vector> #include <cstdio> using namespace std; struct State { int bitn; int isset; }; int N; int encode(State s) { int v = (s.bitn << 1) | (s.isset << 0); // printf("%d %d\n", s.bitn, v); return v; } State decode(int v) { State s; s.isset = (v >> 0) & 1; s.bitn = v >> 1; return s; } vector<vector<int>> devise_strategy(int N) { ::N = N; int Q = 26; vector<vector<int>> s(Q+1, vector<int>(N+1)); s[0][0] = 0; // inspect bag A for (int i = 1; i <= N; i++) { State p{}; p.bitn = 12; p.isset = (i & (1 << p.bitn)) ? 1 : 0; s[0][i] = encode(p); } for (int i = 1; i < s.size(); i++) { // when sees i on board State pi = decode(i); int t = 1-(pi.bitn&1); s[i][0] = t; // inspect bag A/B for (int j = 1; j <= N; j++) { // j in bag A/B bool b = j & (1 << pi.bitn); if (b && !pi.isset) { s[i][j] = t ? -1 : -2; // other has less } else if (!b && pi.isset) { s[i][j] = t ? -2 : -1; // this has less } else if (pi.bitn == 0) { s[i][j] = -1; // shouldn't happen } else { State p; p.bitn = pi.bitn - 1; p.isset = (j & (1 << p.bitn)) ? 1 : 0; s[i][j] = encode(p); if (s[i][j] == 0) { s[i][j] = t ? -2 : -1; // this has less } } } } return s; }

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

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int i = 1; i < s.size(); i++) {
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...