This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "islands.h"
#include<bits/stdc++.h>
using namespace std;
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
//vector<int> find_journey(int N, int M, vector<int> U, vector<int> V) {
vector<map<int, vector<int>>> adj(N);
vector<int> out(N);
for(int i = 0; i < M; ++i) {
adj[U[i]][V[i]].push_back(i);
}
if(N < 3) return false;
vector<int> ans;
ans = {adj[0][1][0], adj[1][0][0], adj[0][2][0], adj[2][0][0], adj[1][0][0], adj[0][1][0], adj[2][0][0], adj[0][2][0]};
return ans;
/* int cur = 0, prev = -1;
vector<int> way, ans;
while(1) {
int cs = out[cur] - (prev != -1);
if(cs == 0) return false;
if(cs == 1) {
for(auto& u : adj[cur]) if(u.first != prev) {
way.push_back(u.second[0]);
prev = cur;
cur = u.first;
break;
}
continue;
}
break;
}
//return true;
ans = way;
vector<pair<int, int>> z;
for(auto& u : adj[cur]) if(u.first != prev) {
for(auto& v : u.second) {
z.push_back(v);
if((int)z.size() == 2) break;
}
if((int)z.size() == 2) break;
}
ans.push_back(z[0]);
ans.push_back(z[0] / 2 * 4 + 1 - z[0]);
ans.push_back(z[1]);
ans.push_back(z[1] / 2 * 4 + 1 - z[1]);
ans.push_back(z[0] / 2 * 4 + 1 - z[0]);
ans.push_back(z[0]);
ans.push_back(z[1] / 2 * 4 + 1 - z[1]);
ans.push_back(z[1]);
reverse(begin(way), end(way));
for(auto& u : way) ans.push_back(u);
return ans;*/
}
/*
int main() {
int N, M;
assert(2 == scanf("%d %d", &N, &M));
std::vector<int> U(M), V(M);
for (int i = 0; i < M; ++i) {
assert(2 == scanf("%d %d", &U[i], &V[i]));
}
vector<int> result = find_journey(N, M, U, V);
for(auto& u : result) {
cout << u << '\n';
}
}*/
# | 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... |