#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define X first
#define Y second
int n,m,x[100005],y[100005],wall1,wall2,a1,b1,a2,b2,go[100005][4],st,d[100005];
int nxt[100005][4],p[100005],rev[100005],num,val;
//right=0 down=1 left 2 up=3
vector<pair<pair<int,int>,int > > v;
vector<int> g;
set<int> s;
void dfs(int u,int dir)
{
/*printf("%d\n",u);
for(int i=1;i<=n;i++)
printf("%d ",d[i]);
printf("\n");
for(auto it:s)printf("%d ",it);
printf("\n");*/
for(int i=0;i<4;i++)
{
int way=(dir+2+i)%4;
if(go[u][way]!=0&&go[u][way]!=p[u])
{
int bug=d[go[u][way]];
if(bug!=1)
{
if(bug==-1)
{
d[go[u][way]]=0;
g.pb(go[u][way]);
p[go[u][way]]=u;
rev[go[u][way]]=nxt[u][way];
dfs(go[u][way],way);
}else if(bug==0)
{
s.erase(nxt[u][way]);
num=u;
//printf("%d\n",u);
while(1)
{
if(num==go[u][way]||num==0)
{
if(num!=0)d[num]=1;
break;
}
s.erase(rev[num]);
d[num]=1;
//printf("%d ",rev[num]);
int con=p[num];
p[num]=0;
num=con;
}
//printf("\n");
}
}
}
}
d[u]=1;
}
int main()
{
memset(d,-1,sizeof d);
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&x[i],&y[i]);
v.pb({{x[i],y[i]},i});
}
scanf("%d",&m);
for(int i=1;i<=m;i++)
{
s.insert(i);
scanf("%d%d",&wall1,&wall2);
a1=x[wall1];
b1=y[wall1];
a2=x[wall2];
b2=y[wall2];
if(a1>a2)
{
swap(a1,a2);
swap(wall1,wall2);
}
if(a1<a2)
{
go[wall1][1]=wall2;
go[wall2][3]=wall1;
nxt[wall1][1]=i;
nxt[wall2][3]=i;
}
if(b1>b2)
{
swap(b1,b2);
swap(wall1,wall2);
}
if(b1<b2)
{
go[wall1][0]=wall2;
go[wall2][2]=wall1;
nxt[wall1][0]=i;
nxt[wall2][2]=i;
}
}
sort(v.begin(),v.end());
for(int i=0;i<(int)v.size();i++)
{
st=v[i].Y;
//printf("%d\n",i);
if(d[st]==-1)
{
val=0;
d[st]=0;
g.pb(st);
dfs(st,2);
for(int j=0;j<(int)g.size();j++)
{
d[g[j]]=1;
}
g.clear();
/*for(auto it:s)
{
printf("%d ",it);
}
printf("\n");*/
}
}
printf("%d\n",(int)s.size());
for(auto it:s)printf("%d\n",it);
}
Compilation message
flood.cpp: In function 'int main()':
flood.cpp:64:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
64 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
flood.cpp:67:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | scanf("%d%d",&x[i],&y[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
flood.cpp:70:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
70 | scanf("%d",&m);
| ~~~~~^~~~~~~~~
flood.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
74 | scanf("%d%d",&wall1,&wall2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
2 |
Incorrect |
1 ms |
704 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
2 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
708 KB |
Output is correct |
2 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
11652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
98 ms |
10244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
153 ms |
15848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
201 ms |
20128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |