# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
728577 | grogu | Thousands Islands (IOI22_islands) | C++17 | 106 ms | 12592 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 <iostream>
#include <vector>
#include <variant>
#include <set>
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define ll int
#define pll pair<ll,ll>
#define pb push_back
using namespace std;
#define maxn 405
ll n,m;
vector<ll> g[maxn];
ll id[maxn][maxn];
set<pll> sss;
vector<ll> gen(vector<ll> v){
vector<ll> ans;
for(ll x : v) ans.pb(x);
for(ll i = v.size()/2 - 1;i>=0;i--) ans.pb(v[i]);
for(ll i = v.size()-1;i>=v.size()/2;i--) ans.pb(v[i]);
return ans;
}
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
n = N;
m = M;
for(ll &x : U) x++;
for(ll &x : V) x++;
if(n==2){
vector<vector<ll> > cnt(3);
for(ll i = 0;i<m;i++){
ll x = U[i],y = V[i];
cnt[x].pb(i);
}
bool ok = cnt[1].size()>=2&&cnt[2].size()>=1;
if(!ok) return ok;
ll x = cnt[1][0],y = cnt[1][1];
ll z = cnt[2][0];
vector<ll> ans;
ans.pb(x);
ans.pb(z);
ans.pb(y);
ans.pb(x);
ans.pb(z);
ans.pb(y);
return ans;
}
for(ll i = 0;i<m;i++){
ll x = U[i],y = V[i];
g[x].pb(y);
g[y].pb(x);
id[x][y] = i;
sss.insert({x,y});
}
if(n<=400&&sss.size()==m&&m==n*(n-1)/2){
ll x = id[1][2];
ll y = id[2][3];
ll z = id[3][1];
ll rx = id[2][1];
ll ry = id[3][2];
ll rz = id[1][3];
vector<ll> ans = gen({x,y,z,rx,ry,rz});
return ans;
}
}
Compilation message (stderr)
# | 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... |