QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704596#9535. Arrow a Rowucup-team5367#AC ✓23ms7060kbC++172.0kb2024-11-02 20:21:322024-11-02 20:21:34

Judging History

This is the latest submission verdict.

  • [2024-11-02 20:21:34]
  • Judged
  • Verdict: AC
  • Time: 23ms
  • Memory: 7060kb
  • [2024-11-02 20:21:32]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 10;
const int inf1 = 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxn = -1;


void solve() {
    string s;
    cin >> s;
    vector<pair<int,int>> p;
    for(int i = 0; i < s.size(); i++) {
        if(p.size() && s[i] == s[i-1]) {
            p.back().sc = i;
        }
        else {
            p.pb(mp(i,i));
        }
    }

    if(s[0] == '-' or s.back() == '-' or p.back().sc-p.back().fr+1 < 3 or p.size() == 1) {
        cout << "No" << endl;
        return;
    }

    vector<pair<int,int>> ans;

    // 11111111
    // 1111100010111111

    // 11111100
    // 111100001111\

    // 110111
    // ******
    // 101111
    for(int i = 0; i < p.size(); i+= 2) {
        // so 1
        if(i != 0 and p[i].sc-p[i].fr+1 >= 5) {
            for(int r = p[i].sc; r-4 >= p[i].fr; r--) {
                int l = r-4;
                ans.pb(mp(l,r));
            }
        }
        else if(i != (int) p.size()-1) {
            for(int j = p[i].fr; j <= p[i].sc-1; j++) {
                if(j+4 < (int) s.size()) ans.pb(mp(j,j+4));
            }
        }
        else if(p[i].sc-p[i].fr+1 == 4) {
            ans.pb(mp(p[i].fr-1,p[i].fr+3));
        }


        // so s[p.back().fr+1] = 0, resto é 1
    }

    //11110000111111
    for(int i = 0; i+2 < p.size(); i+= 2) {
        ans.pb(mp(p[i].sc,p[i+2].fr+2));
    }

    cout << "Yes " << ans.size() << endl;
    for(auto x : ans) {
        cout << x.fr+1 << " " << x.sc-x.fr+1 << endl;
    }


}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
    #endif

    int tt = 1;
    cin >> tt;
    while(tt--) {
        solve();
    }

}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok ok (4 test cases)

Test #2:

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

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

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

input:

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

output:

Yes 11
1 5
2 5
6 5
7 5
8 5
3 6
9 6
12 8
17 5
19 5
21 6
Yes 9
1 5
5 5
6 5
7 5
13 5
2 6
8 5
10 6
14 5
Yes 104
19 5
24 5
29 5
38 5
37 5
44 5
45 5
46 5
59 5
66 5
70 5
71 5
82 5
83 5
88 5
91 5
106 5
109 5
110 5
114 5
119 5
120 5
125 5
126 5
127 5
130 5
135 5
139 5
140 5
143 5
146 5
150 5
151 5
152 5
156 ...

result:

ok ok (10000 test cases)

Test #6:

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

input:

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

output:

No
No
No
No
No
No
Yes 14
11 5
12 5
13 5
16 5
17 5
31 5
1 5
3 7
7 7
14 5
18 9
24 10
32 6
35 5
Yes 60
1 5
4 5
5 5
8 5
9 5
15 5
16 5
23 5
22 5
21 5
20 5
19 5
33 5
36 5
43 5
44 5
51 5
68 5
75 5
85 5
84 5
83 5
82 5
93 5
100 5
101 5
113 5
119 5
2 5
6 5
10 8
17 5
27 5
29 7
34 5
40 6
45 5
47 5
49 5
52 6
55 ...

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 13ms
memory: 5880kb

input:

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

output:

No
No
Yes 43407
1 5
2 5
5 5
6 5
9 5
17 5
18 5
19 5
22 5
23 5
26 5
27 5
33 5
36 5
39 5
40 5
41 5
44 5
45 5
46 5
60 5
66 5
67 5
71 5
72 5
75 5
76 5
81 5
82 5
87 5
93 5
99 5
105 5
118 5
124 5
123 5
143 5
156 5
169 5
172 5
173 5
189 5
202 5
209 5
217 5
231 5
232 5
247 5
250 5
257 5
263 5
264 5
267 5
268...

result:

ok ok (5 test cases)

Test #8:

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

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: 15ms
memory: 4324kb

input:

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

output:

Yes 24987
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: 23ms
memory: 4348kb

input:

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

output:

Yes 24995
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