QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720559#9521. Giving Directions in Harbinzzfs#WA 0ms3500kbC++141.1kb2024-11-07 13:17:402024-11-07 13:17:41

Judging History

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

  • [2024-11-07 13:17:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-11-07 13:17:40]
  • 提交

answer

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

char a[] = {'E', 'S', 'W', 'N'};
void solve()
{
    int n;
    cin >> n;
    char dir = 0;
    list<pair<char, int>> res;

    unordered_map<char, int> mp;
    mp.insert({'E', 0});
    mp.insert({'S', 1});
    mp.insert({'W', 2});
    mp.insert({'N', 3});

    for (int i = 1; i <= n; i++)
    {
        char ch;
        int x;
        cin >> ch >> x;

        if (dir == 0)
        {
            res.push_back({ch, x});
            dir = ch;
        }
        else
        {
            if (a[(mp[ch] + 1 + 4) % 4] == ch)
            {
                res.push_back({'R', x});
            }
            else
            {
                res.push_back({'L', x});
            }
        }
    }

    cout << res.size() - 1 << ' ';

    for (auto [dir, x] : res)
    {
        cout << dir << '\n';
        cout << "Z " << x << '\n';
    }
}

signed main()
{
    cin.tie(0)->ios::sync_with_stdio(false);

    int t = 1;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3500kb

input:

1
2
S 2
E 1

output:

1 S
Z 2
L
Z 1

result:

wrong answer Wrong destination (test case 1)