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>
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
bool visited[1000];
vector<array<ll,2>> edges[1000];
ll N;
vector<ll> ans;
void dfs(ll a, ll p){
for (auto&i : edges[a]){
if (i[0] != p && visited[i[0]] == 0){
visited[i[0]] = 1;
ans.push_back(i[1]);
dfs(i[0], p);
}
}
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
FOR(i,0,u.size()){
edges[u[i]].push_back({v[i],i});
edges[v[i]].push_back({u[i],i});
}
set<ll> realans;
FOR(i,0,n){
FOR(p,0,1000) visited[p] = 0;
ans.clear();
if (i==0) visited[1]=1,dfs(1,i);
else visited[0]=1,dfs(0,i);
if (ans.size() == n-2){
vector<array<ll,2>> idk;
for (auto&j : edges[i]){
ans.push_back(j[1]);
ll sus = count_common_roads(ans);
idk.push_back({sus, j[1]});
ans.pop_back();
}
sort(idk.begin(), idk.end());
for (auto&i : idk) if (i[0] == idk[idk.size()-1][0]) realans.insert(i[1]);
}
}
vector<ll> temp;
for (auto&i : realans) temp.push_back(i);
if (temp.size() != n-1){
FOR(i,0,1000000000) cout << "NYA" << endl;
}
return temp;
}
Compilation message (stderr)
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:7:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
34 | FOR(i,0,u.size()){
| ~~~~~~~~~~~~
simurgh.cpp:34:2: note: in expansion of macro 'FOR'
34 | FOR(i,0,u.size()){
| ^~~
simurgh.cpp:47:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | if (ans.size() == n-2){
| ~~~~~~~~~~~^~~~~~
simurgh.cpp:65:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
65 | if (temp.size() != n-1){
| ~~~~~~~~~~~~^~~~~~
# | 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... |