Submission #541395

# Submission time Handle Problem Language Result Execution time Memory
541395 2022-03-23T13:06:27 Z nigus Bomb (IZhO17_bomb) C++14
25 / 100
1000 ms 5316 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);

ll random2(){
    return (1ll << 31ll)*eng()+eng();
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 1001;

bool grid[MAXN][MAXN] = {0};

bool covered[MAXN][MAXN] = {0};

bool can_place(int i, int j, int a, int b){
    if(n-i < a || m-j < b)return 0;
    rep(c1,0,a){
        rep(c2,0,b){
            if(!grid[i+c1][j+c2])return 0;
        }
    }
    return 1;
}

bool can_cover(int i, int j, int a, int b){
    rep(dx,0,a){
        rep(dy,0,b){
            int i2 = i - dx;
            int j2 = j - dy;
            if(i2 >= 0 && j2 >= 0 && can_place(i2,j2,a,b))return 1;
        }
    }
    return 0;
}

bool solve(int a, int b){
    rep(c1,0,n){
        rep(c2,0,m){
            if(grid[c1][c2] && !can_cover(c1,c2,a,b))return 0;
        }
    }
    return 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

   // freopen("fhc.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> m;
    rep(c1,0,n){
        string s;
        cin >> s;
        rep(c2,0,m){
            grid[c1][c2] = (s[c2] == '1');
        }
    }

    ll ans = 0;

    rep(a,1,n+1){
        rep(b,1,m+1){
            if(solve(a, b)){
                ans = max(ans, (ll)a*b);
            }
        }
    }
    cout << ans << "\n";


    return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:73:8: warning: unused variable 'a' [-Wunused-variable]
   73 |     ll a,b,c,d,e;
      |        ^
bomb.cpp:73:10: warning: unused variable 'b' [-Wunused-variable]
   73 |     ll a,b,c,d,e;
      |          ^
bomb.cpp:73:12: warning: unused variable 'c' [-Wunused-variable]
   73 |     ll a,b,c,d,e;
      |            ^
bomb.cpp:73:14: warning: unused variable 'd' [-Wunused-variable]
   73 |     ll a,b,c,d,e;
      |              ^
bomb.cpp:73:16: warning: unused variable 'e' [-Wunused-variable]
   73 |     ll a,b,c,d,e;
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 3 ms 2388 KB Execution killed with signal 11
4 Runtime error 2 ms 2384 KB Execution killed with signal 11
5 Correct 5 ms 340 KB Output is correct
6 Correct 16 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 9 ms 412 KB Output is correct
18 Correct 10 ms 340 KB Output is correct
19 Correct 92 ms 424 KB Output is correct
20 Correct 110 ms 416 KB Output is correct
21 Correct 12 ms 336 KB Output is correct
22 Correct 27 ms 340 KB Output is correct
23 Correct 767 ms 432 KB Output is correct
24 Correct 85 ms 408 KB Output is correct
25 Execution timed out 1084 ms 340 KB Time limit exceeded
26 Execution timed out 1085 ms 340 KB Time limit exceeded
27 Execution timed out 1082 ms 724 KB Time limit exceeded
28 Execution timed out 1089 ms 724 KB Time limit exceeded
29 Execution timed out 1085 ms 852 KB Time limit exceeded
30 Execution timed out 1072 ms 852 KB Time limit exceeded
31 Execution timed out 1089 ms 724 KB Time limit exceeded
32 Execution timed out 1085 ms 852 KB Time limit exceeded
33 Execution timed out 1078 ms 980 KB Time limit exceeded
34 Execution timed out 1089 ms 724 KB Time limit exceeded
35 Execution timed out 1064 ms 980 KB Time limit exceeded
36 Execution timed out 1081 ms 980 KB Time limit exceeded
37 Correct 1 ms 340 KB Output is correct
38 Runtime error 7 ms 5168 KB Execution killed with signal 11
39 Correct 2 ms 340 KB Output is correct
40 Execution timed out 1083 ms 1884 KB Time limit exceeded
41 Correct 2 ms 340 KB Output is correct
42 Execution timed out 1080 ms 340 KB Time limit exceeded
43 Runtime error 10 ms 5196 KB Execution killed with signal 11
44 Execution timed out 1085 ms 904 KB Time limit exceeded
45 Runtime error 8 ms 5124 KB Execution killed with signal 11
46 Runtime error 8 ms 5188 KB Execution killed with signal 11
47 Runtime error 10 ms 5164 KB Execution killed with signal 11
48 Runtime error 8 ms 5204 KB Execution killed with signal 11
49 Runtime error 7 ms 5200 KB Execution killed with signal 11
50 Runtime error 8 ms 5216 KB Execution killed with signal 11
51 Runtime error 10 ms 5164 KB Execution killed with signal 11
52 Runtime error 11 ms 5184 KB Execution killed with signal 11
53 Runtime error 10 ms 5180 KB Execution killed with signal 11
54 Runtime error 7 ms 5108 KB Execution killed with signal 11
55 Runtime error 10 ms 5196 KB Execution killed with signal 11
56 Runtime error 7 ms 5108 KB Execution killed with signal 11
57 Runtime error 7 ms 5200 KB Execution killed with signal 11
58 Runtime error 9 ms 5184 KB Execution killed with signal 11
59 Runtime error 9 ms 5164 KB Execution killed with signal 11
60 Runtime error 7 ms 5160 KB Execution killed with signal 11
61 Runtime error 7 ms 5208 KB Execution killed with signal 11
62 Runtime error 7 ms 5128 KB Execution killed with signal 11
63 Runtime error 7 ms 5316 KB Execution killed with signal 11
64 Incorrect 6 ms 3908 KB Output isn't correct
65 Runtime error 7 ms 5192 KB Execution killed with signal 11
66 Runtime error 7 ms 5188 KB Execution killed with signal 11
67 Runtime error 8 ms 5148 KB Execution killed with signal 11
68 Runtime error 7 ms 5272 KB Execution killed with signal 11
69 Runtime error 7 ms 5200 KB Execution killed with signal 11
70 Incorrect 5 ms 3476 KB Output isn't correct
71 Incorrect 6 ms 3952 KB Output isn't correct
72 Incorrect 6 ms 4040 KB Output isn't correct
73 Incorrect 6 ms 3932 KB Output isn't correct
74 Incorrect 6 ms 3952 KB Output isn't correct
75 Incorrect 6 ms 3928 KB Output isn't correct
76 Incorrect 6 ms 4000 KB Output isn't correct
77 Incorrect 6 ms 3964 KB Output isn't correct
78 Incorrect 6 ms 3908 KB Output isn't correct
79 Incorrect 6 ms 3928 KB Output isn't correct
80 Incorrect 6 ms 3892 KB Output isn't correct
81 Incorrect 6 ms 4004 KB Output isn't correct
82 Incorrect 6 ms 3924 KB Output isn't correct
83 Incorrect 6 ms 3916 KB Output isn't correct
84 Incorrect 6 ms 3916 KB Output isn't correct
85 Incorrect 6 ms 3968 KB Output isn't correct
86 Runtime error 7 ms 5176 KB Execution killed with signal 11
87 Incorrect 6 ms 3916 KB Output isn't correct
88 Incorrect 6 ms 3980 KB Output isn't correct
89 Runtime error 8 ms 5200 KB Execution killed with signal 11
90 Runtime error 7 ms 4620 KB Execution killed with signal 11
91 Incorrect 6 ms 3968 KB Output isn't correct
92 Incorrect 6 ms 3928 KB Output isn't correct
93 Runtime error 7 ms 5192 KB Execution killed with signal 11
94 Runtime error 7 ms 5220 KB Execution killed with signal 11
95 Incorrect 7 ms 4016 KB Output isn't correct
96 Incorrect 7 ms 4024 KB Output isn't correct
97 Runtime error 8 ms 5124 KB Execution killed with signal 11
98 Incorrect 6 ms 3916 KB Output isn't correct
99 Runtime error 9 ms 5112 KB Execution killed with signal 11
100 Runtime error 7 ms 5196 KB Execution killed with signal 11