QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711347 | #9521. Giving Directions in Harbin | xyz123# | WA | 11ms | 22380kb | C++23 | 2.0kb | 2024-11-05 09:42:05 | 2024-11-05 09:42:06 |
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;
for(int i=1;i<=a;i++)
{
scanf("%s",s+1);
scanf("%lld",&q);
if(i==1)
{
bg=s[1];
ls=s[1];
l[++cn]=p{0,q};
}
else
{
while(ls!=s[1])
{
int tt=0;
for(int j=0;j<4;j++)
{
if(ls==t[j])
{
tt=j;
}
}
tt++,tt%=4;
l[++cn]=p{2,0};
ls=t[tt];
}
l[++cn]=p{0,q};
}
}
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: 0
Wrong Answer
time: 11ms
memory: 22380kb
input:
1 2 S 2 E 1
output:
5 S Z 2 R R R Z 1
result:
wrong answer Same direction appears twice (test case 1)