# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629777 | Cross_Ratio | Keys (IOI21_keys) | C++17 | 3050 ms | 89232 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 <bits/stdc++.h>
using namespace std;
int R[300005];
typedef pair<int,int> P;
vector<vector<P>> adj;
int res[300005];
int N;
vector<int> find_reachable(vector<int> _R, vector<int> _U, vector<int> _V, vector<int> _C) {
N = _R.size();
int i, j;
for(i=0;i<N;i++) R[i] = _R[i];
adj.resize(N);
for(i=0;i<_U.size();i++) {
adj[_U[i]].push_back(P(_V[i],_C[i]));
adj[_V[i]].push_back(P(_U[i],_C[i]));
}
for(i=0;i<N;i++) {
int org = R[i];
vector<queue<int>> Q;
Q.resize(N);
vector<bool> vis;
vector<int> cord;
cord.resize(N);
for(j=0;j<N;j++) cord[j] = j;
vis.resize(N);
res[i]++;
vis[i] = true;
for(P k : adj[i]) {
Q[cord[k.second]].push(k.first);
}
while(!Q[org].empty()) {
int c = Q[org].front();
//cout << c << ' ';
Q[org].pop();
if(vis[c]) continue;
vis[c] = true;
res[i]++;
for(P k : adj[c]) {
Q[cord[k.second]].push(k.first);
}
if(cord[R[c]]!=org) {
cord[R[c]] = org;
while(!Q[R[c]].empty()) {
int n = Q[R[c]].front();
Q[R[c]].pop();
Q[org].push(n);
}
}
}
//cout << '\n' << res[i] << '\n';
}
int mi = 1e9;
for(i=0;i<N;i++) mi = min(mi, res[i]);
vector<int> ans;
ans.resize(N);
for(i=0;i<N;i++) {
if(res[i]==mi) ans[i] = 1;
}
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... |