QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726241#9535. Arrow a RowwuyunzhishiAC ✓26ms4732kbC++201.2kb2024-11-08 22:31:122024-11-08 22:31:13

Judging History

This is the latest submission verdict.

  • [2024-11-08 22:31:13]
  • Judged
  • Verdict: AC
  • Time: 26ms
  • Memory: 4732kb
  • [2024-11-08 22:31:12]
  • Submitted

answer

#include <bits/stdc++.h>
using ll = long long;

void solve() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int flag = 0;
	for(int i = 0; i < n; i++) if(s[i] == '-') {
		flag = 1;
	} 
	int p = n, cnt = 0;
	while(p - 1 >= 0 && s[p - 1] == '>') {
		p--;
		cnt++;
	}
	if(cnt < 3 || s[0] != '>' || n < 5) flag = 0;
	if(!flag) {
		std::cout << "No\n";
		return;
	}
	std::vector<int> l, len;
	int i = n - 1;
	while(i > 0) {
		int j = i, cnt = 0;
		while(j - 1 >= 0 && s[j - 1] == '>') j--;
		int m = j;
		
		while(j - 1 >= 0 && s[j - 1] == '-') {
			j--;
			cnt++;
		}
		if(cnt > 0) {
			l.push_back(j - 1);
			len.push_back(cnt + 4);	
		}
		if(i == n - 1) {
			for(int k = m - 2; k + 4 < n; k++) {
				l.push_back(k);
				len.push_back(5);
			}
		}
		else {
			for(int k = i - 1; k >= m; k--) {
				l.push_back(k);
				len.push_back(5);
			}
		}
		i = j - 1;
		
		
		
	}
	std::cout << "Yes " << l.size() << '\n';
	for(int i = l.size() - 1; i >= 0; i--) {
		std::cout << l[i] + 1 << " " << len[i] << '\n';
	}
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes 3
1 5
2 5
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: 1ms
memory: 3600kb

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #6:

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

input:

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

output:

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

result:

ok ok (9999 test cases)

Test #7:

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

input:

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

output:

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

result:

ok ok (5 test cases)

Test #8:

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

input:

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

output:

No
Yes 99997
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: 26ms
memory: 3656kb

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)

Test #10:

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

input:

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

output:

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