QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402054#8554. Bot FriendsmarherWA 271ms218564kbC++14909b2024-04-29 20:13:482024-04-29 20:13:52

Judging History

你现在查看的是最新测评结果

  • [2024-04-29 20:13:52]
  • 评测
  • 测评结果:WA
  • 用时:271ms
  • 内存:218564kb
  • [2024-04-29 20:13:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e3+500;

int T,f[N][N][2],n;
char s[N];

#define mem(x,y) memset(x,y,sizeof x)
#define ck(x,y) x=min(x,y)

void sol()
{
    cin>>(s+1);n=strlen(s+1);
    for(int i=0;i<=n+1;i++)
    for(int j=0;j<=n+1;j++)mem(f[i][j],0x3f);
    f[0][1][0]=f[0][1][1]=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]!='<')for(int j=1;j<=n+1;j++)ck(f[i][j][0],f[i-1][j-1][0]);
        if(s[i]!='>')for(int j=0;j<=n;j++)ck(f[i][j][1],f[i-1][j+1][1]);
        for(int j=0;j<=n;j++)
        {
            ck(f[i][j][1],f[i][j][0]);
            ck(f[i][j][0],f[i][j][1]+1);
            ck(f[i][j+1][0],f[i][j][1]+1);
            if(j)ck(f[i][j-1][0],f[i][j][1]+1);
        }
        mem(f[i][0],0x3f);
    }
    cout<<n-f[n][1][0]<<'\n';
    mem(s,0);
}

