제출 #986462

#제출 시각아이디문제언어결과실행 시간메모리
986462Yazan_SA게임 (IOI14_game)C++14
0 / 100
1 ms348 KiB
//#pragma once #include "bits/stdc++.h" using namespace std; int N=1e9; map<pair<int,int>,int>mp2; map<pair<int,int>,bool>mp3; vector<vector<int>>gr; bool able(int x, int u, int v, vector<bool>&vis) { if(x==v)return 1; vis[x]=1; for(auto c:gr[x]) { if(vis[c] || (x==u && c==v) || mp3[{u,v}])continue; if(able(c,u,v,vis))return 1; } return 0; } void initialize(int n) { gr.resize(n); for(int i=0; i<n; i++) { for(int j=0;j<n; j++) { if(i==j)continue; gr[i].push_back(j); } } return; } int hasEdge(int u, int v) { if(u>v)swap(u,v); if(mp2[{u,v}])return mp2[{u,v}]%2; vector<bool>vis((int)gr.size()); if((int)gr[u].size()==1 || (int)gr[v].size()==1 || !able(u,u,v,vis)) { mp2[{u,v}]=1; return 1; } mp2[{u,v}]=2; mp3[{u,v}]=1; // cout<<"1"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...