Submission #830790

#TimeUsernameProblemLanguageResultExecution timeMemory
830790tolbiThousands Islands (IOI22_islands)C++17
0 / 100
28 ms7956 KiB
#include <bits/stdc++.h> using namespace std; #define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl; #include "islands.h" variant<bool, vector<int>> solve(int n, int m, vector<int> u, vector<int> v, vector<int> _indis) { vector<bool> vis(n,false); vector<int> ansarr; vector<vector<pair<int,int>>> arr(n); for (int i = 0; i < m; ++i) { arr[u[i]].push_back({v[i],_indis[i]}); } auto dfs = [&](int node, auto dfs)->bool{ if (vis[node]) { return true; } vis[node]=true; ansarr.push_back(node); for (int i = 0; i < arr[node].size(); i++){ if (dfs(arr[node][i].first,dfs)) return true; } ansarr.pop_back(); return false; }; if (!dfs(0,dfs)) return false; return true; } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { int crr = 0; vector<int> ind(N,-1); vector<int> indarr; vector<vector<int>> arr(N); for (int i = 0; i < M; ++i) { arr[U[i]].push_back(V[i]); } auto dfs = [&](int node, auto dfs)->void{ if (ind[node]!=-1) return; ind[node]=crr++; for (int i = 0; i < arr[node].size(); i++){ dfs(arr[node][i],dfs); } }; dfs(0,dfs); vector<int> asu; vector<int> asv; for (int i = 0; i < M; i++){ if (ind[U[i]]==-1 || ind[V[i]]==-1) continue; asu.push_back(ind[U[i]]); asv.push_back(ind[V[i]]); indarr.push_back(i); } return solve(crr,asu.size(),asu,asv,indarr); }

Compilation message (stderr)

islands.cpp: In instantiation of 'solve(int, int, std::vector<int>, std::vector<int>, std::vector<int>)::<lambda(int, auto:23)> [with auto:23 = solve(int, int, std::vector<int>, std::vector<int>, std::vector<int>)::<lambda(int, auto:23)>]':
islands.cpp:25:19:   required from here
islands.cpp:19:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for (int i = 0; i < arr[node].size(); i++){
      |                         ~~^~~~~~~~~~~~~~~~~~
islands.cpp: In instantiation of 'find_journey(int, int, std::vector<int>, std::vector<int>)::<lambda(int, auto:24)> [with auto:24 = find_journey(int, int, std::vector<int>, std::vector<int>)::<lambda(int, auto:24)>]':
islands.cpp:44:14:   required from here
islands.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int i = 0; i < arr[node].size(); i++){
      |                         ~~^~~~~~~~~~~~~~~~~~
#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...