제출 #1080105

#제출 시각아이디문제언어결과실행 시간메모리
1080105Gray죄수들의 도전 (IOI22_prison)C++17
65 / 100
18 ms1200 KiB
#include "prison.h" #include <vector> #include <bits/stdc++.h> #define ll int #define ln "\n" using namespace std; ll code(ll x, ll i){ string s = ""; while (x){ s+=to_string(x%3); x/=3; } while (s.length()<8) s+='0'; reverse(s.begin(), s.end()); return s[i]-'0'; } std::vector<std::vector<int>> devise_strategy(int N) { vector<vector<ll>> ans(25, vector<ll>(N+1)); for (ll i=1; i<=N; i++){ ll cd=code(i, 0); ans[0][i]=cd*8+1; } for (ll x=1; x<=24; x++){ if (x%2){ ans[x][0]=1; ll pos=(x-1)%8, val=(x-1)/8; for (ll i=1; i<=N; i++){ ll cd = code(i, pos); if (cd>val) ans[x][i]=-1; else if (cd<val) ans[x][i]=-2; else { if (pos+1==8) ans[x][i]=0; else ans[x][i]=code(i, pos+1)*8+pos+2; } } }else{ ans[x][0]=0; ll pos=(x-1)%8, val=(x-1)/8; for (ll i=1; i<=N; i++){ ll cd = code(i, pos); if (cd>val) ans[x][i]=-2; else if (cd<val) ans[x][i]=-1; else { if (pos+1==8) ans[x][i]=0; else ans[x][i]=code(i, pos+1)*8+pos+2; } } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...