QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754409 | #9521. Giving Directions in Harbin | ANIG# | WA | 1ms | 3604kb | C++14 | 1.3kb | 2024-11-16 14:58:43 | 2024-11-16 14:58:45 |
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{
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{
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";
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
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: 1ms
memory: 3604kb
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 2 N R Z 3 N Z 14 R Z 12 3 N Z 7 L Z 1 2 N R Z 2 N R Z 3 N Z 18 L Z 1 2 N R Z 2 N R Z 2 N R Z 2 N R Z 3 S Z 3 L Z 9 2 N L Z 10 2 N R Z 3 S Z 16 R Z 9 3 N Z 4 L Z 3 3 S Z 7 L Z 5 2 N R Z 2 N R Z 3 S Z 12 L Z 3 2 N R Z 3 S Z 9 R Z 6 2 N R Z 3 S Z 8 L Z 8 3 S Z 8 R Z 4 2 N R Z 2 N R Z 2 N ...
result:
wrong answer Should start with `Z` (test case 2)