QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#713341#9535. Arrow a Rowcaojc#AC ✓20ms5176kbC++201.5kb2024-11-05 19:03:002024-11-05 19:03:00

Judging History

This is the latest submission verdict.

  • [2024-11-05 19:03:00]
  • Judged
  • Verdict: AC
  • Time: 20ms
  • Memory: 5176kb
  • [2024-11-05 19:03:00]
  • Submitted

answer

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

#define db(args...){\
    string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << '\n';}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << ' ';
    err(++it, args...);
}

typedef pair<int, int> PII;

void solve() {
    string s; cin >> s;
    int n = s.size();
    s = '#' + s;
    if (s[1] != '>' || s[n - 2] != '>' || s[n - 1] != '>' || s[n] != '>') {
        cout << "No\n";
        return ;
    }
    int ok = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '-') {
            ok = true;
            break;
        }
    }
    if (!ok) {
        cout << "No\n";
        return ;
    }
    int id = n;
    while (s[id] == '>') id--;
    vector<PII> ans;
    for (int i = n - 4; i >= id - 1; i--) ans.pb({i, 5});
    for (int i = 1; i < id; i++) {
        if (s[i] == '>') {
            ans.pb({i, id + 4 - i});
        }
    }
    cout << "Yes ";
    cout << ans.size() << "\n";
    for (auto [p, l] : ans) cout << p << ' ' << l << "\n";

}
signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}

/*
g++ 1.cpp -std=c++20 -o 1 && ./1 < in.txt > out.txt
*/

详细

Test #1:

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

input:

4
>>->>>
>>>->
>>>>>
>->>>>>>

output:

Yes 3
2 5
1 6
2 5
No
No
Yes 5
4 5
3 5
2 5
1 5
1 5

result:

