제출 #837467

#제출 시각아이디문제언어결과실행 시간메모리
837467fatemetmhr수천개의 섬 (IOI22_islands)C++17
27.75 / 100
34 ms8124 KiB
// Be name khoda // #include "islands.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define debug(x) cerr << "(" << (#x) << "): " << (x) << endl; #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define fi first #define se second typedef long long ll; const int mod = 1e9 + 9; const int maxn5 = 1e5 + 10; vector <pair<int, int>> adj[maxn5]; bool mark[maxn5]; std::variant<bool, std::vector<int>> find_journey( int n, int m, std::vector<int> u, std::vector<int> v) { if(n == 2){ vector <int> cnt[2], ret; for(int i = 0; i < m; i++){ cnt[u[i]].pb(i); } if(int(cnt[0].size()) < 2 || int(cnt[1].size()) < 1) return false; int a = cnt[0][0], b = cnt[0][1], c = cnt[1][0]; return vector <int> ({a, c, b, a, c, b}); } for(int i = 0; i < m; i++) adj[u[i]].pb({v[i], i}); vector <int> ret; int x = 0; while(true){ mark[x] = true; int cnt = 0; for(auto [u, id] : adj[x]) if(!mark[u]) cnt++; if(!cnt) return false; if(cnt == 1){ for(auto [u, id] : adj[x]) if(!mark[u]){ ret.pb(id); x = u; break; } continue; } vector <int> tmp = ret, have; reverse(all(tmp)); for(auto [u, id] : adj[x]) if(!mark[u]) have.pb(id); int a = have[0], b = have[1]; ret.pb(a); ret.pb(a ^ 1); ret.pb(b); ret.pb(b ^ 1); ret.pb(a ^ 1); ret.pb(a); ret.pb(b ^ 1); ret.pb(b); for(auto u : tmp) ret.pb(u); return ret; } return false; }
#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...