QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#716681#9535. Arrow a Rowfgz#AC ✓59ms5252kbC++231.3kb2024-11-06 15:48:322024-11-06 15:48:32

Judging History

This is the latest submission verdict.

  • [2024-11-06 15:48:32]
  • Judged
  • Verdict: AC
  • Time: 59ms
  • Memory: 5252kb
  • [2024-11-06 15:48:32]
  • Submitted

answer

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0), cin.tie(0)
// #define int long long 
#define pb push_back
#define fi first
#define se second
using namespace std;


typedef pair<int, int> PII;

void solve(){
    int n;
    string s;
    cin >> s;
    n = s.size();
    s = ' ' + s;

    int cnt_ = 0, f = 1;
    for(int i = 1; i <= n; i ++){
        if(s[i] == '-'){
            cnt_ ++;
            if(i == 1 || i >= n - 2)f = 0;
        }
    }
    if(cnt_ == 0 || f == 0){
        cout << "No" << endl;
        return;
    }

    vector<PII> op, tmp;
    int tn = n;
    while(s[tn] == '>')tn --;
    int pos = n;

    // cout << tn << endl;
    // mx = tn + 3;
    op.pb({1, pos});
    while(pos != tn + 3){
        pos = max(pos - 3, tn + 3);
        op.pb({1, pos});
    }
    for(int i = 1; i < tn; i ++){
        if(s[i] == '>' && s[i + 1] == '-'){
            int t = i + 1;
            while(s[t] == '-')t ++;
            op.pb({i, t + 2 - i + 1});
            i = t - 1;
        }
        else op.pb({i, 5});
    }
    cout << "Yes" << " " << op.size() << endl;
    for(auto [a, b] : op)
        cout << a << " " << b << endl;

}
signed main(){
    ios;
    int T = 1;
    cin >> T;

    while(T --)
        solve();
}

详细

Test #1:

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

input:

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

output:

Yes 3
1 6
1 5
2 5
No
No
Yes 3
1 8
1 5
1 5

result:

ok ok (4 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

score: 0
Accepted
time: 8ms
memory: 3484kb

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

score: 0
Accepted
time: 27ms
memory: 3656kb

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

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

input:

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

output:

Yes 12
1 26
1 5
2 5
3 6
6 5
7 5
8 5
9 6
12 8
17 5
19 5
21 6
Yes 10
1 18
1 5
2 6
5 5
6 5
7 5
8 5
10 6
13 5
14 5
Yes 111
1 211
1 5
3 6
6 7
10 7
14 5
16 6
19 5
20 7
24 5
25 5
27 5
29 5
30 6
33 5
35 5
37 5
38 5
39 5
40 5
41 5
42 5
44 5
45 5
46 5
47 9
53 5
55 7
59 5
60 9
66 5
67 6
70 5
71 5
72 9
78 5
80 ...

result:

ok ok (10000 test cases)

Test #6:

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

input:

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

output:

No
No
No
No
No
No
Yes 15
1 39
1 5
3 7
7 7
11 5
12 5
13 5
14 5
16 5
17 5
18 9
24 10
31 5
32 6
35 5
Yes 70
1 129
1 5
2 5
4 5
5 5
6 5
8 5
9 5
10 8
15 5
16 5
17 5
19 5
20 5
21 5
22 5
23 5
24 5
25 5
26 5
27 5
29 7
33 5
34 5
36 5
37 5
38 5
39 5
40 6
43 5
44 5
45 5
47 5
49 5
51 5
52 6
55 5
57 7
61 5
63 6
6...

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 24ms
memory: 4284kb

input:

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

output:

No
No
Yes 48172
1 95948
1 5
2 5
3 5
5 5
6 5
7 5
9 5
10 5
12 8
17 5
18 5
19 5
20 5
22 5
23 5
24 5
26 5
27 5
28 5
30 6
33 5
34 5
36 5
37 5
39 5
40 5
41 5
42 5
44 5
45 5
46 5
47 7
51 6
54 9
60 5
61 5
62 5
63 5
64 5
66 5
67 5
68 6
71 5
72 5
73 5
75 5
76 5
77 7
81 5
82 5
83 7
87 5
88 6
91 5
93 5
94 8
99 ...

result:

ok ok (5 test cases)

Test #8:

score: 0
Accepted
time: 56ms
memory: 5252kb

input:

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

output:

No
Yes 99997
1 100000
1 99999
1 5
2 5
3 5
4 5
5 5
6 5
7 5
8 5
9 5
10 5
11 5
12 5
13 5
14 5
15 5
16 5
17 5
18 5
19 5
20 5
21 5
22 5
23 5
24 5
25 5
26 5
27 5
28 5
29 5
30 5
31 5
32 5
33 5
34 5
35 5
36 5
37 5
38 5
39 5
40 5
41 5
42 5
43 5
44 5
45 5
46 5
47 5
48 5
49 5
50 5
51 5
52 5
53 5
54 5
55 5
56 5...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 59ms
memory: 3820kb

input:

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

output:

Yes 21000
1 25000
1 24997
1 24994
1 24991
1 24988
1 24985
1 24982
1 24979
1 24976
1 24973
1 24970
1 24967
1 24964
1 24961
1 24958
1 24955
1 24952
1 24949
1 24946
1 24943
1 24940
1 24937
1 24934
1 24931
1 24928
1 24925
1 24922
1 24919
1 24916
1 24913
1 24910
1 24907
1 24904
1 24901
1 24898
1 24895
1 ...

result:

ok ok (20 test cases)

Test #10:

score: 0
Accepted
time: 55ms
memory: 3940kb

input:

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

output:

Yes 9852
1 25000
1 24997
1 24994
1 24991
1 24988
1 24985
1 24982
1 24979
1 24976
1 24973
1 24970
1 24967
1 24964
1 24961
1 24958
1 24955
1 24952
1 24949
1 24946
1 24943
1 24940
1 24937
1 24934
1 24931
1 24928
1 24925
1 24922
1 24919
1 24916
1 24913
1 24910
1 24907
1 24904
1 24901
1 24898
1 24895
1 2...

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed