Submission #667515

# Submission time Handle Problem Language Result Execution time Memory
667515 2022-12-01T16:18:35 Z iloveroseanne Tracks in the Snow (BOI13_tracks) C++14
100 / 100
570 ms 186460 KB
// PARK CHAEYOUNG IS MY LOVE
// Author: Ngo Ba Van
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
using ii=pair<int,int>;
const ll N=4e3+5,M=1e9+7;
ll n,m,res,dis[N][N],sz[N][N];
ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
char a[N][N];
bool check(int x,int y)
{
    return (x>0&&y>0&&x<=n&&y<=m&&a[x][y]!='.');
}
void BFS()
{
    deque<ii>de;
    //memset(dis,0x3f,sizeof dis);
    dis[1][1]=1;
    de.push_back({1,1});
    while (!de.empty())
    {
        int u=de.front().fi;
        int v=de.front().se;
        res=max(res,dis[u][v]);
        de.pop_front();
        for (int i=0;i<=3;i++)
        {
            int uv=u+dx[i];
            int vv=v+dy[i];
            if (check(uv,vv)==true&&dis[uv][vv]==0)
            {
                if (a[uv][vv]==a[u][v])
                {
                    dis[uv][vv]=dis[u][v];
                    de.push_front({uv,vv});
                }
                else
                {
                    dis[uv][vv]=dis[u][v]+1;
                    de.push_back({uv,vv});
                }
            }
        }
    }
}
void nhap()
{
    cin>>n>>m;
    for (int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        for (int j=1;j<=m;j++)
        a[i][j]=s[j-1];
    }
    BFS();
    cout<<res;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#define task ""
#define task "a"
if(fopen(task".inp","r"))
{
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}
int t=1;
//cin>>t;
while (t--)
nhap();
}
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$kdtjjijjttdkk$$$$$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$$$$$dttkdtk$tttjijjiijiii.ijjiiiiiiijjjtkk##dkkjjtttk$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$dttkddk$tttjjjjjjjiiiiiijjiiiiiijjtd$kw$tddjjtttd$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kdtkddk$dttjjtjjjjtttjjjjjiiiiijjjtk$#wdtddjjtjtd$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$ddtdkdkkdttjjtjjjjkkddkktjjiijjjjttk$w#tddtjjjjjt$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$ddtdkdkkkttjjttjjjttdkkdjiiijjjjjtd#wwktddtijtjjt$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$dktdkdkdktttjttjiijjjijjiiijjjjjtt$@w#tdddtijjjjt$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$dkddkdddkttjjjjjjijddjjjiijjjjjjttwwwktdddjijjjjt$$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$kdkddkddkkdtjjjjtjtk$kttjijjjjjjjtdw##dddkdjijjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$kdkddkddkdktjjjjtddwwdtjkttjjjjjtt$###tddkdjijjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$kdkddkddkd$dttjjjtdk$ttt$$dtjjjttd$$##ddddttijjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$ddddkddkdkkttttttddkjttdttttttttkk$##ddddttijjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kddddddkkk$dtttttdktijtttjttttddkd$$$$dtdttjjjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kddddkdkkk$$tttttdkiijddjjttttddkk$$k$dtdttjjjjjjk$$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kddddkdkk$$#kttjjtjjjjdtjjjttddkdk$$k$ktttttijjjjdk$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kddddkdkk$#$kdtjjjiijttjjjtttddkdk$$$k$dttttjjjjjtk$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kddddkkkk$#$kdttjjiijjjjjtdkdtdkd$$$ddkdtjjttjjjjjk$$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kdddddkk$$##ddtttjijjttttdkddttddkkk$kddtjjjjjjjjjdk$$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkddddkk$$#wktttdiijjddkk$kdttdkddddddttdjjiijjjjjtkk$$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkdddddk$#wwktttjiiiik$$$kdtttdk$ddttd$djiiiiiijjjjdkkk$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkdddddk$#w@ktjtiiiiitkkkdtttttkkkddd#tjiiiiiiiiijjtkkk$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkddddk$#@@kjjjiiiii.....ijtttddktj$tiiii...iiiiijjdkk$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkddddk$w@@kjjiiiiiiiiii..ijjttjiitkiiiii.....iiiijtk$$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$kkkdkdk#w@@djjiiiiiiiiijjiijjjiiij#jiiiiii....iiiijjdk$$$$$$$$$$$$$d
$$$$$$$$$$$$$$$$$$$$$$$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kkkkkkkkkkkktiiiiiiiiii#wtiiiiiiii...iiiijjtdkkdtjjjiit#$tjiiijjiiiiiiiiiiiiiiiijjtttjdkk$$$$$$d
kkkkkkkkkkkkkjiiiiiiiiit@$iiiiiiii...iijjjjtkkddtjjjiii$wdjiiiijjiiiiiiiiiiiiiiiijjtdtjtkk$$$$$$d
$kkkkkkkkkkktiiiiiiiiii#wjiiiiiiii..iijjjttkkdtjjjiiiidwwtiiiiiijjiiiiiiiiiiiiiiiijjdtjtkkk$$$$$d
####[email protected]$#$iiiiiijjiiiiiiiiiiiiiiiijjddjjkkk$$$$$d
@@@@@@w#$$kkjiiiiiiiii#wiiiiiiiii.iiiiiijdddtjjiidki     t$iiiiijjiiiiiiiiiiiiiiiijjddtjdkk$$$$$d
@@@@@@@@w#$diiiiiiiiiiw$iii..iii..iiiiijtddtjjij#j        j$iiiijjiiiiiiiiiiiiiiiijjddtjtkk$$$$$d
@@@@@@@@@@@diiiiiiiiit$diiiiiii..iiiiiitddtjjidk.          .diiiitiiiiiiiiiiiiiiiijjtdttjkk$$$$$d
ww@@@@@@@@@jiiiiiiiiittd#kiiiii..iiiiittttjii$j..           .jiijtiiiiiiiiiiiiiiiiijtdttjdk$$$$$d
#ww@@@@@@@wiiiiiiiiii   .t$iii..iiiiijtttjijki.           ..  jjjtiiiiiiiiiiiiiiiiijtddtjtk$$$$$d
$#ww@@@@@@$iiiiiiiiii    .iii..iiiiiitttjitj.             ..   ttdiiiiiiiiiiiiiiiijjtddttjkk$$$$d
#wwww@@@@@kiiiiiiiii.    iiii..iiiiijtttjti.                .. .d$jiiiiiiiiiiiiiiijjtddttjdkk$$$d
#wwwww@@@@diiiiiiiii   .iii...iiiiiitttdj...                .....jtiiiiiiiiiiiiiiijjtddttjdk$$$$d
#wwwww@@@@tiiiiiiii.  .iiii...iiiiijttdi...                   ....jiiiiiiiiiiiiiiijjdddttttkk$$$d
##wwww@@@@tiiiiiiii.  iiiiiiiiiiiiitdj.....                   ..iijiiiiiiiiiiiiiiijjddktttjkk$$$d
$#wwww@@@@jiiiiiiii. iiiiiiiiiiiiikwi......                   ..ijjiiiiiiiiiiiiiijjjddktjdtdk$$$d
$#wwww@@@@jiiiiiiii .iiiiiiiiiiiit@k.......                   ...ijiiiiiiiiiiiiiijjtkdktjdttkk$$d
$#wwww@@@@jiiiiiii..iiiiiiiiiiiii#w..... ....           ...   ...ijiiiiiiiiiiiiiijjtkdkdjddtkk$$d
##wwww@@@wjiiiiiiiiiiiiiiiiiiiiittk..........           .    ....ijiiiiiiiiiiiiijjjdkdkdttdtdkk$t
wwwwww@@@$iiiii.iiiiiiiiiiiiiiiijii..    .....    .........  ....ijiiiiiiiiiiiiijjtdkdkdtjddtkkkt
wwwww@@@@diiiiiiiiiiiiiiiiiiiiiji.......... ...  .......... .....iiiiiiiiiiiiiijjjtdkkkdtjdktkkkt
#wwww@@@wjiiiiiiiiiiiiiiiiiiiijji.................................iiiiiiiiiiiiijjttdkkkktjdkdtkkt
#wwwwwww$iiiiiiiiiiiiiiiiiiiiijii..................................iiiiiiiiiiiijjtttkkdktjdkktkkt
########diiiiiiiiiiiiiiiiiiiijji......... .........................iiiiiiiiiiiijjtttkkdktjdkkddkt
#######$jiiiiiiiiiiiiiiiiiiiijji..............................iii..jiiiiiiiiiijjjttdkkkkdjtkkdtkt
####$$$kjiiiiiiiiiiiiiiiiiiijjii...........ii...................iijiiiiiiiiiiijjjttdkkkkdjtkkddtt
###$$$$djiiiiiiiiiiiiiiiiiijjj.................i.........i........jiiiiiiiiiiijjtttddkkkdjtkkkdtj
####$$$diiijiiiiiiiiiiiiiijjji.................d.....iiiiii.......jiiiiiiiiiiijjjttddkkkdjtkkkktj
ww##$$#tiijiiiiiiiiiiiiiijjjjiiiiiiiiijiiii....ti.iiiiiiii........iiiiiiiiiiiijjtttdkkkkkjtkkkkdj
ww#$$$#jjjiiiiiiiiiiiijjjjjttjjjiiii.......iii.tjiiiiii...........ijiiiiiiiiijjjtjjdkkkkkttk$$kkj
ww#####jjjiiiiiiiiiiijjjjjjdj...........iijjii.ttiiiiiiii.........iiiiiiiiiiijjjtjjdkkkkktjk$$$dt
wwwww@$jjiiiiiiiiiiijjjjjjtii.....iiiijjjjiiii.jtii..iiiiiii......iiiiiiiiiiijjjtjjdkkkkktjk$$$kt
wwww@@djjiiiiiiiiijjjjjjjtdtjjjjjjjjjjjiiii....jtii....i..........ijiiiiiiiiijjjtjjdkkkkktjk$$$kt
wwwwwwtjjiiiiiiiijjjjjjjjddjjjjjjjiiiiii....ii.jdiiii............ijjiiiiiiiiijjjtjjdkkkkkdjd$$$kt
wwwwwwjjjiiiiiiiijjjjjjjdddtjjiiiii........ii..it....ii...........jjiiiiiiiiijjtjjjtkkkkkkjtk$$$t
wwwwwwjjiiiiiiiijjjjjjjtkddjjiii...............jj.................ijiiiiiiiiijjtjjjtkkkkkkttk$$$t
ww#ww#jjiiiiiiijjjjjjjjkkdtjiii............... t.      ...........ijiiiiiiiiijjtjjttkkkkkktjk$$$t
ww##w#jiiiijjjjjjjjjttdkdtjii..............    t    ..... ........ijiiiiiiiijjjtjjtjk$kkkkdjk$$$t
w###w$jiijjjjjjjjjjttt$ddtji..............     d      ............ijiiiiiiiiijjtjjtt$$kkkkdtd$$$t
####wkjijjjjjjjjjtttt$$ddjii.........         .t       ...........ijiiiiiiiiijjttjjtk$$k$kdttk$$t
####wtjjjjjjjjjjttttkkkdjii............       jj      ........ ...ijiiiiiiiiijjttjjtk$$$$kkttk$$j
####wjjjjjjjjjjtttdkkkktji................iijjttii.      ..... ...ijjjiiiiiiijjttjjtk$kkkkkdtkkkj
####wtttjjjjjjtttdkkkkkjii.........ijjjjji.......ijjiii..     ....ijjjiiiiiiijjtttjtkkkkkkkdtdkkt
#####ktttjjjjttddkkkk$tii..iiijjjjiiiiii.i........ii...iijjjji....ijjjiiiiiiijttttjjkkkkkkkkttkkt
######dtttjjjtddkkkkk$jiittjiiiiiiiiiiiiiiii.......i..iiiiiiitti..itjjjiiiiiijtttjjjkkkkkkkkdtddt
######$dttttttddkkkkkkjddjjiiiiiiiiiiiiiiiiiiiii......iiiiiiiiijj.itjjjiiiiiijttdjjjkkkkkkkkdtddt
$$###ww#kdddddkkkkkkkkkttjjiiiiiiiiiiiiiiiiiiiiii..iiiiiiiiiiiijjtitjjjiiiiiiitddjjjddkkkkkkkttkd
$$###w##$$$$$$$$$kkkkddttjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjdtjjjiiiiiiitddjjjkkkddkkkkdtkt
$########$$#$$$$$$kkkkdttjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjt$dtjjiiiiiiitddjjjdkkkkdddkdtdt
#########$$$$$$$$$$kkkdtjjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjt$kttjiiiiiiijddttjttdkkkkkddttt
#########$$$$$$$$$$$kkttjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjd#kttjiiiiiiijtdttjdtddkkkkkkddj
########$$$$$$$$$$$$$ktjjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjijjtd#kttjiiiiiiijtdttttddtddkkkkddj
########$$$$$$$$$$$$$$tjjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjtk#kttjjiiiiiijtdttdkddkdtdkkkkdt
########$$$$$$$$$$$$$ktjjjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjtk#dttjjiiiiijjtdtdkkkkddkkdddkkt
#######$$$$$$$$$$$$$$kjjjjjiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjttk$ddttjiiiiijjtddkkkkk$kdkkkdddt
########$$$$$$$$$$$$$kjjjjjiiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjtd$kddttjiiiiijjttdkkkkkkkkkkkkkkt
###########$$$$$$$$$$ktjjjjjiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjtd$kddttjjiiiiijjtdkkkkkkkkkkkkkkt
###########$$$$$$$$$$$ttjjjjijjttttdddddkkkkkkkkkkddttjijtjjjjjtd$dkdttjjiiiiijjtddkkkkkkkkkkkkkt
#w#########$$$$$#####w$$#ww@@wwwwwwwwwwwwwwwwwwwwww@@@@@@@w$djtdk$dkddtjjiiiiijjtddkkkkkkkkkkkkkt
############$$##$$$$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwww@@@@@@@$kw#dk$kdkddtjjiiiiijjtdddkkkkkkkkkkkkt
###############$kkkk$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#d#d@@w#ddkddtjjjiiiijjtdkdkkkkkkkkkkkkt
##############$kkkkk$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#d$d@@@kkdkkdtjjjiiiijjjdkddkkkkkkkkkkkt
##########$##$kkkkkk$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww$d$@@$kkdkkdtjjjiiiijjjtdkkdkkkkkkkkkkt
#############kkkkkkk$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwkkkdkkdtjjjjiiijjjtdkkkkkkkkkkkkkt
###########w$kkkkkkk$$#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww#kkdkkdtjjjjiiiijjtdkkkkkkkkkkkkkt
##########w#kkkkkkkk$$#w##wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww$kdkkddjjjjiiiijjjdkkkkkkkkkkkkkt
#########ww$kkkkkkkk$w####wwwwwwwwwwwwwwww####wwwwwwwwwwwwwwwwww#kkkkddjjjjiiiijjjkkkkkkkkkkkkkkt
#########w#$kkkkkkk$www####wwwwwwwwwwww###########wwwwwwwwwwwwwwwkkkkddtjjjiiiijiiddtdktdkddddttj
########ww$kkkkkkkkwwwwww#w#w######wwwww######w#####wwwwwwwww#www#kkkddtjjjjiiijiitdddkttkddddjdt
########ww$kkkkkkk#wwwwwwwwww######wwwww######w#####wwwwwwwwwwwww@kkkddtjjjjjiijjjtkkkkkkkkkkkkkt
#######www$$kkkkk#wwwwwwww#####w#########w####w#####wwwwwwwwwwwww@$kkddtjjjjjiijjjtkkkkkkkkkkkkkt
#######w@w$$kkkkkwwwwwww#w#####w###########w#w#####wwwwwwwwwwwwwww#kkddtjjjjjiijjjtkkkkkkkkkkkkkt
######ww@w#$kkkk#wwwwwwwww#####w########wwwwwwwwwwwwwwwwwwwwwwwwwwwkkdddjjjjjiijjjjkkkkkkkkkkkkkt
######ww@w#$kkk$wwwwwwwwwww###w####w#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwdkdddjjjjjjijjjjkkkkkkkkkkkkkt
####wwww@w#$$kk#wwwwwwwwwww###w#######wwwwwwwwwwwwwwwwwwwwwwwwwwwww$kkddtjjjjjjjjjjkkkkkkkkkkkkkt
###wwwww@w#$$k$wwwwwwwwwwww##ww######wwwwwwwwwwwwwwwwwwwwwwwwwwwwww#dkkdtjjjjjjjjjjdkkkkkkkkkkkkt
@@@@@@@@@@wwwww@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#####$$$$$$$$$$#wwwwwwwwwwww$ddd?*/


