QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#884406 | #9521. Giving Directions in Harbin | 1903331632 | WA | 1ms | 3712kb | C++23 | 2.0kb | 2025-02-06 03:53:13 | 2025-02-06 03:53:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10;
#define pii pair<int, int>
#define lowbit(x) (x & (-x))
const int mod = 1e9 + 7;
void solve()
{
int n;
cin >> n;
int x = 0, y = 0;
for (int i = 0; i < n; i++)
{
char c;
int d;
cin >> c >> d;
if (c == 'W')
y -= d;
if (c == 'E')
y += d;
if (c == 'N')
x -= d;
if (c == 'S')
x += d;
}
if (x == 0)
{
if (y > 0)
{
cout << "1 E" << endl;
cout << "Z " << y << endl;
}
else
{
cout << "1 W" << endl;
cout << "Z " << -y << endl;
}
}
else if (y == 0)
{
if (x > 0)
{
cout << "1 S" << endl;
cout << "Z " << x << endl;
}
else
{
cout << "1 N" << endl;
cout << "Z " << -x << endl;
}
}
else
{
if (x < 0)
{
cout << "3 N" << endl;
cout << "Z " << -x << endl;
if (y > 0)
{
cout << "R" << endl;
cout << "Z " << y << endl;
}
else
{
cout << "L" << endl;
cout << "Z " << -y << endl;
}
}
else
{
cout << "3 S" << endl;
cout << "Z " << x << endl;
if (y > 0)
{
cout << "L" << endl;
cout << "Z " << y << endl;
}
else
{
cout << "R" << endl;
cout << "Z " << -y << endl;
}
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
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: 3584kb
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 1 W Z 0 3 N Z 14 R Z 12 3 N Z 7 L Z 1 1 W Z 0 1 W Z 0 3 N Z 18 L Z 1 1 W Z 0 1 W Z 0 1 W Z 0 1 W Z 0 3 S Z 3 L Z 9 1 W Z 10 1 W Z 0 3 S Z 16 R Z 9 3 N Z 4 L Z 3 3 S Z 7 L Z 5 1 W Z 0 1 W Z 0 3 S Z 12 L Z 3 1 W Z 0 3 S Z 9 R Z 6 1 W Z 0 3 S Z 8 L Z 8 3 S Z 8 R Z 4 1 W Z 0 1 W Z 0 1 W Z ...
result:
wrong answer Integer parameter [name=y] equals to 0, violates the range [1, 100] (test case 2)