제출 #625498

#제출 시각아이디문제언어결과실행 시간메모리
625498jeroenodb죄수들의 도전 (IOI22_prison)C++17
0 / 100
1 ms212 KiB
#include "prison.h" #include <array> #include <vector> using namespace std; const int D = 7; std::vector<std::vector<int>> devise_strategy(int N) { array<int,D> dig = {2,2,2,5,5,5,5}; array<int,D> pw = {1}; for(int i=1;i<D;++i) pw[i]=pw[i-1]*dig[i-1]; auto extractDig = [&](int n, int i) { n/=pw[i]; return n%dig[i]; }; auto endResult = [&](int dif) { if(dif<=0) return -2; else return -1; }; vector<vector<int>> res; for(int i=D-1;i>=1;--i) { if(pw[i]>=N) continue; int at = res.size(); // before vector<int> cur(N+1); for(int a=0;a<N;++a) { cur[a+1] = at+1+extractDig(a,i); } res.push_back(cur); for(int d=0;d<dig[i];++d) { cur[0]=1; for(int b=0;b<N;++b) { if(extractDig(b,i)!=d) { cur[b+1] = endResult(extractDig(b,i)-d); } else if(i==1) { cur[b+1] = endResult(b&1); } else { cur[b+1] = at+dig[i]+1; } } res.push_back(cur); } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...