QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#715288#9535. Arrow a Roweastcloud#AC ✓12ms4424kbC++201.6kb2024-11-06 11:20:572024-11-06 11:20:57

Judging History

This is the latest submission verdict.

  • [2024-11-06 11:20:57]
  • Judged
  • Verdict: AC
  • Time: 12ms
  • Memory: 4424kb
  • [2024-11-06 11:20:57]
  • Submitted

answer


#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array

using namespace std;

#define N 500005

int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}

char s[N];
vector<pi> res;
void solve(){
    scanf("%s",s+1);int n=strlen(s+1);
    int pos=0;
    vi S;res.clear();
    for(int i=1;i<=n;i++)if(s[i]=='>'){pos=i;break;}
    if(!pos || pos!=1){printf("No\n");return;}
    for(int i=n;i>=1;){
        if(s[i]!='>'){i--;continue;}
        int j=i;
        if(i!=n){printf("No\n");return;}
        while(j-1>=1 && s[j-1]=='>')j--;
        if(i-j+1<=2){printf("No\n");return;}
        if(pos==j){printf("No\n");return;}
        for(int k=i;k>=j+3;k--){
            res.pb(mp(pos,k-pos+1));
        }
        for(int k=1;k<=j-1;k++){
            if(s[k]=='>')res.pb(mp(k,(j+2)-k+1));
        }
        
        break;
    }
    printf("Yes ");write(res.size());putchar('\n');
    for(auto [u,v]:res)write(u),putchar(' '),write(v),putchar('\n');
}

int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    #endif

    int T=read();while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 3880kb

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 8
5 5
Yes 4
1 9
1 8
1 7
2 6
Yes 4
1 9
1 8
2 7
4 5
Yes 5
1 10
1 9
2 8
4 6
5 5
Yes 3
1 10
4 7
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 8
3 7
5 5
Yes 6
1 10
1 9
1 8
1 7
1 6
2 5
Yes 5
1 9
2 8
3 7
4 6
5 5
Ye...

result:

ok ok (126 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (4032 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (10000 test cases)

Test #5:

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

input:

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

output:

Yes 11
1 26
2 25
3 24
6 21
7 20
8 19
9 18
12 15
17 10
19 8
21 6
Yes 9
1 18
2 17
5 14
6 13
7 12
8 11
10 9
13 6
14 5
Yes 110
1 211
3 209
6 206
10 202
14 198
16 196
19 193
20 192
24 188
25 187
27 185
29 183
30 182
33 179
35 177
37 175
38 174
39 173
40 172
41 171
42 170
44 168
45 167
46 166
47 165
53 15...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 6ms
memory: 3796kb

input:

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

output:

No
No
No
No
No
No
Yes 14
1 39
3 37
7 33
11 29
12 28
13 27
14 26
16 24
17 23
18 22
24 16
31 9
32 8
35 5
Yes 69
1 129
2 128
4 126
5 125
6 124
8 122
9 121
10 120
15 115
16 114
17 113
19 111
20 110
21 109
22 108
23 107
24 106
25 105
26 104
27 103
29 101
33 97
34 96
36 94
37 93
38 92
39 91
40 90
43 87
44...

result:

ok ok (9999 test cases)

Test #7:

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

input:

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

output:

No
No
Yes 48171
1 95948
2 95947
3 95946
5 95944
6 95943
7 95942
9 95940
10 95939
12 95937
17 95932
18 95931
19 95930
20 95929
22 95927
23 95926
24 95925
26 95923
27 95922
28 95921
30 95919
33 95916
34 95915
36 95913
37 95912
39 95910
40 95909
41 95908
42 95907
44 95905
45 95904
46 95903
47 95902
51 ...

result:

ok ok (5 test cases)

Test #8:

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

input:

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

output:

No
Yes 99996
1 100000
1 99999
2 99998
3 99997
4 99996
5 99995
6 99994
7 99993
8 99992
9 99991
10 99990
11 99989
12 99988
13 99987
14 99986
15 99985
16 99984
17 99983
18 99982
19 99981
20 99980
21 99979
22 99978
23 99977
24 99976
25 99975
26 99974
27 99973
28 99972
29 99971
30 99970
31 99969
32 99968...

result:

ok ok (5 test cases)

Test #9:

score: 0
Accepted
time: 7ms
memory: 3952kb

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: 12ms
memory: 3960kb

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