제출 #1072977

#제출 시각아이디문제언어결과실행 시간메모리
1072977beaconmc수천개의 섬 (IOI22_islands)C++17
1.75 / 100
64 ms16336 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) const ll maxn = 100005; set<int> edges[maxn]; bool visited[maxn]; bool flag = 0; void dfs(ll a, ll p){ visited[a] = 1; for (auto&i : edges[a]){ if (i==p) continue; if (visited[i]) flag = 1; else{ visited[i] = 1; dfs(i, a); } } } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { flag = 0; FOR(i,0,maxn) visited[i] = 0; FOR(i,0,maxn) edges[i].clear(); FOR(i,0,M){ edges[U[i]].insert(V[i]); } dfs(0, -1); if (flag==1) return true; else 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...