ok ok (4 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

126
>->-->>>>
>--->->>>>
>--->-->>>
>>-->->>>
>>-->>>>>
>>->->>>>
>>->>->>>>
>-->->->>>
>->->>>>>>
>->>>
>->->>>>>
>>>->->>>
>>->>>>>>>
>>>>>->>>
>->>>->>>
>>--->->>>
>>->>>>
>->>>>->>>
>>>>-->>>
>---->>>
>>>---->>>
>>>>->>>>
>->>-->>>
>-->-->>>>
>>---->>>
>>--->>>
>->>>-->>>
>>-->>>>
>>---->>>>
>>-...

output:

Yes 4
5 5
4 5
1 8
3 6
Yes 4
6 5
5 5
1 9
5 5
Yes 3
6 5
1 10
5 6
Yes 4
5 5
1 9
2 8
5 5
Yes 5
5 5
4 5
3 5
1 7
2 6
Yes 5
5 5
4 5
1 8
2 7
4 5
Yes 6
6 5
5 5
1 9
2 8
4 6
5 5
Yes 4
6 5
1 10
4 7
6 5
Yes 6
6 5
5 5
4 5
3 5
1 7
3 5
Yes 2
1 5
1 5
Yes 5
5 5
4 5
3 5
1 7
3 5
Yes 5
5 5
1 9
2 8
3 7
5 5
Yes 7
6 5
5 5
...

result:

ok ok (126 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

4032
>>--->>>>>>>>
>->>->->-->->>>
>>--->>--->>>
>>->->->>>>>>>>
>->---->->>>
>->>->>---->>>>
>>>>>>>>->>>>
>->>>--->>>->>>
>->>->>-->>>>>>
>->>-->---->>>
>-->--->>>->>>
>->---->>-->>>>
>>------>>>
>>>-->>--->>>>>
>->->->>-->>>>
>->->-->>->->>>
>>->>>>-->->>>>
>>>-->>->--->>>
>->->>>>>->>>>
>>-->->>...

output:

Yes 8
9 5
8 5
7 5
6 5
5 5
4 5
1 8
2 7
Yes 7
11 5
1 15
3 13
4 12
6 10
8 8
11 5
Yes 5
9 5
1 13
2 12
6 8
7 7
Yes 10
11 5
10 5
9 5
8 5
7 5
6 5
1 10
2 9
4 7
6 5
Yes 4
8 5
1 12
3 10
8 5
Yes 7
11 5
10 5
1 14
3 12
4 11
6 9
7 8
Yes 10
9 5
8 5
1 12
2 11
3 10
4 9
5 8
6 7
7 6
8 5
Yes 8
11 5
1 15
3 13
4 12
5 11
...

result:

ok ok (4032 test cases)

Test #4:

score: 0
Accepted
time: 10ms
memory: 3640kb

input:

10000
>>>>->->>->>->>>>
>->-->>->>->>>>>>
>->->>-->--->>>>>
>---->-->->>>>>>>
>->-->>--->>->>>>
>->>->>>>>>-->>>
>>--->->-->>->>>
>-->---->>>->>>
>->----->->->>>>>
>>--->---->-->>>>
>>-->->->--->>>
>----->>-->>->>>>
>-->->->>>>>->>>>
>>->>---->-->>>
>>->>-->>>-->>>
>------>->>>->>>>
>->->-->->>>->>>...

output:

Yes 11
13 5
12 5
1 16
2 15
3 14
4 13
6 11
8 9
9 8
11 6
12 5
Yes 10
13 5
12 5
11 5
10 5
1 14
3 12
6 9
7 8
9 6
10 5
Yes 8
13 5
12 5
11 5
1 15
3 13
5 11
6 10
9 7
Yes 8
13 5
12 5
11 5
10 5
9 5
1 13
6 8
9 5
Yes 8
13 5
12 5
1 16
3 14
6 11
7 10
11 6
12 5
Yes 10
12 5
1 16
3 14
4 13
6 11
7 10
8 9
9 8
10 7
11...

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 14ms
memory: 3584kb

input:

10000
>>>-->>>>-->---->->->-->>>
>>-->>>>->-->>->>>
>->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>>
->->>>>--->>>>>>->>>->>>>->->-->-->>...

output:

Yes 12
22 5
1 26
2 25
3 24
6 21
7 20
8 19
9 18
12 15
17 10
19 8
21 6
Yes 10
14 5
1 18
2 17
5 14
6 13
7 12
8 11
10 9
13 6
14 5
Yes 111
207 5
1 211
3 209
6 206
10 202
14 198
16 196
19 193
20 192
24 188
25 187
27 185
29 183
30 182
33 179
35 177
37 175
38 174
39 173
40 172
41 171
42 170
44 168
45 167
46...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 11ms
memory: 3580kb

input:

9999
->->--->>>>->->--->>--
->>>--->>>-->>--->>---
-->>>>>>>-
>>>->>>>>>>--
>>-->-->->----->->>>>->>->---->->
>-->->>>--->->->>->->-
>->--->--->>>>->>>----->------>>-->->>>
>>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...

output:

No
No
No
No
No
No
Yes 15
35 5
1 39
3 37
7 33
11 29
12 28
13 27
14 26
16 24
17 23
18 22
24 16
31 9
32 8
35 5
Yes 70
125 5
1 129
2 128
4 126
5 125
6 124
8 122
9 121
10 120
15 115
16 114
17 113
19 111
20 110
21 109
22 108
23 107
24 106
25 105
26 104
27 103
29 101
33 97
34 96
36 94
37 93
38 92
39 91
40 ...

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 4ms
memory: 4392kb

input:

5
>-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...

output:

No
No
Yes 48172
95944 5
1 95948
2 95947
3 95946
5 95944
6 95943
7 95942
9 95940
10 95939
12 95937
17 95932
18 95931
19 95930
20 95929
22 95927
23 95926
24 95925
26 95923
27 95922
28 95921
30 95919
33 95916
34 95915
36 95913
37 95912
39 95910
40 95909
41 95908
42 95907
44 95905
45 95904
46 95903
47 9...

result:

ok ok (5 test cases)

Test #8:

score: 0
Accepted
time: 20ms
memory: 5176kb

input:

5
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...

output:

No
Yes 99997
99996 5
99995 5
1 99999
2 99998
3 99997
4 99996
5 99995
6 99994
7 99993
8 99992
9 99991
10 99990
11 99989
12 99988
13 99987
14 99986
15 99985
16 99984
17 99983
18 99982
19 99981
20 99980
21 99979
22 99978
23 99977
24 99976
25 99975
26 99974
27 99973
28 99972
29 99971
30 99970
31 99969
3...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 16ms
memory: 3848kb

input:

20
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...

output:

Yes 24995
24996 5
24995 5
24994 5
24993 5
24992 5
24991 5
24990 5
24989 5
24988 5
24987 5
24986 5
24985 5
24984 5
24983 5
24982 5
24981 5
24980 5
24979 5
24978 5
24977 5
24976 5
24975 5
24974 5
24973 5
24972 5
24971 5
24970 5
24969 5
24968 5
24967 5
24966 5
24965 5
24964 5
24963 5
24962 5
24961 5
24...

result:

ok ok (20 test cases)

Test #10:

score: 0
Accepted
time: 18ms
memory: 3748kb

input:

20
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...

output:

Yes 24997
24996 5
24995 5
24994 5
24993 5
24992 5
24991 5
24990 5
24989 5
24988 5
24987 5
24986 5
24985 5
24984 5
24983 5
24982 5
24981 5
24980 5
24979 5
24978 5
24977 5
24976 5
24975 5
24974 5
24973 5
24972 5
24971 5
24970 5
24969 5
24968 5
24967 5
24966 5
24965 5
24964 5
24963 5
24962 5
24961 5
24...

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed