Submission #1061555

#TimeUsernameProblemLanguageResultExecution timeMemory
1061555jamjanekThousands Islands (IOI22_islands)C++17
5 / 100
18 ms6336 KiB
#include "islands.h" #include <variant> #include <vector> #include<bits/stdc++.h> using namespace std; int odw[100010]; vector<int>graf[100010]; void dfs(int x){ for(auto j: graf[x]){ odw[j]++; if(odw[j]==1) dfs(j); } } std::variant<bool, std::vector<int>> find_journey(int n, int m, std::vector<int> U, std::vector<int> V) { if(n==2)return false; int a, b, c, d, e, f; for(int i=0;i<m;i++){ if(U[i]==0 && V[i]==1) a = i; if(V[i]==0 && U[i]==1) b = i; if(U[i]==0 && V[i]==2) c = i; if(V[i]==0 && U[i]==2) d = i; if(U[i]==2 && V[i]==1) e = i; if(V[i]==2 && U[i]==1) f = i; } vector<int>ans = {a, f, d, c, e, b, d, f, a, b, e, c}; return ans; int i; for(i=0;i<m;i+=2){ graf[U[i]].push_back(V[i]); } odw[0] = 1; dfs(0); for(i=0;i<n;i++) if(odw[i]>1) return true; return false; }

Compilation message (stderr)

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:35:54: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |  vector<int>ans = {a, f, d, c, e, b, d, f, a, b, e, c};
      |                                                      ^
islands.cpp:35:54: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:54: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:54: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:54: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:54: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...