Submission #632012

#TimeUsernameProblemLanguageResultExecution timeMemory
632012typ_ikThousands Islands (IOI22_islands)C++17
5 / 100
34 ms4424 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define watch(x) cout << (#x) << " = " << x << '\n' #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; map < pair<int,int>,vector<int> > cnt; vector < int > ans; bool ok = true; void dfs(int a,int b){ pair<int,int> A = {a, b}; pair<int,int> B = {b, a}; if(cnt[A].size() == 0){ ok = false; return; } ans.push_back(cnt[A][0]); } void go(int a,int b){ pair<int,int> A = {a,b}; pair<int,int> B = {b,a}; if(cnt[B].size() == 0){ ok = false; return; } ans.push_back(cnt[B][0]); if(cnt[A].size() < 2){ ok = false; return; } ans.push_back(cnt[A][1]); ans.push_back(cnt[A][0]); ans.push_back(cnt[B][0]); ans.push_back(cnt[A][1]); } std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) { for(int i = 0; i < M; i++){ cnt[{U[i],V[i]}].push_back(i); } for(int i = 0; i + 1 < N; i++){ dfs(i,i+1); } for(int i = N-2; i >= 0; i--){ go(i,i+1); if(!ok) return false; } return ans; }

Compilation message (stderr)

islands.cpp: In function 'void dfs(int, int)':
islands.cpp:20:19: warning: variable 'B' set but not used [-Wunused-but-set-variable]
   20 |     pair<int,int> B = {b, a};
      |                   ^
#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...