# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
828504 |
2023-08-17T10:35:25 Z |
tolbi |
Simurgh (IOI17_simurgh) |
C++17 |
|
139 ms |
7960 KB |
#include <bits/stdc++.h>
using namespace std;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define coutara(x,y) for (auto &it : x) cout<<it<<" ";cout<<y<<endl;
#include "simurgh.h"
int ask(set<int> &st){
vector<int> askarr;
auto it = st.begin();
while (it!=st.end()){
askarr.push_back(*it);
it++;
}
int ans = count_common_roads(askarr);
//coutara(askarr,ans);
return ans;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector<vector<int>> arr(n);
int m = u.size();
map<pair<int,int>,int> mp;
for (int i = 0; i < m; i++){
arr[u[i]].push_back(v[i]);
arr[v[i]].push_back(u[i]);
mp[{u[i],v[i]}]=i;
}
auto getindex = [&](pair<int,int> pr){
if (mp.count(pr)) return mp[pr];
swap(pr.first,pr.second);
return mp[pr];
};
vector<int> par(n);
vector<bool> vis(n,false);
set<int> askarr;
vector<int> dept(n);
vector<int> origset;
auto dfs = [&](int node, auto dfs)->void{
vis[node]=true;
for (int i = 0; i < arr[node].size(); i++){
if (vis[arr[node][i]]) continue;
par[arr[node][i]]=node;
dept[arr[node][i]]=dept[node]+1;
askarr.insert(getindex({node,arr[node][i]}));
origset.push_back(getindex({node,arr[node][i]}));
dfs(arr[node][i],dfs);
}
};
dept[0]=0;
dfs(0,dfs);
int origans = ask(askarr);
vector<int> hueh(m,1);
for (int i = 0; i < m; i++){
if (askarr.find(i)!=askarr.end()) continue;
int a = u[i];
int b = v[i];
vector<int> yep;
vector<int> nop;
vector<int> idk;
int art=0, azal=0, kal=0;
bool yesb=false;
bool hehhehe = false;
while (a!=b){
if (dept[a]<dept[b]) swap(a,b);
if (hueh[getindex({a,par[a]})]!=1){
askarr.erase(getindex({a,par[a]}));
askarr.insert(i);
int crnum = ask(askarr);
if (crnum>origans){
yesb=true;
}
else if (crnum<origans){
yesb=false;
}
else {
yesb=(hueh[getindex({a,par[a]})]);
}
askarr.erase(i);
askarr.insert(getindex({a,par[a]}));
break;
}
a=par[a];
}
a=u[i],b=v[i];
if (hehhehe){
while (a!=b){
if (dept[a]<dept[b]) swap(a,b);
if (hueh[getindex({a,par[a]})]==1){
askarr.erase(getindex({a,par[a]}));
askarr.insert(i);
int crnum = ask(askarr);
if (crnum>origans){
hueh[getindex({a,par[a]})]=0;
}
else if (crnum<origans){
hueh[getindex({a,par[a]})]=2;
}
else {
hueh[getindex({a,par[a]})]=yesb*2;
}
askarr.erase(i);
askarr.insert(getindex({a,par[a]}));
}
a=par[a];
}
continue;
}
while (a!=b){
if (dept[a]<dept[b]) swap(b,a);
askarr.erase(getindex({a,par[a]}));
askarr.insert(i);
int crnum = ask(askarr);
if (crnum>origans){
nop.push_back(getindex({a,par[a]}));
yesb=true;
}
else if (crnum<origans){
yep.push_back(getindex({a,par[a]}));
}
else {
idk.push_back(getindex({a,par[a]}));
}
askarr.erase(i);
askarr.insert(getindex({a,par[a]}));
a=par[a];
}
if (yesb==true){
while (idk.size()){
yep.push_back(idk.back());
idk.pop_back();
}
}
else {
while (idk.size()){
nop.push_back(idk.back());
idk.pop_back();
}
}
if (yesb) hueh[i]=2;
else hueh[i]=0;
while (nop.size()){
hueh[nop.back()]=0;
nop.pop_back();
}
while (yep.size()){
hueh[yep.back()]=2;
yep.pop_back();
}
}
vector<int> final;
for (int i = 0; i < m; i++){
if (hueh[i]!=0) final.push_back(i);
}
//coutarr(final);
return final;
}//wa?
Compilation message
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:58:11: warning: unused variable 'art' [-Wunused-variable]
58 | int art=0, azal=0, kal=0;
| ^~~
simurgh.cpp:58:18: warning: unused variable 'azal' [-Wunused-variable]
58 | int art=0, azal=0, kal=0;
| ^~~~
simurgh.cpp:58:26: warning: unused variable 'kal' [-Wunused-variable]
58 | int art=0, azal=0, kal=0;
| ^~~
simurgh.cpp: In instantiation of 'find_roads(int, std::vector<int>, std::vector<int>)::<lambda(int, auto:23)> [with auto:23 = find_roads(int, std::vector<int>, std::vector<int>)::<lambda(int, auto:23)>]':
simurgh.cpp:48:15: required from here
simurgh.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = 0; i < arr[node].size(); i++){
| ~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
1 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
1 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
37 ms |
340 KB |
correct |
15 |
Correct |
35 ms |
340 KB |
correct |
16 |
Correct |
30 ms |
404 KB |
correct |
17 |
Correct |
29 ms |
388 KB |
correct |
18 |
Correct |
8 ms |
340 KB |
correct |
19 |
Correct |
29 ms |
340 KB |
correct |
20 |
Correct |
22 ms |
340 KB |
correct |
21 |
Correct |
28 ms |
400 KB |
correct |
22 |
Correct |
14 ms |
380 KB |
correct |
23 |
Correct |
9 ms |
340 KB |
correct |
24 |
Correct |
9 ms |
368 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
8 ms |
368 KB |
correct |
27 |
Correct |
8 ms |
340 KB |
correct |
28 |
Correct |
2 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
14 ms |
364 KB |
correct |
31 |
Correct |
15 ms |
368 KB |
correct |
32 |
Correct |
15 ms |
340 KB |
correct |
33 |
Correct |
16 ms |
364 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
1 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
37 ms |
340 KB |
correct |
15 |
Correct |
35 ms |
340 KB |
correct |
16 |
Correct |
30 ms |
404 KB |
correct |
17 |
Correct |
29 ms |
388 KB |
correct |
18 |
Correct |
8 ms |
340 KB |
correct |
19 |
Correct |
29 ms |
340 KB |
correct |
20 |
Correct |
22 ms |
340 KB |
correct |
21 |
Correct |
28 ms |
400 KB |
correct |
22 |
Correct |
14 ms |
380 KB |
correct |
23 |
Correct |
9 ms |
340 KB |
correct |
24 |
Correct |
9 ms |
368 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
8 ms |
368 KB |
correct |
27 |
Correct |
8 ms |
340 KB |
correct |
28 |
Correct |
2 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
14 ms |
364 KB |
correct |
31 |
Correct |
15 ms |
368 KB |
correct |
32 |
Correct |
15 ms |
340 KB |
correct |
33 |
Correct |
16 ms |
364 KB |
correct |
34 |
Incorrect |
139 ms |
3104 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Incorrect |
132 ms |
7960 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
1 ms |
212 KB |
correct |
9 |
Correct |
1 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
37 ms |
340 KB |
correct |
15 |
Correct |
35 ms |
340 KB |
correct |
16 |
Correct |
30 ms |
404 KB |
correct |
17 |
Correct |
29 ms |
388 KB |
correct |
18 |
Correct |
8 ms |
340 KB |
correct |
19 |
Correct |
29 ms |
340 KB |
correct |
20 |
Correct |
22 ms |
340 KB |
correct |
21 |
Correct |
28 ms |
400 KB |
correct |
22 |
Correct |
14 ms |
380 KB |
correct |
23 |
Correct |
9 ms |
340 KB |
correct |
24 |
Correct |
9 ms |
368 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
8 ms |
368 KB |
correct |
27 |
Correct |
8 ms |
340 KB |
correct |
28 |
Correct |
2 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
14 ms |
364 KB |
correct |
31 |
Correct |
15 ms |
368 KB |
correct |
32 |
Correct |
15 ms |
340 KB |
correct |
33 |
Correct |
16 ms |
364 KB |
correct |
34 |
Incorrect |
139 ms |
3104 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |