제출 #828310

#제출 시각아이디문제언어결과실행 시간메모리
828310Amylopectin죄수들의 도전 (IOI22_prison)C++17
90 / 100
12 ms1500 KiB
#include "prison.h" #include <stdio.h> #include <iostream> #include <vector> #include <algorithm> using namespace std; const int mxn = 1e5 + 10; int thr[mxn] = {}; vector<int> fa; vector<vector<int> > ans; std::vector<std::vector<int>> devise_strategy(int n) { int i,j,cn,cm,fn,fm,cou = 7; thr[0] = 1; thr[1] = 4; thr[2] = 8; for(i=3; i<10; i++) { thr[i] = thr[i-1] * 3; } cou = 7; fa.push_back(0); for(i=1; i<=n; i++) { fa.push_back(1+(i/thr[cou])); } ans.push_back(fa); cou = 8; for(i=1; i<19; i++) { fa.clear(); if(i%3 == 1) { cou --; } cm = (i-1) % 3; if(((i-1)/3) % 2 == 0) { fa.push_back(1); for(j=1; j<=n; j++) { cn = (j % thr[cou+1]) / thr[cou]; if(cn < cm) { fa.push_back(-2); } else if(cn > cm) { fa.push_back(-1); } else { fn = (j % thr[cou]) / thr[cou-1]; fa.push_back(i-cm + 3 + fn); } } } else { fa.push_back(0); // if(i>15) // { // for(j=1; j<=n; j++) // { // cn = (j % thr[cou+1]) / thr[cou]; // if(cn < cm) // { // fa.push_back(-1); // } // else if(cn > cm) // { // fa.push_back(-2); // } // else // { // fn = (j % thr[cou]) / 4; // fa.push_back(i-cm + 3 + fn); // } // } // } // else { for(j=1; j<=n; j++) { cn = (j % thr[cou+1]) / thr[cou]; if(cn < cm) { fa.push_back(-1); } else if(cn > cm) { fa.push_back(-2); } else { fn = (j % thr[cou]) / thr[cou-1]; fa.push_back(i-cm + 3 + fn); } } } } ans.push_back(fa); } for(i=0; i<2; i++) { fa.clear(); fa.push_back(1); cm = i; for(j=1; j<=n; j++) { cn = (j % thr[2]) / thr[1]; if(cn < cm) { fa.push_back(-2); } else if(cn > cm) { fa.push_back(-1); } else { fn = j%4; // fn = (j % thr[1]) / thr[0]; if(fn == 0) { fa.push_back(-2); } else if(fn == 3) { fa.push_back(-1); } else { fa.push_back(21); } } } ans.push_back(fa); } fa.clear(); fa.push_back(0); for(j=1; j<=n; j++) { if(j%4 <= 1) { fa.push_back(-1); } else { fa.push_back(-2); } } ans.push_back(fa); return {ans}; }

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

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:13:20: warning: unused variable 'fm' [-Wunused-variable]
   13 |   int i,j,cn,cm,fn,fm,cou = 7;
      |                    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...