QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#697761 | #9521. Giving Directions in Harbin | zzisjtu | WA | 1ms | 3880kb | C++23 | 1.0kb | 2024-11-01 15:39:10 | 2024-11-01 15:39:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node {
char x, y;
};
void solve() {
int n;
cin >> n;
vector<node> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
// cout << a[i].x << " " << a[i].y << endl;
}
char c = a[1].x;
auto b = c;
map<char, int>mp;
mp['N'] = 1;mp['S'] = 3;
mp['W'] = 4;mp['E'] = 2;
vector<pair<char, char>> ans;
ans.push_back({'Z', a[1].y});
// cout << a[1].y << endl;
for(int i = 2; i <= n; i++) {
if(mp[a[i].x] > mp[c]) {
int t = mp[a[i].x] - mp[c];
while(t--) {
ans.push_back({'R', ' '});
}
}
else if(mp[a[i].x] < mp[c]) {
int t = mp[a[i].x] - mp[c];
t = -t;
while(t--) {
ans.push_back({'L', ' '});
}
}
ans.push_back({'Z', a[i].y});
c = a[i].x;
}
cout << ans.size() << " " << b << endl;
for(auto [x, y]: ans) {
cout << x << " " << y << endl;
}
}
#undef int
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3880kb
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: 3580kb
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:
9 E Z 6 L Z 1 R R R Z 2 L Z 8 20 W Z 1 L L L L Z N Z E Z 0 R R R Z 2 L Z 2 L Z 2 R R R Z 2 1
result:
wrong answer Same direction appears twice (test case 1)