QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711880#9535. Arrow a RowJoler#AC ✓27ms5384kbC++201.9kb2024-11-05 13:50:462024-11-05 13:50:47

Judging History

This is the latest submission verdict.

  • [2024-11-05 13:50:47]
  • Judged
  • Verdict: AC
  • Time: 27ms
  • Memory: 5384kb
  • [2024-11-05 13:50:46]
  • Submitted

answer

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

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == '-' || s[n-1] == '-' || s[n-2] == '-' || s[n-3] == '-') {
        cout << "No\n";
        return;
    }
    int lst = 0, mark = 0, ml = 0, mr = 0;
    vector <array<int, 2> > vp;
    for (int i = 0; i + 3 < n; i++) {
        if (s[i] == '-' && s[i+1] == '>') {
            mark = 1;
            vp.push_back({lst, i + 4 - lst});
            mr = i + 2;
        } else if (s[i] == '>') {
            lst = i;
            if (i + 4 < n) vp.push_back({i, 5});
        }
    }
    if (!mark) {
        cout << "No\n";
        return;
    }
    vp.resize(unique(vp.begin(), vp.end()) - vp.begin());
    while (vp.back()[0] + 2 > mr) vp.pop_back();
    string ss = string(n, '*');
    vector <array<int, 2> > v;
    {
        for (int i = mr; i < n; i += 3) {
            if (i + 4 < n) {
                v.push_back({i, 5});
            } else {
                v.push_back({n - 5, 5});
                break;
            }
        }
        std::reverse(v.begin(), v.end());
    }

    cout << "Yes " << vp.size() + v.size() << '\n';
    for (auto[a, b] : v) {
        cout << a + 1 << ' ' << b << '\n';
        ss[a] = ss[a + b - 1] = ss[a + b - 2] = ss[a + b - 3] = '>';
        for (int i = a + 1; i < a + b - 3; i++) {
            ss[i] = '-';
        }
//        cout << ss << '\n';
    }
    for (auto[a, b] : vp) {
        cout << a + 1 << ' ' << b << '\n';
        ss[a] = ss[a + b - 1] = ss[a + b - 2] = ss[a + b - 3] = '>';
        for (int i = a + 1; i < a + b - 3; i++) {
            ss[i] = '-';
        }
//        cout << ss << '\n';

    }
//    if (ss != s) {
//        cout << "? " << ss << '\n';
//    }
}

int main( )
{
    int T;
    cin >> T;
    while (T--) {
        solve();
    }

    return 0;

}

详细

Test #1:

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

input:

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

output:

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

result:

ok ok (4 test cases)

Test #2:

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

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3540kb

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 23ms
memory: 3620kb

input:

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

output:

Yes 16
22 5
1 5
2 5
3 5
3 6
6 5
7 5
8 5
9 5
9 6
12 5
12 8
17 5
19 5
21 5
21 6
Yes 12
14 5
1 5
2 5
2 6
5 5
6 5
7 5
8 5
10 5
10 6
13 5
14 5
Yes 134
207 5
1 5
3 5
3 6
6 5
6 7
10 5
10 7
14 5
16 5
16 6
19 5
20 5
20 7
24 5
25 5
27 5
29 5
30 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 ...

result:

ok ok (10000 test cases)

Test #6:

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

input:

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

output:

No
No
No
No
No
No
Yes 20
35 5
1 5
3 5
3 7
7 5
7 7
11 5
12 5
13 5
14 5
16 5
17 5
18 5
18 9
24 5
24 10
31 5
32 5
32 6
35 5
Yes 85
125 5
1 5
2 5
4 5
5 5
6 5
8 5
9 5
10 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 5
29 7
33 5
34 5
36 5
37 5
38 5
39 5
40 5
40 6
43 5
44 5
45 5
47 ...

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 15ms
memory: 4948kb

input:

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

output:

No
No
Yes 60088
95944 5
1 5
2 5
3 5
5 5
6 5
7 5
9 5
10 5
12 5
12 8
17 5
18 5
19 5
20 5
22 5
23 5
24 5
26 5
27 5
28 5
30 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 5
47 7
51 5
51 6
54 5
54 9
60 5
61 5
62 5
63 5
64 5
66 5
67 5
68 5
68 6
71 5
72 5
73 5
75 5
76 5
77 5
77 7
81 5
82 ...

result:

ok ok (5 test cases)

Test #8:

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

input:

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

output:

No
Yes 99996
99996 5
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 ...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 21ms
memory: 4016kb

input:

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

output:

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

result:

ok ok (20 test cases)

Test #10:

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

input:

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

output:

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

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed