Submission #1150027

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11500272025-02-13 15:58:07byunjaewooThousands Islands (IOI22_islands)C++20
100 / 100
130 ms32836 KiB
#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<multiset<pair<int, int>>> tadj(N);
vector<set<array<int, 3>>> adj(N);
vector<vector<pair<int, int>>> radj(N);
vector<int> ret, st;
for(int i=0; i<M; i++) tadj[U[i]].insert({V[i], i}), radj[V[i]].push_back({U[i], i});
queue<int> q;
auto del=[&]() {
while(!q.empty()) {
int curr=q.front(); q.pop();
for(auto [next, k]:radj[curr]) {
tadj[next].erase(tadj[next].find({curr, k}));
if(tadj[next].empty()) q.push(next);
}
radj[curr].clear();
}
};
int p=0;
for(int i=0; i<N; i++) if(tadj[i].empty()) q.push(i);
del();
if(tadj[0].empty()) return false;
while(tadj[p].size()==1) {
q.push(p), del();
if(tadj[p].empty()) return false;
st.push_back(tadj[p].begin()->second);
p=tadj[p].begin()->first;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...