답안 #1118822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1118822 2024-11-26T08:14:15 Z Younis_Dwai Bomb (IZhO17_bomb) C++14
42 / 100
129 ms 12616 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define endl "\n"
#define F first
#define S second
#define pb push_back
//#define int long long
#define in insert
//#define mid (l+r)/2
#define in insert
using namespace std;
const int N=2505;
char b[N][N];
int n,m,pref[205][205],d[205][205];
void init(){
     for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++){
             pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+bool(b[i][j]=='1');
         }
     }
     return ;
}
int query(int x , int y , int x1 , int y1){
    return pref[x1][y1]-pref[x1][y-1]-pref[x-1][y1]+pref[x-1][y-1];
}
int Query(int x , int y , int x1 , int y1){
    return d[x1][y1]-d[x1][y-1]-d[x-1][y1]+d[x-1][y-1];
}
bool ok(int h  , int w){
     for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++){
             d[i][j]=0;
         }
     }
     for(int i=1;i+h-1<=n;i++){
         for(int j=1;j+w-1<=m;j++){
             if(query(i,j,i+h-1,j+w-1)==h*w){
                d[i][j]=1;
             }
         }
     }
     for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++){
             d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1]+d[i][j];
         }
     }
     bool can=1;
     for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++){
             if(b[i][j]=='1'){
                int i1=max(1,i-h+1),j1=max(1,j-w+1);
                if(Query(i1,j1,i,j)==0) can=0;
             }
         }
     }
     return can;
}
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
        }
    }
    if(n<=200 && m<=200 && n!=1 && m!=1){
       int mx=0;
       init();
       for(int i=1;i<=n;i++){
           int l=1,r=n,mid=(l+r+1)/2;
           while(l<r){
                 if(ok(i,mid)) l=mid;
                 else r=mid-1;
                 mid=(l+r+1)/2;
           }
           if(ok(i,mid)) mx=max(mx,i*mid);
       }
       cout<<mx;
    }
    else{
        int h=n,w=m;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(b[i][j]=='1'){
                   int cnt=1;
                   while(j+1<=m && b[i][j+1]=='1'){
                         ++cnt;
                         ++j;
                   }
                   w=min(w,cnt);
                }
            }
        }
        for(int j=1;j<=m;j++){
            for(int i=1;i<=n;i++){
                if(b[i][j]=='1'){
                   int cnt=1;
                   while(i+1<=n && b[i+1][j]=='1'){
                         ++i;
                         ++cnt;
                   }
                   h=min(h,cnt);
                }
            }
        }
        cout<<h*w;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 5 ms 6480 KB Output is correct
4 Correct 6 ms 6484 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 2 ms 472 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 6 ms 928 KB Output is correct
18 Correct 5 ms 592 KB Output is correct
19 Correct 14 ms 848 KB Output is correct
20 Correct 10 ms 848 KB Output is correct
21 Correct 4 ms 592 KB Output is correct
22 Correct 8 ms 592 KB Output is correct
23 Correct 15 ms 848 KB Output is correct
24 Correct 7 ms 816 KB Output is correct
25 Correct 19 ms 732 KB Output is correct
26 Correct 26 ms 1016 KB Output is correct
27 Correct 3 ms 1104 KB Output is correct
28 Incorrect 3 ms 1124 KB Output isn't correct
29 Incorrect 5 ms 1360 KB Output isn't correct
30 Incorrect 6 ms 1616 KB Output isn't correct
31 Incorrect 4 ms 1360 KB Output isn't correct
32 Incorrect 5 ms 1500 KB Output isn't correct
33 Incorrect 5 ms 1616 KB Output isn't correct
34 Incorrect 3 ms 1428 KB Output isn't correct
35 Incorrect 6 ms 1616 KB Output isn't correct
36 Correct 6 ms 1620 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 71 ms 11464 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Incorrect 17 ms 3164 KB Output isn't correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 20 ms 848 KB Output is correct
43 Correct 75 ms 11448 KB Output is correct
44 Incorrect 4 ms 1620 KB Output isn't correct
45 Incorrect 75 ms 12212 KB Output isn't correct
46 Correct 98 ms 11340 KB Output is correct
47 Incorrect 89 ms 11388 KB Output isn't correct
48 Incorrect 81 ms 11320 KB Output isn't correct
49 Correct 78 ms 11464 KB Output is correct
50 Incorrect 87 ms 11224 KB Output isn't correct
51 Incorrect 78 ms 11304 KB Output isn't correct
52 Incorrect 97 ms 11420 KB Output isn't correct
53 Incorrect 84 ms 11304 KB Output isn't correct
54 Incorrect 71 ms 11320 KB Output isn't correct
55 Incorrect 84 ms 11236 KB Output isn't correct
56 Correct 78 ms 12016 KB Output is correct
57 Incorrect 79 ms 11264 KB Output isn't correct
58 Incorrect 80 ms 11848 KB Output isn't correct
59 Incorrect 96 ms 12224 KB Output isn't correct
60 Correct 74 ms 11612 KB Output is correct
61 Correct 67 ms 11336 KB Output is correct
62 Correct 64 ms 11328 KB Output is correct
63 Correct 71 ms 11300 KB Output is correct
64 Correct 87 ms 12080 KB Output is correct
65 Incorrect 77 ms 11424 KB Output isn't correct
66 Incorrect 85 ms 11336 KB Output isn't correct
67 Incorrect 72 ms 11284 KB Output isn't correct
68 Incorrect 81 ms 11356 KB Output isn't correct
69 Incorrect 73 ms 11404 KB Output isn't correct
70 Incorrect 47 ms 9032 KB Output isn't correct
71 Incorrect 66 ms 11336 KB Output isn't correct
72 Incorrect 71 ms 11480 KB Output isn't correct
73 Incorrect 67 ms 11840 KB Output isn't correct
74 Incorrect 89 ms 12200 KB Output isn't correct
75 Incorrect 76 ms 11212 KB Output isn't correct
76 Incorrect 72 ms 12232 KB Output isn't correct
77 Incorrect 79 ms 12104 KB Output isn't correct
78 Incorrect 89 ms 12104 KB Output isn't correct
79 Incorrect 104 ms 11304 KB Output isn't correct
80 Incorrect 76 ms 12076 KB Output isn't correct
81 Incorrect 94 ms 11980 KB Output isn't correct
82 Incorrect 75 ms 12424 KB Output isn't correct
83 Incorrect 91 ms 11336 KB Output isn't correct
84 Incorrect 111 ms 11424 KB Output isn't correct
85 Incorrect 87 ms 11428 KB Output isn't correct
86 Incorrect 81 ms 11336 KB Output isn't correct
87 Incorrect 129 ms 11976 KB Output isn't correct
88 Incorrect 107 ms 12616 KB Output isn't correct
89 Incorrect 82 ms 11524 KB Output isn't correct
90 Incorrect 66 ms 9196 KB Output isn't correct
91 Incorrect 68 ms 12604 KB Output isn't correct
92 Incorrect 91 ms 12492 KB Output isn't correct
93 Incorrect 66 ms 12012 KB Output isn't correct
94 Incorrect 90 ms 11972 KB Output isn't correct
95 Incorrect 78 ms 11308 KB Output isn't correct
96 Incorrect 89 ms 11336 KB Output isn't correct
97 Incorrect 74 ms 11316 KB Output isn't correct
98 Incorrect 72 ms 12104 KB Output isn't correct
99 Incorrect 76 ms 11336 KB Output isn't correct
100 Incorrect 94 ms 11364 KB Output isn't correct