QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714021 | #9521. Giving Directions in Harbin | SMTTY | WA | 0ms | 3848kb | C++14 | 1.8kb | 2024-11-05 21:15:53 | 2024-11-05 21:15:53 |
Judging History
answer
// #include<iostream>
// #include<algorithm>
// #include<cstring>
// #include<map>
// using namespace std;
// typedef pair<char, char> PCC;
// map<PCC, char> turn;
// void solve(){
// int n, t, len;
// scanf("%d", &n);
// char last[2], now[2];
// printf("%d ", 2 * n - 1);
// n--;
// scanf("%s%d", last, &t);
// printf("%c\nZ %d\n", *last, t);
// while (n -- ){
// scanf("%s%d", now, &t);
// printf("%c\nZ %d\n", turn[{*last, *now}], t);
// }
// }
// int main(){
// turn[{'N', 'W'}] = 'L';
// turn[{'W', 'S'}] = 'L';
// turn[{'S', 'E'}] = 'L';
// turn[{'E', 'N'}] = 'L';
// turn[{'N', 'E'}] = 'R';
// turn[{'E', 'S'}] = 'R';
// turn[{'S', 'W'}] = 'R';
// turn[{'W', 'N'}] = 'R';
// int _;
// scanf("%d", &_);
// while (_ -- ) solve();
// }
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
typedef pair<char, char> PCC;
map<PCC, char> turn;
void solve(){
int n, t, len;
scanf("%d", &n);
int x = 0, y = 0, ans;
while (n -- ){
char s[2];
int t;
scanf("%s%d", s, &t);
if (*s == 'N') y += t;
else if (*s == 'S') y -= t;
else if (*s == 'E') x += t;
else x -= t;
}
if (x && y){
printf("3 %c\nZ %d\n", x > 0 ? 'E' : 'W', abs(x));
printf("Z %c\n", x * y > 0 ? 'L' : 'R');
printf("Z %d\n", abs(y));
return;
}
if (x != 0 || y != 0){
if (x == 0) printf("1 %c\nZ %d\n", y > 0 ? 'N' : 'S', abs(y));
else printf("1 %c\nZ %d\n", x > 0 ? 'E' : 'W', abs(x));
return;
}
puts("7 N\nZ 1\nL\nZ 1\nL\nZ 1\nL\nZ 1\n");
return;
}
int main(){
int _;
scanf("%d", &_);
while (_ -- ) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3848kb
input:
1 2 S 2 E 1
output:
3 E Z 1 Z R Z 2
result:
wrong answer Same direction appears twice (test case 1)