# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60629 |
2018-07-24T12:00:37 Z |
Tenuun |
Simurgh (IOI17_simurgh) |
C++17 |
|
3 ms |
920 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> >adj[501];
vector<int>t;
bool vis[501], check[125000]={false};
void DFS(int u, int p){
vis[u]=true;
for(auto v:adj[u]){
if(v.first!=p && vis[v.first]==false){
vis[v.first]=true;
if(p!=-1) t.push_back(v.second);
DFS(v.first, u);
}
}
}
int calc(int u){
int mx=-1, p=-1, tmp;
for(auto v:adj[u]){
if(check[v.second]){
t.push_back(v.second);
mx=count_common_roads(t);
t.pop_back();
break;
}
}
for(auto v:adj[u]){
if(check[v.second])continue;
t.push_back(v.second);
tmp=count_common_roads(t);
if(mx==-1){
mx=tmp;
p=v.second;
}
else if(tmp==mx){
p=v.second;
}
t.pop_back();
}
return p;
}
vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
int f, ind=0;
memset(check, false, sizeof check);
vector<int> res(n - 1);
for(int i=0; i<u.size(); i++){
adj[u[i]].push_back({v[i], i});
adj[v[i]].push_back({u[i], i});
}
for(int i=0; i<n; i++){
memset(vis, false, sizeof vis);
t.clear();
DFS(i, -1);
f=calc(i);
if(f<0 || f>u.size() || check[f]) continue;
check[f]=true;
res[ind++]=f;
}
return res;
}
Compilation message
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:51:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<u.size(); i++){
~^~~~~~~~~
simurgh.cpp:60:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(f<0 || f>u.size() || check[f]) continue;
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
868 KB |
correct |
2 |
Incorrect |
3 ms |
920 KB |
WA in grader: NO |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |