# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1024697 | Wansur | Thousands Islands (IOI22_islands) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <variant>
#define f first
#define s second
#define ent '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 12;
const int mod = 1e9 + 2022;
map<int, int> a[maxn];
vector<int> g[maxn];
int n, m;
variant<bool, vector<int>> find_journey(int N, int M, vector<int> u, vector<int> v){
n = N, m = M;
for(int i=0;i<m;i++){
a[u[i]][v[i]] = i;
g[u[i]].push_back(i);
}
vector<int> ans;
if(g[0].size() >= 2){
int x = v[g[0][0]], y = v[g[0][1]];
ans = {a[0][x], a[x][0], a[0][y], a[y][0], a[x][0], a[0][x], a[y][0], a[0][y]};
return ans;
}
if(g[0].size() == 0) return false;
int x = v[g[0][0]], sz = 1, y = 0;
ans = {g[0][0]};
while(g[x].size() == 2){
int t = 0;
if(v[g[x][t]] == y){
t++;
}
ans.push_back(g[x][t]);
y = x;
x = v[g[x][t]];
}
if(g[x].size() <= 1) return false;
return {0};
}