# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
259101 |
2020-08-07T08:03:27 Z |
dsjong |
Simurgh (IOI17_simurgh) |
C++14 |
|
3000 ms |
20256 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
set<int>adj[505];
map<pair<int, int>, int>mp;
int roads;
bool vis[505];
int a[200000], val[200000], par[505], l[505];
int timer=0;
pair<int, int>cur={-1, -1};
void dfs(int x, int p){
vis[x]=true;
par[x]=p;
l[x]=timer++;
for(int y:adj[x]){
if(!vis[y]) dfs(y, x);
else if(y!=p && l[y]<=l[x]){
cur={x, y};
}
}
}
vector<int>test, query, oq;
void bfs(){
memset(vis, false, sizeof vis);
queue<int>q;
for(int i=0;i<test.size()-1;i++){
vis[test[i]]=true;
q.push(test[i]);
}
while(!q.empty()){
int x=q.front();
q.pop();
for(int y:adj[x]){
if(!vis[y]){
q.push(y);
vis[y]=true;
query.push_back(mp[{x, y}]-1);
}
}
}
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
int m=u.size();
roads=m;
for(int i=0;i<m;i++){
adj[u[i]].insert(v[i]);
adj[v[i]].insert(u[i]);
mp[{u[i], v[i]}]=i+1;
mp[{v[i], u[i]}]=i+1;
}
while(roads>=n){
//cout<<roads<<endl;
memset(vis, false, sizeof vis);
dfs(0, -1);
int x=cur.first, y=cur.second, ox=cur.first;
test.clear();
while(x!=y){
test.push_back(x);
x=par[x];
}
test.push_back(y);
test.push_back(ox);
/*for(int i:test) cout<<i<<" ";
cout<<endl;*/
query.clear();
bfs();
int mini=0, sz=test.size();
for(int i=0;i<sz-1;i++){
oq=query;
if(a[mp[{test[i], test[i+1]}]]!=0) continue;
for(int j=0;j<sz-1;j++){
if(j!=i) query.push_back(mp[{test[j], test[j+1]}]-1);
}
/*cout<<"querying ";
for(int i:query) cout<<i<<" ";
cout<<endl;*/
val[i]=count_common_roads(query);
mini=max(mini, val[i]);
query=oq;
}
for(int i=0;i<sz-1;i++){
if(a[mp[{test[i], test[i+1]}]]!=0) continue;
if(val[i]==mini){
//cout<<"delet "<<test[i]<<" "<<test[i+1]<<": "<<mp[{test[i], test[i+1]}]-1<<endl;
a[mp[{test[i], test[i+1]}]]=1;
adj[test[i]].erase(test[i+1]);
adj[test[i+1]].erase(test[i]);
roads--;
}
else{
//cout<<"fix "<<test[i]<<" "<<test[i+1]<<": "<<mp[{test[i], test[i+1]}]-1<<endl;
a[mp[{test[i], test[i+1]}]]=2;
}
}
}
vector<int>ans;
for(int i=0;i<m;i++){
if(a[i+1]!=1) ans.push_back(i);
}
return ans;
}
Compilation message
simurgh.cpp: In function 'void bfs()':
simurgh.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<test.size()-1;i++){
~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
0 ms |
384 KB |
correct |
12 |
Correct |
1 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
0 ms |
384 KB |
correct |
12 |
Correct |
1 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
21 ms |
640 KB |
correct |
15 |
Correct |
24 ms |
640 KB |
correct |
16 |
Correct |
19 ms |
640 KB |
correct |
17 |
Correct |
16 ms |
656 KB |
correct |
18 |
Correct |
4 ms |
384 KB |
correct |
19 |
Correct |
16 ms |
640 KB |
correct |
20 |
Correct |
15 ms |
640 KB |
correct |
21 |
Correct |
14 ms |
512 KB |
correct |
22 |
Correct |
8 ms |
512 KB |
correct |
23 |
Correct |
7 ms |
512 KB |
correct |
24 |
Correct |
7 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
396 KB |
correct |
26 |
Correct |
7 ms |
512 KB |
correct |
27 |
Correct |
7 ms |
512 KB |
correct |
28 |
Correct |
2 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
7 ms |
512 KB |
correct |
31 |
Correct |
7 ms |
512 KB |
correct |
32 |
Correct |
8 ms |
512 KB |
correct |
33 |
Correct |
8 ms |
512 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
0 ms |
384 KB |
correct |
12 |
Correct |
1 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
21 ms |
640 KB |
correct |
15 |
Correct |
24 ms |
640 KB |
correct |
16 |
Correct |
19 ms |
640 KB |
correct |
17 |
Correct |
16 ms |
656 KB |
correct |
18 |
Correct |
4 ms |
384 KB |
correct |
19 |
Correct |
16 ms |
640 KB |
correct |
20 |
Correct |
15 ms |
640 KB |
correct |
21 |
Correct |
14 ms |
512 KB |
correct |
22 |
Correct |
8 ms |
512 KB |
correct |
23 |
Correct |
7 ms |
512 KB |
correct |
24 |
Correct |
7 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
396 KB |
correct |
26 |
Correct |
7 ms |
512 KB |
correct |
27 |
Correct |
7 ms |
512 KB |
correct |
28 |
Correct |
2 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
7 ms |
512 KB |
correct |
31 |
Correct |
7 ms |
512 KB |
correct |
32 |
Correct |
8 ms |
512 KB |
correct |
33 |
Correct |
8 ms |
512 KB |
correct |
34 |
Execution timed out |
3083 ms |
7544 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Execution timed out |
3076 ms |
20256 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
correct |
2 |
Correct |
1 ms |
384 KB |
correct |
3 |
Correct |
1 ms |
384 KB |
correct |
4 |
Correct |
0 ms |
384 KB |
correct |
5 |
Correct |
1 ms |
384 KB |
correct |
6 |
Correct |
1 ms |
384 KB |
correct |
7 |
Correct |
0 ms |
384 KB |
correct |
8 |
Correct |
1 ms |
384 KB |
correct |
9 |
Correct |
1 ms |
384 KB |
correct |
10 |
Correct |
0 ms |
384 KB |
correct |
11 |
Correct |
0 ms |
384 KB |
correct |
12 |
Correct |
1 ms |
384 KB |
correct |
13 |
Correct |
1 ms |
384 KB |
correct |
14 |
Correct |
21 ms |
640 KB |
correct |
15 |
Correct |
24 ms |
640 KB |
correct |
16 |
Correct |
19 ms |
640 KB |
correct |
17 |
Correct |
16 ms |
656 KB |
correct |
18 |
Correct |
4 ms |
384 KB |
correct |
19 |
Correct |
16 ms |
640 KB |
correct |
20 |
Correct |
15 ms |
640 KB |
correct |
21 |
Correct |
14 ms |
512 KB |
correct |
22 |
Correct |
8 ms |
512 KB |
correct |
23 |
Correct |
7 ms |
512 KB |
correct |
24 |
Correct |
7 ms |
512 KB |
correct |
25 |
Correct |
1 ms |
396 KB |
correct |
26 |
Correct |
7 ms |
512 KB |
correct |
27 |
Correct |
7 ms |
512 KB |
correct |
28 |
Correct |
2 ms |
384 KB |
correct |
29 |
Correct |
1 ms |
384 KB |
correct |
30 |
Correct |
7 ms |
512 KB |
correct |
31 |
Correct |
7 ms |
512 KB |
correct |
32 |
Correct |
8 ms |
512 KB |
correct |
33 |
Correct |
8 ms |
512 KB |
correct |
34 |
Execution timed out |
3083 ms |
7544 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |