Submission #1058175

#TimeUsernameProblemLanguageResultExecution timeMemory
1058175hirayuu_ojThousands Islands (IOI22_islands)C++17
10 / 100
47 ms31412 KiB
#include "islands.h" #include <variant> #include <vector> #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rng(i,l,r) for(int i=(l); i<(r); i++) #define all(x) x.begin(),x.end() using ll=long long; std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { if(N==2) { vector<vector<int>> cnt(2); rep(i,M)cnt[U[i]].emplace_back(i); if(cnt[0].size()>=2&&cnt[1].size()>=1) { return vector<int>{cnt[0][0],cnt[1][0],cnt[0][1],cnt[0][0],cnt[1][0],cnt[0][1]}; } else { return false; } } bool subtask2=true; if(N>400)subtask2=false; array<array<vector<int>,1000>,1000> gr; rep(i,M) { if(gr[U[i]][V[i]].size()!=0)subtask2=false; gr[U[i]][V[i]].emplace_back(i); } if(M!=N*(N-1))subtask2=false; if(subtask2) { vector<int> ans; rep(i,N) { ans.emplace_back(gr[i][(i+1)%N][0]); } rep(i,N) { ans.emplace_back(gr[(N-i)%N][N-i-1][0]); } rep(i,N) { ans.emplace_back(gr[N-i-1][(N-i)%N][0]); } rep(i,N) { ans.emplace_back(gr[(i+1)%N][i][0]); } return ans; } else { vector<int> cnt(N,0); rep(i,N) { rep(j,N) { if(gr[i][j].size()>=2)return true; cnt[i]++; } } if(cnt[0]>=2)return true; int mx=0; for(int i:cnt)mx=max(mx,i); if(mx>=3)return true; return false; } return false; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...