QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717598#9521. Giving Directions in Harbin20225954#WA 0ms3532kbC++141.1kb2024-11-06 18:27:192024-11-06 18:27:19

Judging History

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

  • [2024-11-06 18:27:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-11-06 18:27:19]
  • 提交

answer

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

#define ll long long

map<pair<char,char>,char> m;

void solve(){
    int n;
    cin>>n;
    vector<pair<char,int>> v;
    char dir='S';
    for(int i=1;i<=n;i++){
        char c;
        int num;
        cin>>c>>num;
        if(c==dir){
            v.push_back({'Z',num});
        }
        else{
            v.push_back({m[{dir,c}],0});
            dir=c;
            v.push_back({'Z',num});
        }
    }
    cout<<v.size()<<" S"<<'\n';
    for(auto x:v){
        if(x.second!=0){
            cout<<x.first<<" "<<x.second<<'\n';
        }
        else{
            cout<<x.first<<'\n';
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    m.insert({{'N','E'},'R'});
    m.insert({{'N','W'},'L'});
    m.insert({{'E','S'},'R'});
    m.insert({{'E','N'},'L'});
    m.insert({{'S','W'},'R'});
    m.insert({{'S','E'},'L'});
    m.insert({{'W','N'},'R'});
    m.insert({{'W','S'},'L'});
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3488kb

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:

8 S
L
Z 6
L
Z 1
L
Z 2
L
Z 8
16 S
R
Z 10
R
Z 1
R
Z 10
R
Z 2
L
Z 2
L
Z 2
L
Z 2
L
Z 1
18 S

result:

wrong answer Should start with `Z` (test case 1)