QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697347 | #9521. Giving Directions in Harbin | wdw | WA | 0ms | 3812kb | C++20 | 1.9kb | 2024-11-01 13:26:17 | 2024-11-01 13:26:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define int long long
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
void solve() {
int x1 = 0, y1 = 0;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
char x;
int p;
cin >> x >> p;
if (x == 'S') {
x1 -= p;
} else if (x == 'N') {
x1 += p;
} else if (x == 'W') {
y1 -= p;
} else {
y1 += p;
}
}
char s = '1';
vector<pair<char, int>> ans;
if (x1 != 0) {
if (x1 > 0) {
s = 'N';
ans.push_back({s, -1});
} else if (x1 < 0) {
s = 'S';
ans.push_back({s, -1});
}
ans.push_back({'Z', abs(x1)});
}
if (y1 != 0) {
if (y1 > 0) {
if (s == '1') {
s = 'E';
ans.push_back({s, -1});
} else if (s == 'N') {
ans.push_back({'R', -1});
} else {
ans.push_back({'L', -1});
}
} else if (y1 < 0) {
if (s == '1') {
s = 'W';
ans.push_back({s, -1});
} else if (s == 'N') {
ans.push_back({'L', -1});
} else {
ans.push_back({'R', -1});
}
}
ans.push_back({'Z', abs(y1)});
}
int w1 = ans.size() - 1;
cout << max(w1, 0ll) << " ";
for (int i = 0; i < ans.size(); i++) {
cout << ans[i].first << " ";
if (ans[i].second != -1) {
cout << ans[i].second;
}
cout << "\n";
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
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: 3812kb
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 3 N Z 14 R Z 12 3 N Z 7 L Z 1 0 0 3 N Z 18 L Z 1 0 0 0 0 3 S Z 3 L Z 9 1 W Z 10 0 3 S Z 16 R Z 9 3 N Z 4 L Z 3 3 S Z 7 L Z 5 0 0 3 S Z 12 L Z 3 0 3 S Z 9 R Z 6 0 3 S Z 8 L Z 8 3 S Z 8 R Z 4 0 0 0 3 N Z 5 R Z 9 0 1 N Z 10 0 0 3 S Z 5 R Z 2 3 S Z 10 L Z ...
result:
wrong answer Integer parameter [name=m] equals to 0, violates the range [1, 20] (test case 2)