제출 #959130

#제출 시각아이디문제언어결과실행 시간메모리
959130berr경찰관과 강도 (BOI14_coprobber)C++17
0 / 100
155 ms262144 KiB
#include <cstdio> #include <utility> #include <bits/stdc++.h> #include "coprobber.h" using namespace std; int pos; map<array<int, 2>, int> mp; int state[500][500][2]; vector<vector<int>> g(500); int calc(int x, int y, int player){ if(x==y&&player==0) return state[x][y][player]=x; else if(x==y)return state[x][y][player]=-1; // if(state[x][y][player]!=-2)return state[x][y][player]; if(player==0){ int c=0; state[x][y][player]=-1; //-1 means holding for(auto i: g[x]){ if(calc(i, y, 1)==-1){ state[x][y][0]=i; c++; } } for(auto i: g[x]){ if(calc(i, y, 1)==-1){ state[x][y][0]=i; c++; } } if(!c) state[x][y][player]=-1; } else{ int c=0; state[x][y][player]=0; for(auto i: g[y]){ if(calc(x, i, 0)==-1){ state[x][y][1]=i; c++; } } for(auto i: g[y]){ if(calc(x, i, 0)==-1){ state[x][y][1]=i; c++; } } if(!c) state[x][y][player]=-1; } return state[x][y][player]; }; int start(int n, bool a[MAX_N][MAX_N]) { for(int i=0; i<n; i++){ for(int l=0; l<n; l++){ state[i][l][0]=-2; state[i][l][1]=-2; if(a[i][l]){ g[i].push_back(l); } } } for(int i=0; i<n; i++){ int flag=1; for(int l=0; l<n; l++){ if(calc(i, l, 1)!=-1){ flag=0; } } if(flag) return pos=i; } return -1; } int nextMove(int R) { return pos = calc(pos, R, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...