Submission #60990988
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+10;
int n,m,i,j,b[N<<2],k,c,sx[N],sy[N],tx[N],ty[N],x,y,ans,ma[N],px,py;
struct Node{
int x,y;
}a[N];
bool cmp(Node o,Node p){return o.y<p.y||(o.y==p.y&&o.x<p.x);}
vector<Node> Gx[N<<2],Gy[N<<2];
vector<int> mx[N<<2],my[N<<2];
char op[2];
bool check1(int x,int y)
{
int i,l,r,mid;
if (Gx[x].size()==0) return false;
l=0;
r=(int)Gx[x].size()-1;
while (l<=r)
{
mid=l+r>>1;
if (Gx[x][mid].y>=x) r=mid-1;
else l=mid+1;
}
return mx[x][l]<=y;
}
bool check2(int x,int y)
{
int i,l,r,mid;
if (Gy[x].size()==0) return false;
l=0;
r=(int)Gy[x].size()-1;
while (l<=r)
{
mid=l+r>>1;
if (Gy[x][mid].y>=x) r=mid-1;
else l=mid+1;
}
return my[x][l]<=y;
}
signed main()
{
scanf("%lld%lld%lld%lld",&n,&m,&x,&y);
for (i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y),b[++k]=a[i].x,b[++k]=a[i].y;
for (i=1;i<=m;i++)
{
sx[i]=x;
sy[i]=y;
b[++k]=x;
b[++k]=y;
scanf("%s%lld",op,&c);
if (op[0]=='U') y+=c;
else if (op[0]=='D') y-=c;
else if (op[0]=='L') x-=c;
else x+=c;
tx[i]=x;
ty[i]=y;
px=x;
py=y;
b[++k]=x;
b[++k]=y;
}
sort(b+1,b+k+1);
k=unique(b+1,b+k+1)-b-1;
for (i=1;i<=n;i++)
{
a[i].x=lower_bound(b+1,b+k+1,a[i].x)-b;
a[i].y=lower_bound(b+1,b+k+1,a[i].y)-b;
}
for (i=1;i<=m;i++)
{
sx[i]=lower_bound(b+1,b+k+1,sx[i])-b;
sy[i]=lower_bound(b+1,b+k+1,sy[i])-b;
tx[i]=lower_bound(b+1,b+k+1,tx[i])-b;
ty[i]=lower_bound(b+1,b+k+1,ty[i])-b;
if (sx[i]==tx[i]) Gx[sx[i]].push_back({min(sy[i],ty[i]),max(sy[i],ty[i])});
else Gy[sy[i]].push_back({min(sx[i],tx[i]),max(sx[i],tx[i])});
}
for (i=1;i<=n*2+m*2;i++)
{
sort(Gx[i].begin(),Gx[i].end(),cmp);
sort(Gy[i].begin(),Gy[i].end(),cmp);
if (Gx[i].size()>0)
{
ma[(int)Gx[i].size()-1]=Gx[i][(int)Gx[i].size()-1].x;
for (j=(int)Gx[i].size()-2;j>=0;j--) ma[j]=max(Gx[i][j].x,ma[j+1]);
for (j=0;j<=(int)Gx[i].size()-1;j++) mx[i].push_back(ma[j]);
}
if (Gy[i].size()>0)
{
ma[(int)Gy[i].size()-1]=Gy[i][(int)Gy[i].size()-1].x;
for (j=(int)Gy[i].size()-2;j>=0;j--) ma[j]=max(Gy[i][j].x,ma[j+1]);
for (j=0;j<=(int)Gy[i].size()-1;j++) my[i].push_back(ma[j]);
}
}
for (i=1;i<=n;i++)
{
if (check1(a[i].x,a[i].y)||check2(a[i].y,a[i].x)) ans++;
}
printf("%lld %lld %lld",px,py,ans);
return 0;
}
Submission Info
Submission Time
2024-12-21 22:38:47+0900
Task
D - Santa Claus 2
User
GUO120822
Language
C++ 23 (Clang 16.0.6)
Score
0
Code Size
2422 Byte
Status
RE
Exec Time
268 ms
Memory
39188 KiB
Compile Error
./Main.cpp:21:8: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
mid=l+r>>1;
~^~~~
./Main.cpp:21:8: note: place parentheses around the '+' expression to silence this warning
mid=l+r>>1;
^
( )
./Main.cpp:15:6: warning: unused variable 'i' [-Wunused-variable]
int i,l,r,mid;
^
./Main.cpp:35:8: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
mid=l+r>>1;
~^~~~
./Main.cpp:35:8: note: place parentheses around the '+' expression to silence this warning
mid=l+r>>1;
^
( )
./Main.cpp:29:6: warning: unused variable 'i' [-Wunused-variable]
int i,l,r,mid;
^
4 warnings generated.
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
0 / 425
Status
Set Name
Test Cases
Sample
sample_01.txt, sample_02.txt
All
hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
Case Name
Status
Exec Time
Memory
hand.txt
AC
15 ms
3868 KiB
random_01.txt
AC
110 ms
24244 KiB
random_02.txt
WA
108 ms
24124 KiB
random_03.txt
AC
93 ms
24212 KiB
random_04.txt
AC
88 ms
10028 KiB
random_05.txt
WA
88 ms
9940 KiB
random_06.txt
WA
130 ms
23412 KiB
random_07.txt
WA
83 ms
11412 KiB
random_08.txt
AC
186 ms
36140 KiB
random_09.txt
RE
268 ms
15832 KiB
random_10.txt
AC
156 ms
39188 KiB
random_11.txt
WA
132 ms
14912 KiB
random_12.txt
RE
199 ms
17304 KiB
random_13.txt
WA
98 ms
10380 KiB
random_14.txt
WA
94 ms
20960 KiB
random_15.txt
RE
196 ms
17384 KiB
random_16.txt
RE
212 ms
18764 KiB
random_17.txt
RE
199 ms
17792 KiB
random_18.txt
WA
92 ms
20432 KiB
random_19.txt
RE
199 ms
17868 KiB
random_20.txt
WA
117 ms
12104 KiB
random_21.txt
RE
189 ms
16676 KiB
random_22.txt
WA
115 ms
26360 KiB
sample_01.txt
AC
12 ms
3784 KiB
sample_02.txt
AC
12 ms
3768 KiB