제출 #1058492

#제출 시각아이디문제언어결과실행 시간메모리
1058492tolbi수천개의 섬 (IOI22_islands)C++17
0 / 100
16 ms4188 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { vector<vector<pair<int,int>>> arr(N); for (int i = 0; i < M; i+=2){ arr[U[i]].push_back({V[i],i}); } vector<bool> vis(N,false); vector<pair<int,int>> par(N,{-1,-1}); function<void(int)> dfs = [&](int node)->void{ if (vis[node]) return; vis[node]=true; for (auto it : arr[node]){ if (vis[it.first]) continue; par[it.first]={node,it.second}; dfs(it.first); } }; for (auto it : arr[0]){ if (vis[it.first]) continue; par[it.first]={0,it.second}; dfs(it.first); if (par[0].first!=-1){ //oha cevap buldum return vector<int>(1,23); } } 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...