이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |