Submission #745876

#TimeUsernameProblemLanguageResultExecution timeMemory
745876math_rabbit_1028Thousands Islands (IOI22_islands)C++17
0 / 100
1091 ms13000 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; bool ans = false; int n, m; vector< pair<int, int> > adj[101010], rev[101010]; int out[101010], remain[202020]; set< pair<int, int> > outset; int ch[101010]; void DFS(int v) { //cout << v << "\n"; ch[v] = 1; int cnt = 0; for (int i = 0; i < adj[v].size(); i++) { if (remain[adj[v][i].second] == 0) continue; int next = adj[v][i].first; if (ch[next] == 0) { cnt++; ch[next] = 1; DFS(next); ch[next] = 0; } } if (cnt >= 2) { ans = true; } } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { n = N; m = M; for (int i = 0; i < m; i++) { adj[U[i]].push_back({V[i], i}); rev[V[i]].push_back({U[i], i}); out[U[i]]++; remain[i] = 1; } for (int i = 0; i < n; i++) outset.insert({out[i], i}); while (!outset.empty() && outset.begin()->first == 0) { int v = outset.begin()->second; outset.erase(outset.begin()); for (int i = 0; i < rev[v].size(); i++) { if (remain[rev[v][i].second] == 0) continue; remain[rev[v][i].second] = 0; outset.erase(outset.find(make_pair(out[rev[v][i].first], rev[v][i].first))); out[rev[v][i].first]--; outset.insert(make_pair(out[rev[v][i].first], rev[v][i].first)); } } DFS(0); return ans; }

Compilation message (stderr)

islands.cpp: In function 'void DFS(int)':
islands.cpp:19:21: 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 < adj[v].size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~
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:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (int i = 0; i < rev[v].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...