QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711360 | #9521. Giving Directions in Harbin | xyz123# | AC ✓ | 18ms | 24408kb | C++23 | 2.4kb | 2024-11-05 09:54:13 | 2024-11-05 09:54:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001],cn1,cn2,st1[1000001],st2[1000001];
char s[1000001],bg,ls;
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
char t[4];
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
T=1;
t[0]='N';
t[1]='E';
t[2]='S';
t[3]='W';
scanf("%lld",&T);
for(int ii=1;ii<=T;ii++)
{
scanf("%lld",&a);
cn=0;
long long t1=0,t2=0;
for(int i=1;i<=a;i++)
{
scanf("%s",s+1);
scanf("%lld",&q);
if(s[1]=='N') t1+=q;
else if(s[1]=='S') t1-=q;
else if(s[1]=='E') t2+=q;
else t2-=q;
}
if(t1==0)
{
if(t2==0)
{
cn=7;bg='N';
l[1]=p{0,1};
l[2]=p{1,0};
l[3]=p{0,1};
l[4]=p{1,0};
l[5]=p{0,1};
l[6]=p{1,0};
l[7]=p{0,1};
}
else
{
cn=1;
if(t2>0) l[1]=p{0,t2},bg='E';
else l[1]=p{0,-t2},bg='W';
}
}
else if(t2==0)
{
cn=1;
if(t1>0)
{
l[1]=p{0,t1},bg='N';
}
else l[1]=p{0,-t1},bg='S';
}
else
{
cn=3;
if(t1>0) l[1]=p{0,t1},bg='N';
else l[1]=p{0,-t1},bg='S';
if(t1>0)
{
if(t2>0) l[2]=p{2,0};
else l[2]=p{1,0};
}
else
{
if(t2>0) l[2]=p{1,0};
else l[2]=p{2,0};
}
l[3]=p{0,abs(t2)};
}
printf("%lld ",cn);
cout<<bg<<"\n";
for(int i=1;i<=cn;i++)
{
if(l[i].q==0)
{
printf("Z %lld\n",l[i].w);
}
else if(l[i].q==1)
{
printf("L\n");
}
else printf("R\n");
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 22380kb
input:
1 2 S 2 E 1
output:
3 S Z 2 L Z 1
result:
ok ok (1 test case)
Test #2:
score: 0
Accepted
time: 8ms
memory: 22252kb
input:
99 4 E 6 N 1 W 2 S 8 8 W 10 N 1 E 10 S 2 E 2 N 2 W 2 S 1 9 N 5 E 4 N 7 E 6 S 9 E 8 N 4 W 6 N 7 6 N 6 E 6 N 8 W 9 S 7 E 2 8 E 6 S 9 W 5 S 4 W 6 N 4 E 5 N 9 8 N 6 W 10 N 6 W 6 S 6 E 6 S 6 E 10 10 N 7 W 3 N 5 W 5 S 8 W 10 N 6 E 9 N 8 E 8 8 W 9 N 10 E 6 S 10 E 9 S 10 W 6 N 10 4 W 5 N 1 E 5 S 1 4 W 4 S 8...
output:
3 S Z 7 L Z 4 7 N Z 1 L Z 1 L Z 1 L Z 1 3 N Z 14 R Z 12 3 N Z 7 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 3 N Z 18 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 7 N Z 1 L Z 1 L Z 1 L Z 1 3 S Z 3 L Z 9 1 W Z 10 7 N Z 1 L Z 1 L Z 1 L Z 1 3 S Z 16 R...
result:
ok ok (99 test cases)
Test #3:
score: 0
Accepted
time: 18ms
memory: 24408kb
input:
10000 1 W 9 1 N 3 10 W 10 N 7 W 5 S 9 W 9 S 8 E 9 S 6 E 5 S 5 2 E 8 S 10 2 N 7 W 5 5 S 4 W 3 S 7 E 4 N 7 8 N 7 E 8 N 3 E 9 S 5 W 5 S 9 W 10 9 W 9 S 6 E 6 N 8 W 5 N 6 W 3 N 8 W 7 3 S 9 W 2 N 10 5 N 6 E 4 N 6 E 10 N 1 10 S 7 W 4 N 3 E 5 S 7 W 8 N 2 E 8 N 4 W 8 8 S 9 W 1 N 4 E 6 N 1 W 8 N 6 W 6 4 W 10 ...
output:
1 W Z 9 1 N Z 3 3 S Z 21 R Z 10 3 S Z 10 L Z 8 3 N Z 7 L Z 5 3 S Z 4 L Z 1 3 S Z 4 L Z 2 3 N Z 16 L Z 18 3 N Z 1 L Z 2 3 N Z 13 R Z 14 3 S Z 5 R Z 7 3 N Z 2 L Z 9 3 N Z 13 L Z 4 3 S Z 29 R Z 12 3 N Z 2 R Z 11 3 N Z 1 R Z 21 3 N Z 7 R Z 5 3 S Z 9 R Z 16 1 S Z 7 3 S Z 9 L Z 5 1 N Z 10 3 N Z 9 R Z 5 3 ...
result:
ok ok (10000 test cases)
Extra Test:
score: 0
Extra Test Passed