제출 #1072988

#제출 시각아이디문제언어결과실행 시간메모리
1072988beaconmc수천개의 섬 (IOI22_islands)C++17
8.40 / 100
60 ms14032 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 realvisited[maxn]; bool flag = 0; void dfs(ll a){ visited[a] = 1; realvisited[a] = 1; for (auto&i : edges[a]){ if (realvisited[i]) flag = 1; else{ if (!visited[i]) visited[i] = 1, dfs(i); } } realvisited[a] = 0; } 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); 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...