Submission #60991406
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
struct jt{
int x,y,wz,z,zz,yz;
}pl1[200005],pl2[200005];
char d[200005];
int c[200005],zt[200005];
int cmp1(jt p1,jt p2){
return p1.x<p2.x||(p1.x==p2.x&&p1.y<p2.y);
}
int cmp2(jt p1,jt p2){
return p1.y<p2.y||(p1.y==p2.y&&p1.x<p2.x);
}
int cl(int n){
int fh=1;
for(;fh<n;fh*=2){}
return fh;
}
void xg1(int kl,int kr,int fwwz,long long dtwz,long long qdz,long long qdy){
if(pl1[kl].x==dtwz&&pl1[kl].y>=qdz&&pl1[kr].y<=qdy&&pl1[kr].x==dtwz){
pl1[fwwz].z++;
return ;
}
if(kl==kr)
return ;
int zj=(kl+kr)/2;
if(pl1[zj].x>dtwz||(pl1[zj].x==dtwz&&pl1[zj].y>=qdz))
xg1(kl,zj,pl1[fwwz].zz,dtwz,qdz,qdy);
if(pl1[zj].x<dtwz||(pl1[zj].x==dtwz&&pl1[zj].y<qdy))
xg1(zj+1,kr,pl1[fwwz].yz,dtwz,qdz,qdy);
return ;
}
void xg2(int kl,int kr,int fwwz,long long dtwz,long long qdz,long long qdy){
if(pl2[kl].y==dtwz&&pl2[kl].x>=qdz&&pl2[kr].x<=qdy&&pl2[kr].y==dtwz){
pl2[fwwz].z++;
return ;
}
if(kl==kr)
return ;
int zj=(kl+kr)/2;
if(pl2[zj].y>dtwz||(pl2[zj].y==dtwz&&pl2[zj].x>=qdz))
xg2(kl,zj,pl2[fwwz].zz,dtwz,qdz,qdy);
if(pl2[zj].y<dtwz||(pl2[zj].y==dtwz&&pl2[zj].x<qdy))
xg2(zj+1,kr,pl2[fwwz].yz,dtwz,qdz,qdy);
return ;
}
int cx1(int kl,int kr,int fwwz,int cz){
if(kl==kr)
return pl1[fwwz].z;
int zj=(kl+kr)/2;
if(zj<=cz)
return cx1(kl,zj,pl1[fwwz].zz,cz)+pl1[fwwz].z;
else
return cx1(zj+1,kr,pl1[fwwz].yz,cz)+pl1[fwwz].z;
}
int cx2(int kl,int kr,int fwwz,int cz){
if(kl==kr)
return pl2[fwwz].z;
int zj=(kl+kr)/2;
if(zj<=cz)
return cx2(kl,zj,pl2[fwwz].zz,cz)+pl2[fwwz].z;
else
return cx2(zj+1,kr,pl2[fwwz].yz,cz)+pl2[fwwz].z;
}
int main(){
int n,m,ans=0;
long long sx,sy;
scanf("%d%d%lld%lld",&n,&m,&sx,&sy);
for(int i=0;i<n;i++){
scanf("%d%d",&pl1[i].x,&pl1[i].y);
pl1[i].wz=i;
pl1[i].z=0;
pl2[i].x=pl1[i].x;
pl2[i].y=pl1[i].y;
pl2[i].wz=i;
pl2[i].z=0;
}
sort(pl1,pl1+n,cmp1);
sort(pl2,pl2+n,cmp2);
for(int i=n;i<cl(n);i++){
pl1[i].x=INT_MAX;
pl2[i].y=INT_MAX;
}
for(int i=cl(n),j=0;i>j+1;i++,j+=2){
pl1[i].z=0;
pl1[i].zz=j;
pl1[i].yz=j+1;
pl2[i].z=0;
pl2[i].zz=j;
pl2[i].yz=j+1;
}
for(int i=0;i<m;i++){
cin>>d[i]>>c[i];
if(d[i]=='L'){
xg1(0,cl(n)-1,cl(n)*2-2,sx,sy,sy+c[i]);
sy+=c[i];
}else if(d[i]=='U'){
xg2(0,cl(n)-1,cl(n)*2-2,sy,sx-c[i],sx);
sx-=c[i];
}else if(d[i]=='R'){
xg1(0,cl(n)-1,cl(n)*2-2,sx,sy-c[i],sy);
sy-=c[i];
}else{
xg2(0,cl(n)-1,cl(n)*2-2,sy,sx,sx+c[i]);
sx+=c[i];
}
}
for(int i=0;i<n;i++){
zt[pl1[i].wz]+=cx1(0,cl(n)-1,cl(n)*2-2,i);
zt[pl2[i].wz]+=cx2(0,cl(n)-1,cl(n)*2-2,i);
}
for(int i=0;i<n;i++)
ans+=min(zt[i],1);
printf("%lld %lld %d",sx,sy,ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Santa Claus 2 |
User |
miaorunhao2 |
Language |
C++ 20 (gcc 12.2) |
Score |
0 |
Code Size |
2779 Byte |
Status |
RE |
Exec Time |
172 ms |
Memory |
12872 KB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:68:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%d%d%lld%lld",&n,&m,&sx,&sy);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:70:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
70 | scanf("%d%d",&pl1[i].x,&pl1[i].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 |
WA |
1 ms |
3796 KB |
random_01.txt |
AC |
63 ms |
4780 KB |
random_02.txt |
WA |
63 ms |
4772 KB |
random_03.txt |
WA |
63 ms |
4776 KB |
random_04.txt |
RE |
156 ms |
12872 KB |
random_05.txt |
RE |
156 ms |
12804 KB |
random_06.txt |
WA |
82 ms |
10884 KB |
random_07.txt |
RE |
129 ms |
12808 KB |
random_08.txt |
RE |
147 ms |
12776 KB |
random_09.txt |
RE |
157 ms |
12756 KB |
random_10.txt |
WA |
77 ms |
10740 KB |
random_11.txt |
RE |
170 ms |
12760 KB |
random_12.txt |
RE |
171 ms |
12828 KB |
random_13.txt |
RE |
168 ms |
12808 KB |
random_14.txt |
RE |
151 ms |
12792 KB |
random_15.txt |
RE |
168 ms |
12828 KB |
random_16.txt |
RE |
171 ms |
12808 KB |
random_17.txt |
RE |
167 ms |
12800 KB |
random_18.txt |
RE |
151 ms |
12800 KB |
random_19.txt |
RE |
167 ms |
12780 KB |
random_20.txt |
RE |
171 ms |
12668 KB |
random_21.txt |
RE |
172 ms |
12748 KB |
random_22.txt |
RE |
151 ms |
12804 KB |
sample_01.txt |
WA |
1 ms |
3872 KB |
sample_02.txt |
WA |
1 ms |
3848 KB |