Submission #909122

#TimeUsernameProblemLanguageResultExecution timeMemory
909122adhityamvGame (APIO22_game)C++17
0 / 100
1 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pii pair<int,int> #define fi first #define se second vector<vector<int>> edges; vector<vector<int>> redges; vector<int> minreach; vector<int> maxreturn; int n,k; void init(int N,int K){ n=N; k=K; for(int i=0;i<n;i++){ edges.push_back({}); redges.push_back({}); } for(int i=0;i<k;i++){ minreach.push_back(i); maxreturn.push_back(i); } for(int i=k;i<n;i++){ minreach.push_back(k); maxreturn.push_back(-1); } } bool dfs(int u){ bool ans=true; for(int v:edges[u]){ if(maxreturn[v]<maxreturn[u]){ maxreturn[v]=maxreturn[u]; if((maxreturn[v]>minreach[v]) || (maxreturn[v]==minreach[v] && v>=k)) ans=false; if(!dfs(v)) ans=false;; } } return ans; } bool rdfs(int u){ bool ans=true; for(int v:redges[u]){ if(minreach[v]>minreach[u]){ minreach[v]=minreach[u]; if((maxreturn[v]>minreach[v]) || (maxreturn[v]==minreach[v] && v>=k)) ans=false; if(!dfs(v)) ans=false;; } } return ans; } int add_teleporter(int u,int v){ if(u==v && u<k) return 1; edges[u].push_back(v); redges[v].push_back(u); if(maxreturn[v]<maxreturn[u]){ maxreturn[v]=maxreturn[u]; if(!dfs(v)) return 1; } if(minreach[u]>minreach[v]){ minreach[u]=minreach[v]; if(!rdfs(u)) return 1; } return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...