QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754425 | #9521. Giving Directions in Harbin | ANIG# | WA | 0ms | 3764kb | C++14 | 1.3kb | 2024-11-16 15:00:17 | 2024-11-16 15:00:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mov[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int t,n;
signed main(){
cin>>t;
while(t--){
cin>>n;
int x=0,y=0;
for(int i=1;i<=n;i++){
char c;int xx,op;
cin>>c>>xx;
if(c=='E')op=0;
if(c=='W')op=1;
if(c=='S')op=2;
if(c=='N')op=3;
x+=xx*mov[op][0];
y+=xx*mov[op][1];
}
vector<pair<char,int> >rs;
char cs;
if(x<=0){
cs='N';
if(x)rs.push_back({'Z',-x});
if(y<0){
rs.push_back({'L',0});
rs.push_back({'Z',-y});
}else if(y>0){
rs.push_back({'R',0});
rs.push_back({'Z',y});
}
}else{
cs='S';
if(x)rs.push_back({'Z',x});
if(y<0){
rs.push_back({'R',0});
rs.push_back({'Z',-y});
}else if(y>0){
rs.push_back({'L',0});
rs.push_back({'Z',y});
}
}
cout<<rs.size()<<" "<<cs<<"\n";
for(auto c:rs){
if(c.second)cout<<c.first<<" "<<c.second<<"\n";
else cout<<c.first<<"\n";
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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: 0ms
memory: 3764kb
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 0 N 3 N Z 14 R Z 12 3 N Z 7 L Z 1 0 N 0 N 3 N Z 18 L Z 1 0 N 0 N 0 N 0 N 3 S Z 3 L Z 9 2 N L Z 10 0 N 3 S Z 16 R Z 9 3 N Z 4 L Z 3 3 S Z 7 L Z 5 0 N 0 N 3 S Z 12 L Z 3 0 N 3 S Z 9 R Z 6 0 N 3 S Z 8 L Z 8 3 S Z 8 R Z 4 0 N 0 N 0 N 3 N Z 5 R Z 9 0 N 1 N Z 10 0 N 0 N 3 S Z 5 R Z 2 3 S Z 1...
result:
wrong answer Integer parameter [name=m] equals to 0, violates the range [1, 20] (test case 2)