QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#711980#9535. Arrow a Rowgaofeng#AC ✓36ms6096kbC++231.3kb2024-11-05 14:11:392024-11-05 14:11:45

Judging History

This is the latest submission verdict.

  • [2024-11-05 14:11:45]
  • Judged
  • Verdict: AC
  • Time: 36ms
  • Memory: 6096kb
  • [2024-11-05 14:11:39]
  • Submitted

answer

#include<bits/stdc++.h>

void solve() {

    std::string s; std::cin >> s;
    int n = s.size();
    
    std::vector<std::array<int, 2>> ans;
    for (int i = n - 1, last = -1; i >= 0; i--) {
        if (s[i] == '>' && last != -1) {
            if (last + 3 >= n) {
                std::cout << "No\n";
                return;
            }
            ans.push_back({i, last + 3});
            last = -1;
        } else if (s[i] == '-' && last == -1) last = i;
    }
    if (s[0] != '>' || ans.empty()) {
        std::cout << "No\n";
        return;
    }
    std::set<int> st;
    for (auto [l, r] : ans) st.insert(l);
    
    for (int i = ans[0][0]; i + 4 < n; i++) {
        if (st.count(i)) continue;
        ans.push_back({i, i + 4});
    }
    for (int i = ans[0][0];  i >= 0; i--) {
        if (st.count(i)) continue;
        ans.push_back({i, i + 4});
    }
    std::reverse(ans.begin(), ans.end());
    std::cout << "Yes " << ans.size() << "\n";
    for (auto [l, r] : ans ) {
        std::cout << l + 1 << ' ' << r - l + 1 << "\n";
    }
}


signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0),std::cout.tie(0);
    int t;t=1;
    std::cin>>t;
    for(int i=1;i<=t;i++){
        //printf("Case %d: ",i);
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok ok (4 test cases)

Test #2:

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

input:

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

output:

Yes 5
2 5
5 5
4 5
1 5
3 6
Yes 6
2 5
3 5
4 5
6 5
1 7
5 5
Yes 6
2 5
3 5
4 5
6 5
1 7
5 6
Yes 5
1 5
3 5
4 5
2 6
5 5
Yes 5
1 5
5 5
4 5
3 5
2 6
Yes 5
1 5
3 5
5 5
2 5
4 5
Yes 6
1 5
3 5
4 5
6 5
2 5
5 5
Yes 6
2 5
3 5
5 5
1 6
4 5
6 5
Yes 6
2 5
6 5
5 5
4 5
1 5
3 5
Yes 1
1 5
Yes 5
2 5
5 5
4 5
1 5
3 5
Yes 5
1 5
...

result:

ok ok (126 test cases)

Test #3:

score: 0
Accepted
time: 5ms
memory: 3852kb

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

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

input:

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

output:

Yes 22
1 5
2 5
4 5
5 5
6 5
7 5
8 5
10 5
11 5
13 5
14 5
15 5
16 5
18 5
20 5
22 5
3 6
9 6
12 8
17 5
19 5
21 6
Yes 14
1 5
3 5
4 5
5 5
6 5
7 5
9 5
11 5
12 5
13 5
2 6
8 5
10 6
14 5
Yes 207
2 5
4 5
5 5
7 5
8 5
9 5
11 5
12 5
13 5
15 5
17 5
18 5
19 5
21 5
22 5
23 5
24 5
26 5
28 5
29 5
31 5
32 5
34 5
36 5
37...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 28ms
memory: 3516kb

input:

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

output:

No
No
No
No
No
No
Yes 35
2 5
4 5
5 5
6 5
8 5
9 5
10 5
11 5
12 5
13 5
15 5
16 5
17 5
19 5
20 5
21 5
22 5
23 5
25 5
26 5
27 5
28 5
29 5
30 5
31 5
33 5
34 5
1 5
3 7
7 7
14 5
18 9
24 10
32 6
35 5
Yes 125
1 5
3 5
4 5
5 5
7 5
8 5
9 5
11 5
12 5
13 5
14 5
15 5
16 5
18 5
19 5
20 5
21 5
22 5
23 5
24 5
25 5
26...

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 36ms
memory: 6096kb

input:

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

output:

No
No
Yes 95944
1 5
2 5
4 5
5 5
6 5
8 5
9 5
11 5
13 5
14 5
15 5
16 5
17 5
18 5
19 5
21 5
22 5
23 5
25 5
26 5
27 5
29 5
31 5
32 5
33 5
35 5
36 5
38 5
39 5
40 5
41 5
43 5
44 5
45 5
46 5
48 5
49 5
50 5
52 5
53 5
55 5
56 5
57 5
58 5
59 5
60 5
61 5
62 5
63 5
65 5
66 5
67 5
69 5
70 5
71 5
72 5
74 5
75 5
7...

result:

ok ok (5 test cases)

Test #8:

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

input:

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

output:

No
Yes 99996
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
57 5
58 5
59 5
6...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 29ms
memory: 3780kb

input:

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

output:

Yes 24996
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
57 5
58 5
59 5
60 5...

result:

ok ok (20 test cases)

Test #10:

score: 0
Accepted
time: 22ms
memory: 3836kb

input:

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

output:

Yes 24996
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
57 5
58 5
59 5
60 5...

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed