답안 #1118389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1118389 2024-11-25T12:18:55 Z Younis_Dwai Bomb (IZhO17_bomb) C++14
0 / 100
123 ms 131072 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=2509;
char b[N][N];
int n,m,pref[N][N];
set<pair<int,int>> adj[N][N];
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];
}
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];
    init();
    if(n==1){
       int mx=m;
       for(int i=1;i<=m;i++){
           if(b[1][i]=='1'){
              int cnt=1;
              while(i+1<=m && b[1][i+1]==b[1][i]){
                    ++i;
                    ++cnt;

              }
              mx=min(mx,cnt);
              ++i;
           }
       }
       cout<<mx;
    }
    else if(m==1){
          int mx=n;
          for(int i=1;i<=n;i++){
              if(b[i][1]=='1'){
                 int cnt=1;
                 while(i+1<=n && b[i+1][1]==b[i][1]){
                    ++i;
                    ++cnt;
                 }
                 mx=min(mx,cnt);
                 ++i;
              }
          }
          cout<<mx;
    }
    else{
         int mx=0,all=0;
         for(int i=1;i<=n;i++)
             for(int j=1;j<=m;j++) if(b[i][j]=='1') ++all;
         for(int i=1;i<=n;i++){
             for(int j=1;j<=m;j++){
                 if(b[i][j]=='0') continue ;
                 for(int i1=1;i1<=i;i1++){
                     for(int j1=1;j1<=j;j1++){
                         for(int i2=i;i2<=n;i2++){
                             for(int j2=j;j2<=m;j2++){
                                 if(b[i1][j1]=='1' && b[i2][j2]=='1' && query(i1,j1,i2,j2)==(i2-i1+1)*(j2-j1+1)){
                                    adj[i2-i1+1][j2-j1+1].in({i,j});
                                 }
                             }
                         }
                     }
                 }
             }
         }
         for(int i=1;i<=n;i++){
             for(int j=1;j<=m;j++){
                 int x=adj[i][j].size();
                 if(x==all) mx=max(mx,i*j);
             }
         }
         cout<<mx;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 131072 KB Execution killed with signal 9
2 Runtime error 102 ms 131072 KB Execution killed with signal 9
3 Runtime error 100 ms 131072 KB Execution killed with signal 9
4 Runtime error 100 ms 131072 KB Execution killed with signal 9
5 Runtime error 99 ms 131072 KB Execution killed with signal 9
6 Runtime error 90 ms 131072 KB Execution killed with signal 9
7 Runtime error 123 ms 131072 KB Execution killed with signal 9
8 Runtime error 92 ms 131072 KB Execution killed with signal 9
9 Runtime error 96 ms 131072 KB Execution killed with signal 9
10 Runtime error 90 ms 131072 KB Execution killed with signal 9
11 Runtime error 96 ms 131072 KB Execution killed with signal 9
12 Runtime error 92 ms 131072 KB Execution killed with signal 9
13 Runtime error 98 ms 131072 KB Execution killed with signal 9
14 Runtime error 95 ms 131072 KB Execution killed with signal 9
15 Runtime error 93 ms 131072 KB Execution killed with signal 9
16 Runtime error 94 ms 131072 KB Execution killed with signal 9
17 Runtime error 96 ms 131072 KB Execution killed with signal 9
18 Runtime error 108 ms 131072 KB Execution killed with signal 9
19 Runtime error 95 ms 131072 KB Execution killed with signal 9
20 Runtime error 99 ms 131072 KB Execution killed with signal 9
21 Runtime error 96 ms 131072 KB Execution killed with signal 9
22 Runtime error 98 ms 131072 KB Execution killed with signal 9
23 Runtime error 94 ms 131072 KB Execution killed with signal 9
24 Runtime error 103 ms 131072 KB Execution killed with signal 9
25 Runtime error 97 ms 131072 KB Execution killed with signal 9
26 Runtime error 101 ms 131072 KB Execution killed with signal 9
27 Runtime error 97 ms 131072 KB Execution killed with signal 9
28 Runtime error 90 ms 131072 KB Execution killed with signal 9
29 Runtime error 96 ms 131072 KB Execution killed with signal 9
30 Runtime error 90 ms 131072 KB Execution killed with signal 9
31 Runtime error 91 ms 131072 KB Execution killed with signal 9
32 Runtime error 97 ms 131072 KB Execution killed with signal 9
33 Runtime error 101 ms 131072 KB Execution killed with signal 9
34 Runtime error 93 ms 131072 KB Execution killed with signal 9
35 Runtime error 101 ms 131072 KB Execution killed with signal 9
36 Runtime error 95 ms 131072 KB Execution killed with signal 9
37 Runtime error 104 ms 131072 KB Execution killed with signal 9
38 Runtime error 101 ms 131072 KB Execution killed with signal 9
39 Runtime error 90 ms 131072 KB Execution killed with signal 9
40 Runtime error 82 ms 131072 KB Execution killed with signal 9
41 Runtime error 82 ms 131072 KB Execution killed with signal 9
42 Runtime error 93 ms 131072 KB Execution killed with signal 9
43 Runtime error 81 ms 131072 KB Execution killed with signal 9
44 Runtime error 86 ms 131072 KB Execution killed with signal 9
45 Runtime error 85 ms 131072 KB Execution killed with signal 9
46 Runtime error 89 ms 131072 KB Execution killed with signal 9
47 Runtime error 85 ms 131072 KB Execution killed with signal 9
48 Runtime error 84 ms 131072 KB Execution killed with signal 9
49 Runtime error 91 ms 131072 KB Execution killed with signal 9
50 Runtime error 81 ms 131072 KB Execution killed with signal 9
51 Runtime error 92 ms 131072 KB Execution killed with signal 9
52 Runtime error 89 ms 131072 KB Execution killed with signal 9
53 Runtime error 95 ms 131072 KB Execution killed with signal 9
54 Runtime error 107 ms 131072 KB Execution killed with signal 9
55 Runtime error 110 ms 131072 KB Execution killed with signal 9
56 Runtime error 96 ms 131072 KB Execution killed with signal 9
57 Runtime error 96 ms 131072 KB Execution killed with signal 9
58 Runtime error 96 ms 131072 KB Execution killed with signal 9
59 Runtime error 95 ms 131072 KB Execution killed with signal 9
60 Runtime error 92 ms 131072 KB Execution killed with signal 9
61 Runtime error 102 ms 131072 KB Execution killed with signal 9
62 Runtime error 90 ms 131072 KB Execution killed with signal 9
63 Runtime error 102 ms 131072 KB Execution killed with signal 9
64 Runtime error 96 ms 131072 KB Execution killed with signal 9
65 Runtime error 91 ms 131072 KB Execution killed with signal 9
66 Runtime error 99 ms 131072 KB Execution killed with signal 9
67 Runtime error 93 ms 131072 KB Execution killed with signal 9
68 Runtime error 94 ms 131072 KB Execution killed with signal 9
69 Runtime error 91 ms 131072 KB Execution killed with signal 9
70 Runtime error 100 ms 131072 KB Execution killed with signal 9
71 Runtime error 96 ms 131072 KB Execution killed with signal 9
72 Runtime error 91 ms 131072 KB Execution killed with signal 9
73 Runtime error 96 ms 131072 KB Execution killed with signal 9
74 Runtime error 96 ms 131072 KB Execution killed with signal 9
75 Runtime error 101 ms 131072 KB Execution killed with signal 9
76 Runtime error 89 ms 131072 KB Execution killed with signal 9
77 Runtime error 82 ms 131072 KB Execution killed with signal 9
78 Runtime error 84 ms 131072 KB Execution killed with signal 9
79 Runtime error 94 ms 131072 KB Execution killed with signal 9
80 Runtime error 95 ms 131072 KB Execution killed with signal 9
81 Runtime error 98 ms 131072 KB Execution killed with signal 9
82 Runtime error 99 ms 131072 KB Execution killed with signal 9
83 Runtime error 92 ms 131072 KB Execution killed with signal 9
84 Runtime error 93 ms 131072 KB Execution killed with signal 9
85 Runtime error 105 ms 131072 KB Execution killed with signal 9
86 Runtime error 98 ms 131072 KB Execution killed with signal 9
87 Runtime error 98 ms 131072 KB Execution killed with signal 9
88 Runtime error 94 ms 131072 KB Execution killed with signal 9
89 Runtime error 97 ms 131072 KB Execution killed with signal 9
90 Runtime error 105 ms 131072 KB Execution killed with signal 9
91 Runtime error 93 ms 131072 KB Execution killed with signal 9
92 Runtime error 91 ms 131072 KB Execution killed with signal 9
93 Runtime error 99 ms 131072 KB Execution killed with signal 9
94 Runtime error 94 ms 131072 KB Execution killed with signal 9
95 Runtime error 91 ms 131072 KB Execution killed with signal 9
96 Runtime error 99 ms 131072 KB Execution killed with signal 9
97 Runtime error 105 ms 131072 KB Execution killed with signal 9
98 Runtime error 95 ms 131072 KB Execution killed with signal 9
99 Runtime error 91 ms 131072 KB Execution killed with signal 9
100 Runtime error 104 ms 131072 KB Execution killed with signal 9