# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73927 | Batmend4 | Simurgh (IOI17_simurgh) | C++98 | 181 ms | 3716 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 "simurgh.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector<int> motherfickinggoldenroads;
vector< pair<int, int> > ed[n];
for( int i = 0 ; i < u.size() ; i++ ){
ed[u[i]].push_back(make_pair( v[i], i) );
ed[v[i]].push_back(make_pair( u[i], i) );
}
for( int i = 0 ; i < n ; i++ ){
vector<int> ct;
int pos = 0;
int used[n];
memset(used, -1, sizeof used);
used[i] = 1000000007;
for( int j = 0 ; j < n ; j++ ){
if( used[j] != -1 ) continue;
queue< int >q;
q.push(j);
used[j] = pos;
while( !q.empty()){
int x = q.front();
q.pop();
for( int i = 0 ; i < ed[x].size() ; i++ ){
if( used[ed[x][i].first] != -1 ) continue;
ct.push_back( ed[x][i].second );
used[ed[x][i].first] = pos;
q.push( ed[x][i].first);
}
}
pos++;
}
vector<int> edge[pos + 5];
vector<pair<int, int> > impo[pos + 5];
for( int j = 0 ; j < ed[i].size() ; j++ ){
edge[used[ed[i][j].first]].push_back(ed[i][j].second);
}
for( int j = 0 ; j < pos ; j++ ){
ct.push_back(edge[j][0]);
}
for( int j = 0 ; j < ed[i].size() ; j++ ){
ct[n - 2 - (pos - 1) + used[ed[i][j].first]] = ed[i][j].second;
impo[used[ed[i][j].first]].push_back(make_pair(count_common_roads(ct), ed[i][j].second));
}
for( int j = 0 ; j < pos ; j++ ){
sort( impo[j].begin(), impo[j].end() );
bool lol = 1;
int si = impo[j].size();
int x = impo[j][si - 1].first;
for( int ii = si - 1 ; ii >= 0 ; ii-- ){
if( impo[j][ii].first != x )lol = 0;
if (lol == 0) continue;
motherfickinggoldenroads.push_back(impo[j][ii].second);
}
}
}
sort( motherfickinggoldenroads.begin(), motherfickinggoldenroads.end());
vector<int> realmotherfickinggoldenroads;
for( int i = 0 ; i < motherfickinggoldenroads.size() / 2; i++ ){
realmotherfickinggoldenroads.push_back(motherfickinggoldenroads[i * 2]);
}
return realmotherfickinggoldenroads;
}
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... |