QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697483 | #9521. Giving Directions in Harbin | jimmyywang# | WA | 0ms | 3620kb | C++14 | 1.0kb | 2024-11-01 14:20:19 | 2024-11-01 14:20:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
ll rd(){
ll x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
#define d rd()
ll T,n;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
map<char,ll>mp;
char f[1000010];
char res[100010];
ll t[100010];
int main(){
mp['E']=0;mp['S']=1,mp['W']=2,mp['N']=3;
T=d;while(T--){
n=d;ll m=0;char C;
f(i,1,n){
cin>>f[i];ll x=d;
if(i==1){C=f[1],res[++m]='Z',t[m]=x;continue;}
else{
ll o=mp[f[i-1]],p=mp[f[i]];
while(1){
if(o==p)break;
o=(o+1)%4;
res[++m]='R';
}
res[++m]='Z',t[m]=x;
}
}cout<<m<<" "<<C<<endl;
f(i,1,m){
if(res[i]=='R')cout<<'R'<<endl;
else cout<<"Z"<<" "<<t[i]<<endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
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)