# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
628875 | welleyth | Thousands Islands (IOI22_islands) | C++17 | 0 ms | 0 KiB |
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 <variant>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
map<pair<int,int>,vector<int>> cnt;
vector<int> ans;
bool ok = true;
void go1(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]);
return;
}
void go2(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]);
return;
}
std::variant<bool, std::vector<int>> find_journey(
return true;
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++){
go1(i,i+1);
}
for(int i = N-2; i >= 0; i--){
go2(i,i+1);
if(!ok)
return false;
}
return ans;
}