QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783151#9535. Arrow a RowMiaoYuAC ✓92ms4440kbC++141.8kb2024-11-26 00:01:132024-11-26 00:01:14

Judging History

This is the latest submission verdict.

  • [2024-11-26 00:01:14]
  • Judged
  • Verdict: AC
  • Time: 92ms
  • Memory: 4440kb
  • [2024-11-26 00:01:13]
  • Submitted

answer

#include <iostream>
#include <stack>
#include <cstring>
 
using namespace std;
 
const int maxn = 5e5 + 10;
char s[maxn];
int T;
stack< pair<int, int> > order; //ans顺序
 
bool judge(){
    int len = strlen(s);
    bool flag = true;
    for(int i = len - 3; i < len; i++) if(s[i] == '-') return false; //头尾正确 
 
    if(s[0] == '-') return false;
 
    for(int i = 1; i < len - 3; i++) if(s[i] == '-'){return true;}//存在一个杆子
    return false;
}
 
int main(){
    cin >> T;
    while(T--){
        cin >> s;
        //cout << strlen(s);
        if(!judge()) {cout << "No" << endl; continue;}
 
        int len = strlen(s);
        
        //规定箭头的长度为 箭头右侧不包含在箭头里的一点 - 箭头最左侧且在箭头里的一点
        int end = len;
        int m = 0; //统计m
 
        int e1 = len - 4; //表示第一个是 - 的位置
        for(int i = len - 4; i >= 1; i--) {
            if(s[i] == '-') {break;}
            e1--;
        }
 
        //知道了-的位置,那么对于任何>e1的就都是>>
        end = e1 + 4;
        for(int i = e1 - 1; i >= 1; i--) {            
            if(s[i] == '-') continue;
            //是'>'
            m++;
            order.push(make_pair(i, end - i));
            end = i + 4; // 设置终点位置,并且可以被覆盖掉
        }
 
        //输出之前铺设一个底
        m += len - e1 - 3;
        cout << "Yes" << " " << m << endl;
 
        for (int i = len; i >= e1 + 4; i--)
            cout << 1 << " " << i << endl;
        
        //cout << "e1" << e1 << endl;
        while(!order.empty()){
            pair<int, int> p = order.top();
            order.pop();
            //结果编号由1开始,所以全部+1
            cout << p.first + 1 << " " << p.second << endl; 
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3800kb

input:

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

output:

Yes 2
1 6
2 5
No
No
Yes 4
1 8
1 7
1 6
1 5

result:

ok ok (4 test cases)

Test #2:

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

input:

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

output:

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

result:

ok ok (126 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

Yes 10
1 17
1 16
2 5
3 5
4 6
6 6
8 5
9 6
11 5
12 5
Yes 9
1 17
1 16
1 15
1 14
3 7
6 5
7 6
9 5
10 5
Yes 7
1 17
1 16
1 15
3 6
5 5
6 7
9 7
Yes 7
1 17
1 16
1 15
1 14
1 13
6 7
9 5
Yes 7
1 17
1 16
3 7
6 5
7 8
11 5
12 5
Yes 9
1 16
3 5
4 6
6 5
7 5
8 5
9 5
10 5
11 6
Yes 6
1 16
2 8
6 6
8 7
11 5
12 5
Yes 5
1 15...

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 44ms
memory: 3668kb

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #6:

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

input:

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

output:

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

result:

ok ok (9999 test cases)

Test #7:

score: 0
Accepted
time: 54ms
memory: 4068kb

input:

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

output:

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

result:

ok ok (5 test cases)

Test #8:

score: 0
Accepted
time: 72ms
memory: 4440kb

input:

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

output:

No
Yes 99996
1 100000
1 99999
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 ...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 84ms
memory: 3764kb

input:

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

output:

Yes 24994
1 25000
1 24999
1 24998
1 24997
1 24996
1 24995
1 24994
1 24993
1 24992
1 24991
1 24990
1 24989
1 24988
1 24987
1 24986
1 24985
1 24984
1 24983
1 24982
1 24981
1 24980
1 24979
1 24978
1 24977
1 24976
1 24975
1 24974
1 24973
1 24972
1 24971
1 24970
1 24969
1 24968
1 24967
1 24966
1 24965
1 ...

result:

ok ok (20 test cases)

Test #10:

score: 0
Accepted
time: 92ms
memory: 3700kb

input:

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

output:

Yes 24996
1 25000
1 24999
1 24998
1 24997
1 24996
1 24995
1 24994
1 24993
1 24992
1 24991
1 24990
1 24989
1 24988
1 24987
1 24986
1 24985
1 24984
1 24983
1 24982
1 24981
1 24980
1 24979
1 24978
1 24977
1 24976
1 24975
1 24974
1 24973
1 24972
1 24971
1 24970
1 24969
1 24968
1 24967
1 24966
1 24965
1 ...

result:

ok ok (20 test cases)

Extra Test:

score: 0
Extra Test Passed