Submission #474277

# Submission time Handle Problem Language Result Execution time Memory
474277 2021-09-17T18:41:05 Z ogibogi2004 Bomb (IZhO17_bomb) C++14
82 / 100
544 ms 57492 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2502;
char t[MAXN][MAXN];
int n,m,maxw,maxh;
vector<pair<int,int> >segments[MAXN];
vector<pair<int,int> >mws[MAXN];
int up[MAXN][MAXN];
int down[MAXN][MAXN];
int ans[MAXN];
int main()
{
    cin>>n>>m;
    maxh=n;
    maxw=m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>t[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        ans[i]=n*m;
        int cnt=0;
        for(int j=1;j<=m;j++)
        {
            if(t[i][j]=='1')cnt++;
            else
            {
                if(cnt>0)maxw=min(maxw,cnt);
            }
        }
        if(cnt>0)maxw=min(maxw,cnt);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(t[i][j]=='0')up[i][j]=-1;
            else
            {
                if(up[i-1][j]>0)up[i][j]=up[i-1][j];
                else up[i][j]=i;
            }
        }
    }
    for(int i=n;i>=1;i--)
    {
        for(int j=1;j<=m;j++)
        {
            if(t[i][j]=='0')down[i][j]=-1;
            else
            {
                if(down[i+1][j]>0)down[i][j]=down[i+1][j];
                else down[i][j]=i;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        int cnt=0;
        for(int j=1;j<=m;j++)
        {
            if(t[i][j]=='0')
            {
                if(cnt>0)mws[i].push_back({j-cnt,j-1});
                cnt=0;
            }
            else cnt++;
        }
        if(cnt>0)mws[i].push_back({m-cnt+1,m});
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<up[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<down[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;*/
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<mws[i].size();j++)
        {
            int start=mws[i][j].first;
            int mindown=m+1,maxup=-1;
            for(int len=1;start+len-1<=mws[i][j].second;len++)
            {
                mindown=min(mindown,down[i][start+len-1]);
                maxup=max(maxup,up[i][start+len-1]);
                //cout<<mindown<<" "<<maxup<<endl;
                //cout<<mindown<<" "<<maxup<<endl;
                ans[len]=min(ans[len],len*(mindown-maxup+1));
            }
            start=mws[i][j].second;
            mindown=m+1;maxup=-1;
            for(int len=1;start-len+1>=mws[i][j].first;len++)
            {
                mindown=min(mindown,down[i][start-len+1]);
                maxup=max(maxup,up[i][start-len+1]);
                ans[len]=min(ans[len],len*(mindown-maxup+1));
            }
        }
    }
    int ans1=0;
    for(int i=1;i<=maxw;i++)
    {
        ans1=max(ans1,ans[i]);
    }
    cout<<ans1<<endl;
return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:95:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         for(int j=0;j<mws[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Incorrect 1 ms 552 KB Output isn't correct
3 Incorrect 14 ms 26700 KB Output isn't correct
4 Incorrect 15 ms 26700 KB Output isn't correct
5 Incorrect 1 ms 460 KB Output isn't correct
6 Incorrect 1 ms 428 KB Output isn't correct
7 Incorrect 1 ms 420 KB Output isn't correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Incorrect 1 ms 588 KB Output isn't correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Incorrect 1 ms 588 KB Output isn't correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 2 ms 1484 KB Output is correct
20 Correct 2 ms 1356 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 1228 KB Output is correct
23 Correct 2 ms 1452 KB Output is correct
24 Correct 1 ms 1228 KB Output is correct
25 Correct 2 ms 1484 KB Output is correct
26 Incorrect 2 ms 1484 KB Output isn't correct
27 Incorrect 8 ms 4172 KB Output isn't correct
28 Correct 11 ms 4388 KB Output is correct
29 Correct 14 ms 5628 KB Output is correct
30 Correct 18 ms 6640 KB Output is correct
31 Correct 12 ms 5196 KB Output is correct
32 Correct 13 ms 6012 KB Output is correct
33 Correct 16 ms 6940 KB Output is correct
34 Correct 8 ms 4812 KB Output is correct
35 Correct 16 ms 6824 KB Output is correct
36 Incorrect 17 ms 6912 KB Output isn't correct
37 Correct 1 ms 588 KB Output is correct
38 Correct 461 ms 56352 KB Output is correct
39 Correct 1 ms 588 KB Output is correct
40 Correct 60 ms 16200 KB Output is correct
41 Correct 1 ms 588 KB Output is correct
42 Correct 2 ms 1484 KB Output is correct
43 Correct 446 ms 56124 KB Output is correct
44 Correct 22 ms 6920 KB Output is correct
45 Correct 431 ms 56304 KB Output is correct
46 Correct 441 ms 57492 KB Output is correct
47 Correct 433 ms 56192 KB Output is correct
48 Correct 438 ms 56112 KB Output is correct
49 Incorrect 487 ms 56108 KB Output isn't correct
50 Correct 432 ms 56212 KB Output is correct
51 Correct 453 ms 56156 KB Output is correct
52 Correct 437 ms 56192 KB Output is correct
53 Correct 427 ms 56168 KB Output is correct
54 Correct 435 ms 56140 KB Output is correct
55 Correct 423 ms 56136 KB Output is correct
56 Correct 472 ms 57384 KB Output is correct
57 Correct 448 ms 56184 KB Output is correct
58 Correct 421 ms 56200 KB Output is correct
59 Correct 422 ms 56256 KB Output is correct
60 Incorrect 423 ms 56112 KB Output isn't correct
61 Incorrect 451 ms 56260 KB Output isn't correct
62 Incorrect 480 ms 56120 KB Output isn't correct
63 Incorrect 441 ms 56012 KB Output isn't correct
64 Incorrect 420 ms 56108 KB Output isn't correct
65 Correct 447 ms 56064 KB Output is correct
66 Correct 443 ms 56240 KB Output is correct
67 Correct 430 ms 56016 KB Output is correct
68 Correct 438 ms 55968 KB Output is correct
69 Correct 424 ms 55964 KB Output is correct
70 Correct 273 ms 44940 KB Output is correct
71 Correct 420 ms 55972 KB Output is correct
72 Correct 468 ms 55960 KB Output is correct
73 Correct 422 ms 56032 KB Output is correct
74 Correct 423 ms 56032 KB Output is correct
75 Correct 421 ms 55992 KB Output is correct
76 Correct 443 ms 55988 KB Output is correct
77 Correct 473 ms 55976 KB Output is correct
78 Correct 428 ms 56032 KB Output is correct
79 Correct 416 ms 56032 KB Output is correct
80 Correct 419 ms 55960 KB Output is correct
81 Correct 454 ms 55936 KB Output is correct
82 Correct 439 ms 56084 KB Output is correct
83 Correct 451 ms 55960 KB Output is correct
84 Correct 416 ms 55800 KB Output is correct
85 Correct 440 ms 55948 KB Output is correct
86 Correct 457 ms 55872 KB Output is correct
87 Correct 421 ms 55892 KB Output is correct
88 Correct 437 ms 55956 KB Output is correct
89 Correct 427 ms 55840 KB Output is correct
90 Correct 276 ms 45016 KB Output is correct
91 Correct 441 ms 56012 KB Output is correct
92 Correct 544 ms 55840 KB Output is correct
93 Correct 441 ms 55956 KB Output is correct
94 Correct 483 ms 55876 KB Output is correct
95 Correct 439 ms 55876 KB Output is correct
96 Correct 439 ms 55872 KB Output is correct
97 Correct 490 ms 56004 KB Output is correct
98 Correct 441 ms 55904 KB Output is correct
99 Correct 425 ms 55884 KB Output is correct
100 Correct 462 ms 55872 KB Output is correct