제출 #828560

#제출 시각아이디문제언어결과실행 시간메모리
828560Amylopectin죄수들의 도전 (IOI22_prison)C++17
100 / 100
9 ms1424 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] = 10; thr[3] = 22; for(i=4; 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<16; 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 { if(i>=13) { fn = j % 22; if(fn == 0) { fa.push_back(-2); } else if(fn == 21) { fa.push_back(-1); } else { fa.push_back(16+((fn-1)/10)); } } 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(0); cm = i; for(j=1; j<=n; j++) { cn = (j % 22); if(cn == 0) { fa.push_back(-1); } else if(cn == 21) { fa.push_back(-2); } else { cn = (cn-1) / 10; if(cn < cm) { fa.push_back(-1); } else if(cn > cm) { fa.push_back(-2); } else { fn = ((j%22) - 1) % 10; // fn = (j % thr[1]) / thr[0]; if(fn == 0) { fa.push_back(-1); } else if(fn == 9) { fa.push_back(-2); } else { fa.push_back(18 + ((fn-1) / 4)); } } } } 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 % 22); if(cn == 0 || cn == 1 || cn == 11) { fa.push_back(-2); } else if(cn == 21 || cn == 10 || cn == 20) { fa.push_back(-1); } else { cn = (((cn-1) % 10)-1) / 4; if(cn < cm) { fa.push_back(-2); } else if(cn > cm) { fa.push_back(-1); } else { fn = ((((j%22) - 1) % 10)-1) % 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(20); } } } } ans.push_back(fa); } fa.clear(); fa.push_back(0); for(j=1; j<=n; j++) { if(((((j%22) - 1) % 10)-1) % 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...