QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711358 | #9521. Giving Directions in Harbin | xyz123# | WA | 12ms | 22400kb | C++23 | 2.3kb | 2024-11-05 09:51:39 | 2024-11-05 09:51:40 |
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=1;bg='N';
l[1]=p{1,0};
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 12ms
memory: 22324kb
input:
1 2 S 2 E 1
output:
3 S Z 2 L Z 1
result:
ok ok (1 test case)
Test #2:
score: -100
Wrong Answer
time: 12ms
memory: 22400kb
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 1 N L 3 N Z 14 R Z 12 3 N Z 7 L Z 1 1 N L 1 N L 3 N Z 18 L Z 1 1 N L 1 N L 1 N L 1 N L 3 S Z 3 L Z 9 1 W Z 10 1 N L 3 S Z 16 R Z 9 3 N Z 4 L Z 3 3 S Z 7 L Z 5 1 N L 1 N L 3 S Z 12 L Z 3 1 N L 3 S Z 9 R Z 6 1 N L 3 S Z 8 L Z 8 3 S Z 8 R Z 4 1 N L 1 N L 1 N L 3 N Z 5 R Z 9 1 N L 1 N Z 10...
result:
wrong answer Should start with `Z` (test case 2)