QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#700295 | #9521. Giving Directions in Harbin | CCSU_YZT# | WA | 0ms | 3672kb | C++20 | 1.1kb | 2024-11-02 12:39:57 | 2024-11-02 12:39:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
int n;
cin>>n;
int x = 0, y = 0;
for (int i = 1; i <= n; i++) {
char ch;
int num = 0;
cin>>ch>>num;
if (ch == 'N') {
x -= num;
} else if (ch == 'S') {
x += num;
} else if (ch == 'W') {
y -= num;
} else {
y += num;
}
}
int ans = min(1, abs(x)) + 1 + min(1, abs(y)) + 6;
cout<<ans<<' ';
if (x <= 0) cout<<"N"<<'\n';
else cout<<"S"<<'\n';
if (x) cout<<"Z"<<' '<<abs(x)<<'\n';
cout<<"Z"<<' '<<1<<'\n';
cout<<"L"<<'\n';
cout<<"L"<<'\n';
cout<<"Z"<<' '<<1<<'\n';
cout<<"L"<<'\n';
cout<<"L"<<'\n';
if (y <= 0) {
if (x <= 0) cout<<"L"<<'\n';
else cout<<"R"<<'\n';
}
else {
if (x <= 0) cout<<"R"<<'\n';
else cout<<"L"<<'\n';
}
if (y) cout<<"Z"<<' '<<abs(y)<<'\n';
}
int main()
{
if (ifstream("test.in")) {
freopen("test.in", "r", stdin);
// freopen("test.out", "w", stdout);
}
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
cin>>T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
input:
1 2 S 2 E 1
output:
9 S Z 2 Z 1 L L Z 1 L L L Z 1
result:
wrong answer Same direction appears twice (test case 1)