Submission #630706

#TimeUsernameProblemLanguageResultExecution timeMemory
630706DanerZeinThousands Islands (IOI22_islands)C++17
1.75 / 100
32 ms5288 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> #include <vector> using namespace std; typedef pair<int,int> ii; typedef vector<ii> vii; const int MAX_N=1010; const int MAX_M=2e5+10; vector<vii> G; bool vis[MAX_N]; bool usa[MAX_M]; void dfs(int u){ vis[u]=1; for(auto &v:G[u]){ if(!vis[v.first]){ usa[v.second]=1; dfs(v.first); } } } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { G.resize(N+1); for(int i=0;i<M;i+=2){ G[U[i]].push_back(ii(V[i],i/2)); G[U[i+1]].push_back(ii(V[i+1],i/2)); } memset(vis,0,sizeof vis); dfs(0); bool ci=0; for(int i=0;i<N;i++){ if(vis[i]){ for(auto &v:G[i]){ if(vis[v.first] && !usa[v.second]){ ci=1; break; } } } if(ci) break; } if(ci || G[0].size()>=2) return true; return false; }
#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...