제출 #643685

#제출 시각아이디문제언어결과실행 시간메모리
643685blue죄수들의 도전 (IOI22_prison)C++17
56 / 100
12 ms1136 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; using vpii = vector<pii>; using vvpii = vector<vpii>; #define sz(x) int(x.size()) const int lg = 13; vvi devise_strategy(int N) { vvi s(2*lg+1, vi(1+N, -1)); s[0][0] = 0; for(int i = 1; i <= N; i++) { s[0][i] = 1 + bool(i & (1<<(lg-1))); } for(int p = 0; p < lg; p++) { int b = lg-1 - p; if(p % 2 == 0) //even bit, check B { s[2*p + 1][0] = 1; s[2*p + 2][0] = 1; for(int i = 1; i <= N; i++) { if(i & (1<<b)) { s[2*p + 1][i] = -1; s[2*p + 2][i] = 2*(p+1) + 1 + (b >= 1 ? bool(i & (1<<(b-1))) : 0); } else { s[2*p + 1][i] = 2*(p+1) + 1 + (b >= 1 ? bool(i & (1<<(b-1))) : 0); s[2*p + 2][i] = -2; } } } else //odd bit, check A { s[2*p + 1][0] = 0; s[2*p + 2][0] = 0; for(int i = 1; i <= N; i++) { if(i & (1<<b)) { s[2*p + 1][i] = -2; s[2*p + 2][i] = 2*(p+1) + 1 + (b >= 1 ? bool(i & (1<<(b-1))) : 0); } else { s[2*p + 1][i] = 2*(p+1) + 1 + (b >= 1 ? bool(i & (1<<(b-1))) : 0); s[2*p + 2][i] = -1; } } } } int x = sz(s) - 1; for(int i = 0; i < sz(s); i++) for(int j = 0; j <= N; j++) if(s[i][j] > x) s[i][j] = -1; // for(int i = 0; i <= x; i++) // { // for(int j = 0; j <= N; j++) // { // cerr << i << ' ' << j << " : " << s[i][j] << '\n'; // } // } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...