Compilation message

tracks.cpp:66: warning: "task" redefined
   66 | #define task "a"
      | 
tracks.cpp:65: note: this is the location of the previous definition
   65 | #define task ""
      | 
tracks.cpp: In function 'int main()':
tracks.cpp:69:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:70:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 6356 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 7 ms 5720 KB Output is correct
5 Correct 3 ms 3160 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 3 ms 2644 KB Output is correct
11 Correct 3 ms 2268 KB Output is correct
12 Correct 5 ms 3416 KB Output is correct
13 Correct 3 ms 3160 KB Output is correct
14 Correct 3 ms 3208 KB Output is correct
15 Correct 10 ms 6108 KB Output is correct
16 Correct 11 ms 6336 KB Output is correct
17 Correct 9 ms 6140 KB Output is correct
18 Correct 7 ms 5844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 31096 KB Output is correct
2 Correct 42 ms 18264 KB Output is correct
3 Correct 186 ms 91224 KB Output is correct
4 Correct 74 ms 46460 KB Output is correct
5 Correct 178 ms 71200 KB Output is correct
6 Correct 545 ms 171632 KB Output is correct
7 Correct 21 ms 32496 KB Output is correct
8 Correct 17 ms 31064 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 31780 KB Output is correct
12 Correct 2 ms 1620 KB Output is correct
13 Correct 40 ms 18380 KB Output is correct
14 Correct 23 ms 12504 KB Output is correct
15 Correct 21 ms 17060 KB Output is correct
16 Correct 18 ms 7212 KB Output is correct
17 Correct 95 ms 36300 KB Output is correct
18 Correct 81 ms 51404 KB Output is correct
19 Correct 69 ms 46484 KB Output is correct
20 Correct 48 ms 30408 KB Output is correct
21 Correct 115 ms 63168 KB Output is correct
22 Correct 148 ms 71192 KB Output is correct
23 Correct 202 ms 57596 KB Output is correct
24 Correct 121 ms 61724 KB Output is correct
25 Correct 496 ms 156932 KB Output is correct
26 Correct 319 ms 185948 KB Output is correct
27 Correct 451 ms 186460 KB Output is correct
28 Correct 570 ms 171748 KB Output is correct
29 Correct 535 ms 167700 KB Output is correct
30 Correct 520 ms 173908 KB Output is correct
31 Correct 430 ms 116220 KB Output is correct
32 Correct 400 ms 175484 KB Output is correct