Submission #730419

#TimeUsernameProblemLanguageResultExecution timeMemory
730419caganyanmazThousands Islands (IOI22_islands)C++17
0 / 100
2 ms596 KiB
#include <bits/stdc++.h> #define pb push_back #define pp pop_back using namespace std; vector<array<int, 2>> edges; vector<vector<int>> g; vector<bool> visited; vector<int> path; vector<int> res; bool dfs(int node) { if (visited[node]) { for (int i : path) res.pb(i); int i; for (i = 0; i < path.size() && edges[path[i]][0] != node; i++); assert(i < path.size()); for (int j = i; j < path.size(); j++) res.pb(path[j]+1); for (int j = path.size()-1; j >= i; j--) res.pb(path[j]); for (int j = path.size()-1; j >= i; j--) res.pb(path[j]+1); for (int j = i-1; j >= 0; j--) res.pb(path[j]); return true; } visited[node] = true; for (int edge : g[node]) { path.pb(edge); if(dfs(edges[edge][1])) return true; } return false; } variant<bool, vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v) { edges = vector<array<int, 2>>(m); g = vector<vector<int>>(n); visited = vector<bool>(n); for (int i = 0; i < m; i+=2) { edges[i][0] = u[i], edges[i][1] = v[i]; g[u[i]].pb(i); } if(dfs(0)) return res; return false; }

Compilation message (stderr)

islands.cpp: In function 'bool dfs(int)':
islands.cpp:19:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |                 for (i = 0; i < path.size() && edges[path[i]][0] != node; i++);
      |                             ~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from islands.cpp:1:
islands.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |                 assert(i < path.size());
      |                        ~~^~~~~~~~~~~~~
islands.cpp:21:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |                 for (int j = i; j < path.size(); j++)
      |                                 ~~^~~~~~~~~~~~~
#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...