QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732727#9535. Arrow a RowPHarrAC ✓20ms5268kbC++201.7kb2024-11-10 15:41:592024-11-10 15:42:00

Judging History

This is the latest submission verdict.

  • [2024-11-10 15:42:00]
  • Judged
  • Verdict: AC
  • Time: 20ms
  • Memory: 5268kb
  • [2024-11-10 15:41:59]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

using vi = vector<int>;
using pii = pair<int,int>;


string check(int n, vector<pii> op) {
	string s(n + 1, '*');
	for(auto [x, len] : op) {
		s[x] = s[x + len - 1] = s[x + len - 2] = s[x + len - 3] = '>';
		for(int i = x + 1; i <= x + len - 4; i ++)
			s[i] = '-';
		cout << s << "\n";
	}
	return s;
}

void solve() {
	string s;
	cin >> s;

	int n = s.size() - 1;

	if(s[0] != '>' or s[n] != '>' or s[n - 1] != '>' or s[n - 2] != '>'){
		cout << "No\n";
		return;
	}
	bool ok = false;
	for(int i = 1; i <= n - 3; i ++) {
		if(s[i] == '-') {
			ok = true;
			break;
		}
	}

	if(ok == false){
		cout << "No\n";
		return;
	}

	vector<pii> op;
	int lst = -1;
	for(int i = n; i >= 0; i --){
		if(s[i] == '>' and s[i - 1] == '>' and s[i - 2] == '>') {
			op.emplace_back(i - 4, 5);
			i = i - 2;
		} else if(s[i] == '>' and s[i - 1] == '>') {
			op.emplace_back(i - 3, 5);
			lst = i - 2;
			break;
		} else if(s[i] == '>') {
			op.emplace_back(i - 2, 5);
			lst = i - 1;
			break;
		} else {
			lst = i;
			break;
		}
	}


	for(int i = 0; i <= lst; i ++){
		if(s[i] == '>') {
			if(s[i + 1] == '-'){
				int len = 4, j = i;
				while(s[i + 1] == '-')
					i ++, len ++;
				op.emplace_back(j, len);
			} else {
				op.emplace_back(i, 5);
			}
		} else {
			assert(false);
		}
	}

	cout << "Yes " << op.size() << "\n";
	for(auto [x, y]: op) cout << x + 1 << " " << y << "\n"; 
	// check(n, op);
	return;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int T;
	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: 3568kb

input:

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

output:

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

result:

ok ok (4 test cases)

Test #2:

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

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 14ms
memory: 3520kb

input:

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

output:

Yes 12
22 5
1 5
2 5
3 6
6 5
7 5
8 5
9 6
12 8
17 5
19 5
21 6
Yes 10
14 5
1 5
2 6
5 5
6 5
7 5
8 5
10 6
13 5
14 5
Yes 111
207 5
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: 14ms
memory: 3476kb

input:

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

output:

No
No
No
No
No
No
Yes 15
35 5
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
125 5
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: 8ms
memory: 4300kb

input:

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

output:

No
No
Yes 48172
95944 5
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: 19ms
memory: 5268kb

input:

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

output:

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

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 12ms
memory: 3756kb

input:

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

output:

Yes 21000
24996 5
24993 5
24990 5
24987 5
24984 5
24981 5
24978 5
24975 5
24972 5
24969 5
24966 5
24963 5
24960 5
24957 5
24954 5
24951 5
24948 5
24945 5
24942 5
24939 5
24936 5
24933 5
24930 5
24927 5
24924 5
24921 5
24918 5
24915 5
24912 5
24909 5
24906 5
24903 5
24900 5
24897 5
24894 5
24891 5
24...

result:

ok ok (20 test cases)

Test #10:

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

input:

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

output:

Yes 9852
24996 5
24993 5
24990 5
24987 5
24984 5
24981 5
24978 5
24975 5
24972 5
24969 5
24966 5
24963 5
24960 5
24957 5
24954 5
24951 5
24948 5
24945 5
24942 5
24939 5
24936 5
24933 5
24930 5
24927 5
24924 5
24921 5
24918 5
24915 5
24912 5
24909 5
24906 5
24903 5
24900 5
24897 5
24894 5
24891 5
248...

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed