Submission #171107

# Submission time Handle Problem Language Result Execution time Memory
171107 2019-12-27T11:52:30 Z mosiashvililuka Bomb (IZhO17_bomb) C++14
42 / 100
1000 ms 26744 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,dp[2509][2509],zx,xc,qw,we,k[2509][2509],pas,dd;
string s;
bool f[2509][2509];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    if(a*b>=1000000){
        cout<<a*b;
        return 0;
    }
    for(c=1; c<=a; c++){
        cin>>s;
        for(d=1; d<=b; d++){
            f[c][d]=s[d-1]-'0';
        }
    }
    for(c=1; c<=a; c++){
        for(d=1; d<=b; d++) dp[c][d]=dp[c-1][d]+dp[c][d-1]-dp[c-1][d-1]+f[c][d];
    }
    d=b;
    for(c=1; c<=a; c++){
        while(d>=1){
            bool bo=0;
            for(i=1; i<=a; i++) for(j=1; j<=b; j++) k[i][j]=0;
            for(i=c; i<=a; i++){
                for(j=d; j<=b; j++){
                    qw=i-c+1;we=j-d+1;
                    if(dp[i][j]-dp[i][we-1]-dp[qw-1][j]+dp[qw-1][we-1]==c*d){
                        k[qw][we]=1;
                    }
                }
            }
/*            if(c==2&&d==2){
                for(i=1; i<=a; i++){
                    for(j=1; j<=b; j++) cout<<k[i][j]<<" ";
                    cout<<endl;
                }
            }
            if(c==2&&d==2) cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;*/
            for(i=1; i<=a; i++){
                for(j=1; j<=b; j++) k[i][j]=k[i-1][j]+k[i][j-1]-k[i-1][j-1]+k[i][j];
            }
/*            if(c==2&&d==2){
                for(i=1; i<=a; i++){
                    for(j=1; j<=b; j++) cout<<k[i][j]<<" ";
                    cout<<endl;
                }
            }*/
            for(i=1; i<=a; i++){
                if(bo==1) break;
                for(j=1; j<=b; j++){
                    if(f[i][j]==0) continue;
                    qw=i-c+1;we=j-d+1;
                    if(qw<=0) qw=1;
                    if(we<=0) we=1;
                    int hj=0;
                    hj=k[i][j]-k[qw-1][j]-k[i][we-1]+k[qw-1][we-1];
                    if(hj==0){
                        bo=1;
                        break;
                    }
                }
            }
            if(bo==0){
//                cout<<c<<" "<<d<<" vict"<<endl;
                if(pas<c*d) pas=c*d;
                break;
            }
  //          cout<<c<<" "<<d<<" lose"<<endl;
            d--;
        }
    }
    cout<<pas;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 380 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 35 ms 26608 KB Output is correct
4 Correct 42 ms 26744 KB Output is correct
5 Correct 33 ms 376 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 5 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 3 ms 508 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 632 KB Output is correct
17 Correct 5 ms 1144 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 8 ms 1400 KB Output is correct
20 Correct 8 ms 1400 KB Output is correct
21 Correct 6 ms 1060 KB Output is correct
22 Correct 6 ms 1272 KB Output is correct
23 Correct 10 ms 1528 KB Output is correct
24 Correct 7 ms 1272 KB Output is correct
25 Correct 11 ms 1528 KB Output is correct
26 Correct 10 ms 1528 KB Output is correct
27 Correct 114 ms 4216 KB Output is correct
28 Correct 216 ms 4472 KB Output is correct
29 Correct 291 ms 5624 KB Output is correct
30 Correct 569 ms 6648 KB Output is correct
31 Correct 428 ms 5260 KB Output is correct
32 Correct 423 ms 6032 KB Output is correct
33 Correct 686 ms 6820 KB Output is correct
34 Correct 101 ms 4860 KB Output is correct
35 Correct 489 ms 6904 KB Output is correct
36 Correct 570 ms 6904 KB Output is correct
37 Correct 3 ms 632 KB Output is correct
38 Correct 2 ms 524 KB Output is correct
39 Correct 3 ms 504 KB Output is correct
40 Execution timed out 1044 ms 15736 KB Time limit exceeded
41 Correct 3 ms 504 KB Output is correct
42 Correct 13 ms 1528 KB Output is correct
43 Incorrect 2 ms 376 KB Output isn't correct
44 Correct 820 ms 6904 KB Output is correct
45 Incorrect 2 ms 436 KB Output isn't correct
46 Incorrect 2 ms 376 KB Output isn't correct
47 Incorrect 2 ms 376 KB Output isn't correct
48 Incorrect 2 ms 376 KB Output isn't correct
49 Incorrect 2 ms 376 KB Output isn't correct
50 Incorrect 2 ms 376 KB Output isn't correct
51 Incorrect 1 ms 376 KB Output isn't correct
52 Incorrect 6 ms 376 KB Output isn't correct
53 Incorrect 2 ms 376 KB Output isn't correct
54 Incorrect 2 ms 376 KB Output isn't correct
55 Incorrect 2 ms 376 KB Output isn't correct
56 Incorrect 2 ms 376 KB Output isn't correct
57 Incorrect 2 ms 376 KB Output isn't correct
58 Incorrect 2 ms 376 KB Output isn't correct
59 Incorrect 0 ms 376 KB Output isn't correct
60 Incorrect 1 ms 348 KB Output isn't correct
61 Incorrect 2 ms 376 KB Output isn't correct
62 Incorrect 2 ms 376 KB Output isn't correct
63 Incorrect 2 ms 376 KB Output isn't correct
64 Incorrect 2 ms 376 KB Output isn't correct
65 Incorrect 2 ms 376 KB Output isn't correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Incorrect 2 ms 376 KB Output isn't correct
68 Incorrect 2 ms 376 KB Output isn't correct
69 Incorrect 2 ms 408 KB Output isn't correct
70 Incorrect 2 ms 376 KB Output isn't correct
71 Incorrect 2 ms 376 KB Output isn't correct
72 Incorrect 2 ms 376 KB Output isn't correct
73 Incorrect 2 ms 404 KB Output isn't correct
74 Incorrect 0 ms 376 KB Output isn't correct
75 Incorrect 2 ms 424 KB Output isn't correct
76 Incorrect 2 ms 376 KB Output isn't correct
77 Incorrect 2 ms 376 KB Output isn't correct
78 Incorrect 2 ms 376 KB Output isn't correct
79 Incorrect 2 ms 376 KB Output isn't correct
80 Incorrect 7 ms 504 KB Output isn't correct
81 Incorrect 2 ms 380 KB Output isn't correct
82 Incorrect 2 ms 376 KB Output isn't correct
83 Incorrect 2 ms 376 KB Output isn't correct
84 Incorrect 2 ms 376 KB Output isn't correct
85 Incorrect 2 ms 376 KB Output isn't correct
86 Incorrect 3 ms 376 KB Output isn't correct
87 Incorrect 2 ms 376 KB Output isn't correct
88 Incorrect 2 ms 376 KB Output isn't correct
89 Incorrect 3 ms 376 KB Output isn't correct
90 Incorrect 6 ms 376 KB Output isn't correct
91 Incorrect 2 ms 376 KB Output isn't correct
92 Incorrect 2 ms 376 KB Output isn't correct
93 Incorrect 2 ms 376 KB Output isn't correct
94 Incorrect 2 ms 376 KB Output isn't correct
95 Incorrect 0 ms 376 KB Output isn't correct
96 Incorrect 2 ms 376 KB Output isn't correct
97 Incorrect 2 ms 376 KB Output isn't correct
98 Incorrect 4 ms 380 KB Output isn't correct
99 Incorrect 2 ms 376 KB Output isn't correct
100 Incorrect 2 ms 376 KB Output isn't correct