main()
{
    // freopen("in.txt","r",stdin);
    cin>>T;
    while(T--)sol();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
?>?
>?<
??<?
?><?<
??????
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>

output:

2
2
3
4
5
8
7
8
5
6

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 131ms
memory: 5796kb

input:

100000
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>
>><>><<<<<
>?>?>?<<>>
?><?<<?<><
???><>?>?>
<??>?<<><?
??>><?<>>>
<><><?<>>?
?>>?>???><
?<?><?<<>?
>>><?<??><
><><<>?>?<
>?><>><<<?
>??>?><?<>
?????<><?>
<><<?<<>?<
><?>>?>?>?
?><><<<>>?
?<>?<>?<<<
<><<<<<>>>
?>?>?><<>>
<>?<>><>?<
<<<?<>>...

output:

8
7
8
5
6
8
6
7
6
7
6
6
8
7
8
7
8
7
7
6
6
7
7
2
6
6
3
9
6
6
5
7
5
8
7
6
8
7
8
6
6
7
4
2
7
6
8
7
8
6
6
5
7
8
8
8
8
7
5
6
7
7
6
8
8
6
8
6
7
8
7
7
6
8
5
7
6
6
5
5
7
7
6
4
8
6
6
7
5
7
6
7
7
8
3
8
8
7
8
7
7
4
8
8
7
5
8
7
7
8
8
7
5
7
8
5
7
6
5
8
8
7
7
8
6
7
8
6
6
8
7
8
7
6
6
5
7
8
6
8
6
7
5
7
4
6
6
7
7
7
...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 106ms
memory: 3680kb

input:

100000
<<<<>>>>><
>>>><<<><<
>><?>><<<<
<><><<>?<>
><>?>>?<><
<<<<><><><
>>>??<><><
<<><?>?<<<
>?<<<><<<<
<<>><<><><
<>?<<<<>><
>>?>>>><>>
?>><<?<<<<
>>>><><??<
><<<<<><<<
><???<>><>
<<<<><<<>>
?<>>?>?<<<
<><>><><>>
<>><<<<>><
<<>><<<<>>
><><<<<?<<
><<<<<><>>
>>>><<><?>
><>>?><?<<
??<?<??<<?
<<<<><<...

output:

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

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 198ms
memory: 5704kb

input:

100000
>>>??><<>?<>??>><>?<
>><<>????<<<>?>>?<<<
<>>??><><>>?>>?><>?>
<<<<><>><>>>???>>>?<
<>>>?<>>>?<><??<<<>>
>><><><><?<>>><>??><
>?<>?????<?<<><<<<>>
?><<>?>??>>>??<><<?<
>>><>?<?>>?<?<??>?><
<>>?<<?>???><?><><>?
<>?<?>?>?<>?<????>?<
<??<>?<>><<?<?????<<
>?>?<><>?<><><>>>??>
>?<??>?<??>>>>><><?<...

output:

15
17
12
12
14
13
15
17
15
14
15
15
13
16
15
16
15
15
17
15
15
10
16
12
14
16
17
16
11
14
13
14
13
14
14
10
12
11
15
13
16
13
13
13
16
10
14
16
12
12
13
14
14
16
17
13
15
15
11
17
15
15
16
15
17
15
16
14
14
13
11
15
14
17
15
17
17
15
13
17
16
16
16
14
17
14
12
14
13
15
16
12
15
16
14
15
13
16
15
14
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 207ms
memory: 5748kb

input:

100000
<<>?>>?<>?<>><<<<<><
<>>><<>><><><><<>?>>
><>?<<>><>?<>>><><<>
>>>><?><<<<><<<?><<<
>>?<><>>?>??<>><<>><
>>?><<?<<><?><<<<>>>
><?<<><>><<?<?>><>?<
<><<<?<><<<<<<<>><><
<<><><><>><<<>>>><><
>>>><<?<><<<<><<<>>>
<<<><>><<><<>?<<<<>>
><>><>>><>><>?<><??<
?<<><?>><><><><<><><
<>>><><<><?<<<>><><>...

output:

14
11
13
16
15
14
14
9
11
13
11
14
12
13
14
16
10
13
15
12
11
10
8
13
13
11
16
13
14
13
10
14
13
14
13
15
11
11
14
13
12
13
11
11
13
12
10
13
15
13
13
14
6
14
14
8
11
8
14
12
11
10
12
14
14
13
10
13
9
15
16
7
11
14
12
12
12
12
12
15
12
14
10
13
11
14
13
14
14
11
9
12
13
11
12
11
11
16
13
11
13
15
15...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 230ms
memory: 3728kb

input:

100000
?>???<<><>?>?>>>><<>?
?>?>>?>><<><??<?<?>??
<><<?>>?<>?<>>?><????
>?<<<?><?>?><>>><>><<
<???>?<>???<><<<<<??>
><<?<<<<<<<<<<<?>><<?
?<?>><?<?>?<>??><><><
?>?<?>>>><<?>??><>>>>
><<<????>>><>>>><<??>
<??><??>><<?<?<>>?><>
>><>>>><>>?<?<>?>><>>
??<?<<><?>?>>>??><>?>
>?<<<?<?><<??><>>?<??
<<>?<?>...

output:

15
18
16
15
16
9
15
13
15
15
14
14
16
16
18
14
16
14
19
16
11
13
14
15
14
17
12
14
14
12
15
16
16
15
18
15
15
16
17
16
14
17
17
15
13
16
14
14
13
16
15
14
16
16
18
14
15
14
15
14
13
17
13
17
13
16
15
15
17
18
18
15
13
15
17
15
17
14
16
14
15
12
16
16
14
17
17
16
18
14
15
14
18
15
15
16
17
15
16
19
1...

result:

ok 100000 numbers

Test #7:

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

input:

100000
<><><><<>><>>><>?<<?>
<><<>><>>>>><>><<>?<?
>?<<>>><>>>><?<<<>><<
>>>><<<<<<>><>>>><<>>
<<>>><<>><<?><?>>>><<
<<<<><??><<><>>>?>?>>
>><><>?>><><<<>>><<>?
><<<>>><<><<><><><>><
>>><>>?><<<<?><<<<<?<
?<>>><<><<><><<>><<><
<<><<<><<<<>>>>>>>>>>
<?<><<>><><>>><<>>><>
<<>><><>>><><>>><<><<
><<><<>...

output:

13
15
17
14
14
10
15
13
18
14
4
12
13
13
12
15
14
14
14
12
14
15
14
10
12
11
15
6
14
14
14
12
17
14
12
16
13
14
13
8
12
14
13
14
12
15
14
14
14
12
17
17
15
12
14
15
13
12
13
16
13
16
16
14
15
15
17
11
14
13
11
12
12
10
14
14
15
12
12
15
13
14
14
12
15
15
15
10
15
16
15
13
16
14
14
10
18
10
14
11
8
1...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 271ms
memory: 5656kb

input:

100000
??><>?<?><<<<>>??>><<<
?<><><<??<<<>><?><>?<>
<><<>?><>?>><>??>?<<?>
>>><??<?<>>>>>><??><<?
>?<<><??<>?>>?<<?>>?<>
?<?>?>?<><?>?<?<?>>>?<
?<?<<><<<?<>>?<><<><>?
?>>><?<<>?>>>?<??>>?>>
>>???>???<>?<??><?>?><
?>>?>>>><>>?><>?>?<<>?
><?<?<<<?<<?<>??<>>?<<
>?<?<<<<???<?<<?<<?<<<
>><>>>><<>>?>?>??...

output:

17
14
15
18
16
17
14
17
17
16
15
16
16
15
17
16
18
13
13
15
16
17
18
16
16
18
14
19
18
15
18
17
16
17
16
16
18
17
17
17
16
16
14
17
15
16
18
16
16
18
16
17
16
17
16
12
17
15
17
16
16
16
17
16
16
18
17
16
18
18
15
17
19
18
19
17
16
15
17
17
16
16
18
13
12
19
17
19
16
16
18
16
17
18
14
15
16
18
10
14
...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 241ms
memory: 5868kb

input:

100000
?><?><<<?<><<<>>><<>>>
><><<<>?><><???>><>><<
<><>>><>>>>>>>>>><<><<
<>>>><<<<<<><<<<<>>?><
><<><>><?>>>>><>>><>><
<?<<<<<>><<>>>>><?<><<
<?<<<><<>>>>><<<><>>><
><<><<>><<<<><<><<>>?<
>><<<><<<<<>>>>><<?>><
>?<<?<<<?<<<<<>?<<<>>>
<>?<>>>?<><><>>>><><<>
><<?<?<<<<>>><><<>><<?
<>>><>?>>>><><>>>...

output:

14
16
11
13
12
14
14
15
14
12
14
15
14
13
13
15
15
16
17
11
16
15
17
17
14
16
12
13
15
16
11
17
14
18
16
16
16
14
13
13
14
16
16
16
17
16
16
16
15
15
16
10
9
14
16
16
13
14
16
15
16
14
13
17
16
16
17
15
17
13
14
12
13
11
10
13
14
15
11
15
17
13
17
14
16
12
15
11
15
15
14
15
12
16
17
14
17
16
12
13
1...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 204ms
memory: 5728kb

input:

20000
?<?><??>>?<?><<>>?>?>?>?<<<><???<?<<<><?<?<>>?<><>
????><??><>??<><????><>?<>?<?><<<><>?<>??<?<<?><<>
>?>>?>>>>>>?<<??<??<?<?>>><??<<>>>?<<?<<>?<<<>>><?
?<<>>?>>><?><<><?><>>?><?<<?<>????<>><<<<?>><<>??<
?????>>>>?>?><<>??>>>?<><?>><??????>>>?<>??>>?????
>>>?<?<<?<>>>????<<?>><><>>><>?<?<>><>>...

output:

40
37
45
40
43
40
38
40
37
41
42
35
41
40
38
40
37
39
40
39
40
42
42
41
43
39
35
41
41
39
40
41
35
42
38
40
37
39
41
38
37
39
37
42
38
40
42
37
43
42
41
38
41
41
40
42
42
39
36
41
42
45
40
41
38
37
37
37
38
37
41
39
39
42
38
40
37
39
40
37
42
38
41
40
39
37
39
40
37
38
39
37
37
41
37
39
39
39
42
38
...

result:

ok 20000 numbers

Test #11:

score: 0
Accepted
time: 209ms
memory: 7956kb

input:

5000
<<???<<?<>>>?<<<<>?<><>?><??<?<><<><?><>>><<><?>>?>>?>??>?>>?<<?<<<?>?><>><<<>>>?<<<<<>??>>>>?><>>?<
>?<>?>><?<?>>??>????>>??>?>????>>?>>???>????<?><<>><<<<>?<<?<??><>><?<?<>??<<>>><<<<<?>>??<?<<>>>?>>
<>><?><???>??<?????><><?>><?>><???<?<><?<>?<???<<?>>????>?<?<<><<<>>?>>?><>??<?>?<><>><??<>>?...

output:

80
85
82
88
78
78
81
79
86
79
80
79
82
76
81
78
84
78
80
81
82
80
81
78
81
87
81
85
83
85
84
83
82
79
82
83
82
83
82
84
78
81
77
77
84
82
74
83
80
80
83
84
80
80
75
81
80
82
81
83
79
78
82
85
80
82
85
83
81
79
84
80
86
84
82
79
81
78
83
81
82
83
77
83
84
85
81
81
79
83
84
85
83
82
84
84
78
77
83
74
...

result:

ok 5000 numbers

Test #12:

score: 0
Accepted
time: 206ms
memory: 12048kb

input:

1250
><?>?<>><?<<???<?<>>>????><>??<><<><>??<<<><>???<?>?<<?<>?<><??<>><<>>><<>??<<<???>><??><?>><???>?>?><??>?<<?>><>><<>>><>><<??<<><<<<>???><??????<><><?>?<?<??<<><>??>??><?>?<><><<??<<><><?>>?><??<?><?
<><>?>?>?<?<<><?>?<><>?<?><>>><<>?><<?<><><><?>?><?<>>?<<>??<??>?>?<>>?<?>?<<????>?>><><???><?...

output:

160
161
165
168
165
171
172
164
161
162
165
167
164
165
164
166
157
163
168
166
164
169
165
167
167
167
169
163
164
167
173
161
161
163
167
160
166
165
165
163
167
162
168
168
163
161
160
163
169
166
168
165
167
172
167
165
171
163
163
166
164
167
165
165
167
167
167
166
161
165
163
167
163
163
162
...

result:

ok 1250 numbers

Test #13:

score: 0
Accepted
time: 196ms
memory: 14076kb

input:

800
><<?<><>?>><?<<?<<>>><<>><<>?>>>??><?>><?><<<?<>><>?><>><><?<<<<<?>><>>?<><<>??<??><<>><>???>??><???>???>?<?<<>>??<>>?<?>??<<??<<><<>>?><<?<>?><><<<>?><>?<>>>>?<?<><<?<?><<>>>?>>><>???<?><>>><><?<<><>?<????>?>?>???>?><>>>><???<<??<<<?<>?><>>?><>>??<>
>?<<<???<<>??<><<>?>?<<?>?<>><<><>?<?<><??<>>...

output:

203
211
202
204
201
205
206
204
209
203
204
211
199
204
209
211
209
206
207
208
206
208
208
209
209
202
202
206
208
204
209
209
206
207
198
207
212
203
206
205
199
210
209
207
213
206
204
207
202
210
206
202
213
205
208
205
198
206
198
200
204
202
212
210
207
208
199
205
208
206
203
206
203
213
210
...

result:

ok 800 numbers

Test #14:

score: 0
Accepted
time: 151ms
memory: 16128kb

input:

400
>><>?????<><<>>???<??????<<??>>>><??<<<<?>>?>???<>><?><<><<?>???<<?>?<>?<<<?>>??><<?>>>>?>??<??>>??>???<?<><<>?<>>???<>>?>><<?<<><???<<<<??<?<><?<<<<?<>??>><?<><??<?>?><>?<<?>>?><<??<<>><<<><>>><<>>>><?><>??<>><>>?<<<>??>>?>??><?<<??<<?><?<>>?>?<><??<>?<<<<<>?<?<?<<???><?<?<<?<<?>?<<><>??>>>??>>...

output:

266
252
253
255
257
261
260
264
256
258
263
252
256
262
258
257
259
259
258
257
253
254
261
262
262
256
260
264
256
264
265
246
267
266
258
254
263
252
262
252
264
258
259
254
257
263
255
259
254
257
258
259
252
261
260
263
255
259
254
257
252
256
259
259
255
259
252
262
260
254
258
261
254
257
255
...

result:

ok 400 numbers

Test #15:

score: 0
Accepted
time: 194ms
memory: 24256kb

input:

200
???><???>><<<?>>?<><?<>><<>>>>??<?><<>>>>????<<>>>?><><?<><><????<<><?><<???>>?>???><?>><?><<><>>?>??<<<<?>?<?>>?>?>><><>><<?<<>>><<?>>>?>>>?<?<<<<><><>>???<<??>>?>><??>?????>><<><>><<<???<>><<??<>?><><>?>><<<<><><<>?><><?<>?>>?<?>???<?><?<???>?<<<<<<??<><><?>><?<?>>>?<?<<???>?>?<<?<?<?<?>?<>??>...

output:

413
409
412
417
407
412
417
423
416
406
414
418
419
421
419
408
418
409
412
429
425
409
409
424
406
409
415
413
411
407
416
410
410
421
423
402
415
415
416
415
417
409
412
414
416
406
417
407
412
421
413
417
416
419
409
405
409
420
421
408
420
413
408
421
415
410
420
406
406
419
413
413
425
418
417
...

result:

ok 200 numbers

Test #16:

score: 0
Accepted
time: 190ms
memory: 33236kb

input:

50
?>?<>>>><?>>?<?>>>?>??<<<<>>>>?><?<??>><<>?<<??<>??<?><>><?>?<><?<<><?><?<<>??>>>???>?>>><>?<>?<>>?<?>>???><><?<>????>??<?>><<?><><><<><><><?<><><<??><>?>>><<<<??>><><><????>??<<<<<?>????<?><<<><<<<<>><>><><><>?>?><>??><<<<><<?>?<<?>><><?>>><<>?>>?>>>>?><?<><?><<><>>?<><<<?<<>?<<<?>?>>??<<?>?<<><...

output:

826
834
826
828
834
824
832
831
839
829
826
826
826
841
837
824
835
834
826
832
824
837
842
850
846
829
830
840
833
823
828
833
826
841
820
830
845
833
811
831
816
841
831
816
839
822
830
840
840
829

result:

ok 50 numbers

Test #17:

score: 0
Accepted
time: 215ms
memory: 73568kb

input:

8
<>?>?<><??<??>>><?>?><<<>???><><<>><>>>?<>?<>><<<??>>??><><???<><<>??<?<<?>>?<>?<?><<>?>?<????<>?<>>><?????><>>??><?<><>?>><???<?>??<??><?<?>??><><??<><>???>?><<<?>?<<><???>><<?>>>>>>>>?>?><?><<>><??>??>>>??<<<<><><<?>><?<?<>><>?<><<?>???<??>??>>??<?<<<>?>?<?<>>?>><??>?>???<???<>???<?><<?>???>??>?...

output:

2076
2077
2071
2063
2076
2073
2084
2070

result:

ok 8 numbers

Test #18:

score: 0
Accepted
time: 232ms
memory: 218564kb

input:

2
>?<>><>>><><>?<<?><??<?><??<?<??<??<??<<?>>?><<>>??<<<<<??><????><>?<>???<?>??<??>>??>????<><<><<?<<?<><<><??><?<?>>?<<><><??><??<>??<<?>>>??<><>?<?<?>><??<>>>?<<?<<<<?<<??<??<><><????>??<?><<<>><?<??<<>>?<<<<><>>??<<><?<?<<>>?<?<<?<?>><>?<??>><<<<><>><>>????>><<>??<<<?<?>><?<><?<>?>>?>??>?>>>???<...

output:

4168
4153

result:

ok 2 number(s): "4168 4153"

Test #19:

score: 0
Accepted
time: 216ms
memory: 28288kb

input:

530
?
??
???
????
?????
??????
???????
????????
?????????
??????????
???????????
????????????
?????????????
??????????????
???????????????
????????????????
?????????????????
??????????????????
???????????????????
????????????????????
?????????????????????
??????????????????????
?????????????????????...

output:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
10...

result:

ok 530 numbers

Test #20:

score: -100
Wrong Answer
time: 176ms
memory: 28260kb

input:

530
>
>>
>>>
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>...

output:

-1061109566
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st numbers differ - expected: '0', found: '-1061109566'