QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780509#9521. Giving Directions in Harbinucup-team093#WA 0ms3632kbC++202.1kb2024-11-25 11:19:012024-11-25 11:19:02

Judging History

你现在查看的是最新测评结果

  • [2024-11-25 11:19:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-11-25 11:19:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using pci = pair<char, int>;

void solve() {
    int n, x = 0, y = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        char c;
        int d;
        cin >> c >> d;
        if(c == 'N') y += d;
        else if(c == 'S') y -= d;
        else if(c == 'W') x -= d;
        else if(c == 'E') x += d;
    }
    if(x == 0 && y == 0) {
        cout << "8 E\n";
        for(int i : {0, 0, 0, 1}) {
            cout << "Z 1\n";
            if(!i) cout << "R\n";
        }
        return;
    }
    if(x <= 0) {
        vector<pci> v;
        while(x < 0) {
            v.emplace_back('Z', min(-x, 100));
            x += min(-x, 100);
        }
        if(y < 0) {
            v.emplace_back('L', 0);
            while(y < 0) {
                v.emplace_back('Z', min(-y, 100));
                y += min(-y, 100);
            }
        }
        if(y > 0) {
            v.emplace_back('R', 0);
            while(y > 0) {
                v.emplace_back('Z', min(y, 100));
                y -= min(y, 100);
            }
        }
        cout << v.size() << " W\n";
        for(auto &[a, b] : v) {
            cout << a;
            if(a == 'Z') cout << " " << b;
            cout << "\n";
        }
    }else{
        vector<pci> v;
        while(x > 0) {
            v.emplace_back('Z', min(x, 100));
            x -= min(x, 100);
        }
        if(y < 0) {
            v.emplace_back('R', 0);
            while(y < 0) {
                v.emplace_back('Z', min(-y, 100));
                y += min(-y, 100);
            }
        }
        if(y > 0) {
            v.emplace_back('L', 0);
            while(y > 0) {
                v.emplace_back('Z', min(y, 100));
                y -= min(y, 100);
            }
        }
        cout << v.size() << " E\n";
        for(auto &[a, b] : v) {
            cout << a;
            if(a == 'Z') cout << " " << b;
            cout << "\n";
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;
    while(T --) {
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

1
2
S 2
E 1

output:

3 E
Z 1
R
Z 2

result:

ok ok (1 test case)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

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 E
Z 4
R
Z 7
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 12
L
Z 14
3 W
Z 1
R
Z 7
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 W
Z 1
R
Z 18
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 9
R
Z 3
1 W
Z 10
8 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 W
Z 9
L
...

result:

wrong answer Token parameter [name=g] equals to "3", doesn't correspond to pattern "[ZLR]" (test case 2)