# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1020595 |
2024-07-12T07:22:30 Z |
vjudge1 |
Flood (IOI07_flood) |
C++17 |
|
162 ms |
59988 KB |
#include<bits/stdc++.h>
using namespace std;
int X[100100],Y[100100],lev[400100],side[100100][4][2],Xof[400100],N[800100],E;
bitset<400100>vis;
bitset<800100>C;
vector<int> adj[400100];
void AE(int a,int b,int c){
N[++E]=a+b,C[E]=c;
adj[a].push_back(E);
adj[b].push_back(E);
}
set<pair<int,int>>st;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n,w;
cin>>n;
for(int i=1;i<=n;i++)
cin>>X[i]>>Y[i];
cin>>w;
for(int i=1;i<=w;i++){
int a,b;
cin>>a>>b;
if(X[a]==X[b]){
if(Y[a]>Y[b])swap(a,b);
side[a][2][1]=i;
side[a][2][0]=i+w;
side[b][0][0]=i;
side[b][0][1]=i+w;
Xof[i]=X[a];
st.insert({Xof[i],i});
} else {
if(X[a]>X[b])swap(a,b);
side[a][1][0]=i;
side[a][1][1]=i+w;
side[b][3][1]=i;
side[b][3][0]=i+w;
Xof[i]=1e9;
}
AE(i,i+w,1);
}
for(int i=1;i<=n;i++)
for(int j=0;j<4;j++) if(side[i][j][1])
for(int k=(j+1)%4;;k=(k+1)%4) if(side[i][k][0]){
AE(side[i][k][0],side[i][j][1],0);break;}
delete side;
delete X;
delete Y;
deque<int>Q;
memset(lev,7,sizeof lev);
while(1){
if(st.empty())break;
int K=st.begin()->second;
Q.push_back(K);
lev[K]=0;
while(Q.size()){
int x=Q.front();Q.pop_front();
if(vis[x])continue;
if(x<=w)st.erase({Xof[x],x});
vis[x]=1;
for(auto y:adj[x])
if(lev[N[y]-x]>lev[x]+C[y]) if(C[y])
Q.push_back(N[y]-x),lev[N[y]-x]=lev[x]+1;
else Q.push_front(N[y]-x),lev[N[y]-x]=lev[x];
adj[x].clear();
}
}
vector<int>v;
for(int i=1;i<=w;i++)
if(lev[i]==lev[i+w])
v.push_back(i);
cout<<v.size()<<'\n';
for(auto i:v)
cout<<i<<'\n';
}
Compilation message
flood.cpp: In function 'int main()':
flood.cpp:45:12: warning: deleting array 'side'
45 | delete side;
| ^~~~
flood.cpp:46:12: warning: deleting array 'X'
46 | delete X;
| ^
flood.cpp:47:12: warning: deleting array 'Y'
47 | delete Y;
| ^
flood.cpp:62:19: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
62 | if(lev[N[y]-x]>lev[x]+C[y]) if(C[y])
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
19548 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
19548 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
19548 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
19548 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
19544 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
19544 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
19800 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
19688 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
19804 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
26468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
58 ms |
45140 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
63 ms |
47632 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
103 ms |
55236 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
162 ms |
59988 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |