이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
const ll inf = 1e18;
const int i_inf = 1e9;
const ll mod = 1e9+7;
const int mxn = 505;
#include "coprobber.h"
int n;
vector<int> g[mxn];
vector<int> gc[mxn];
int nxt[mxn][mxn];
int cnt[mxn][mxn];
bool vis[mxn][mxn];
int cop;
int start(int N, bool A[MAX_N][MAX_N])
{
n = N;
fr(i, 0, n){
gc[i].pb(i);
fr(j, 0, n){
if(A[i][j]){
g[i].pb(j);
gc[i].pb(j);
}
}
}
fr(i, 0, n) vis[i][i] = true;
fr(i, 0, n) nxt[i][i] = i;
queue<pii> Q;
fr(i, 0, n){
fr(j, 0, n){
if(A[i][j]){
nxt[i][j] = j;
vis[i][j] = true;
Q.push({i, j});
}
}
}
while(!Q.empty()){
int u = Q.front().st;
int v = Q.front().nd;
Q.pop();
for(auto e1 : g[v]){
cnt[u][e1] ++;
if(cnt[u][e1] == (int)g[e1].size()){
for(auto e2 : gc[u]){
if(!vis[e2][e1]){
vis[e2][e1] = true;
nxt[e2][e1] = u;
Q.push({e2, e1});
}
}
}
}
}
fr(i, 0, n){
bool cand = true;
fr(j, 0, n){
cand &= vis[i][j];
}
if(cand){
cop = i;
return i;
}
}
return -1;
}
int nextMove(int R)
{
cop = nxt[cop][R];
return cop;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |