Submission #697342

# Submission time Handle Problem Language Result Execution time Memory
697342 2023-02-09T11:02:13 Z allllekssssa Bomb (IZhO17_bomb) C++14
18 / 100
1000 ms 56380 KB
#include<bits/stdc++.h>
 
using namespace std;


#define pii pair<int ,int>
#define pb push_back

const int maxN = 2600;
int n, m;
int a[maxN][maxN];
int d[maxN][maxN];
int c[maxN][maxN];
string s;
int cnt[maxN];

int getDSum(int x1, int y1, int x2, int y2) {
	if (x2 > n || y2 > m) return 0;
	return d[x2][y2] + d[x1 - 1][y1 - 1] - d[x1 - 1][y2] - d[x2][y1 - 1];
}
 
int heuristic1() {
    
	vector<pii> gornji;

	for (int i = 1; i<=n; i++) {
		for (int j = 1; j<=m; j++) {
			if (a[i - 1][j] == 0 && a[i][j - 1] == 0 && a[i][j] == 1) gornji.pb({i, j});
		}
	}

    
    for (int i = 1; i <=n; i++) {
    	cnt[i] = m;
    }

      for (int i = 0; i < gornji.size(); i++) {
       for (int len = 1; len <= n; len++) {
          
          int width = m;
          int x = gornji[i].first;
          int y = gornji[i].second;


          while ((width > 0 || cnt[len]) && getDSum(x, y, x + len - 1, y + width - 1) != len * width) width--;
       	  cnt[len] = min(cnt[len], width);
       }
    }


    int ans = 0;
    for (int i = 1; i<=n; i++) {
    	ans = max(ans, i * cnt[i]);
    }

    return ans;
}

int main() {
 
	cin >> n >> m;
 
	for (int i = 1; i <=n; i++) {
		cin >> s;
 
		for (int j = 0; j < m; j++) {
			a[i][j + 1] = s[j] - '0';
		}
	}
    
    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] + a[i][j] - d[i - 1][j - 1];
		}
	}
    
    cout << heuristic1() << endl;
}

Compilation message

bomb.cpp: In function 'int heuristic1()':
bomb.cpp:37:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       for (int i = 0; i < gornji.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 10 ms 20404 KB Output is correct
4 Correct 11 ms 20388 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 468 KB Output isn't correct
9 Incorrect 1 ms 444 KB Output isn't correct
10 Correct 1 ms 340 KB Output is correct
11 Incorrect 1 ms 468 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Incorrect 1 ms 340 KB Output isn't correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 1 ms 468 KB Output isn't correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 2 ms 824 KB Output is correct
18 Correct 1 ms 828 KB Output is correct
19 Incorrect 2 ms 1108 KB Output isn't correct
20 Incorrect 1 ms 1108 KB Output isn't correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Incorrect 1 ms 1220 KB Output isn't correct
24 Incorrect 1 ms 980 KB Output isn't correct
25 Incorrect 1 ms 1108 KB Output isn't correct
26 Incorrect 1 ms 1216 KB Output isn't correct
27 Incorrect 4 ms 3300 KB Output isn't correct
28 Incorrect 7 ms 3540 KB Output isn't correct
29 Incorrect 18 ms 4500 KB Output isn't correct
30 Incorrect 8 ms 5316 KB Output isn't correct
31 Incorrect 8 ms 4416 KB Output isn't correct
32 Incorrect 9 ms 4820 KB Output isn't correct
33 Incorrect 8 ms 5700 KB Output isn't correct
34 Incorrect 7 ms 3796 KB Output isn't correct
35 Incorrect 9 ms 5628 KB Output isn't correct
36 Incorrect 8 ms 5632 KB Output isn't correct
37 Incorrect 0 ms 468 KB Output isn't correct
38 Correct 172 ms 54924 KB Output is correct
39 Incorrect 1 ms 468 KB Output isn't correct
40 Incorrect 27 ms 14028 KB Output isn't correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 2 ms 1092 KB Output is correct
43 Execution timed out 1100 ms 54908 KB Time limit exceeded
44 Correct 29 ms 5716 KB Output is correct
45 Execution timed out 1026 ms 55032 KB Time limit exceeded
46 Execution timed out 1084 ms 55244 KB Time limit exceeded
47 Execution timed out 1008 ms 55696 KB Time limit exceeded
48 Execution timed out 1050 ms 55864 KB Time limit exceeded
49 Incorrect 180 ms 55804 KB Output isn't correct
50 Execution timed out 1050 ms 55632 KB Time limit exceeded
51 Execution timed out 1020 ms 55468 KB Time limit exceeded
52 Execution timed out 1052 ms 55784 KB Time limit exceeded
53 Execution timed out 1045 ms 55544 KB Time limit exceeded
54 Execution timed out 1069 ms 55528 KB Time limit exceeded
55 Execution timed out 1024 ms 55416 KB Time limit exceeded
56 Correct 535 ms 55368 KB Output is correct
57 Execution timed out 1072 ms 55636 KB Time limit exceeded
58 Execution timed out 1026 ms 55056 KB Time limit exceeded
59 Execution timed out 1031 ms 54988 KB Time limit exceeded
60 Incorrect 176 ms 54816 KB Output isn't correct
61 Incorrect 171 ms 54876 KB Output isn't correct
62 Incorrect 177 ms 54836 KB Output isn't correct
63 Incorrect 168 ms 54580 KB Output isn't correct
64 Incorrect 172 ms 54556 KB Output isn't correct
65 Execution timed out 1039 ms 55380 KB Time limit exceeded
66 Incorrect 300 ms 55388 KB Output isn't correct
67 Execution timed out 1032 ms 55056 KB Time limit exceeded
68 Execution timed out 1014 ms 54092 KB Time limit exceeded
69 Execution timed out 1008 ms 54008 KB Time limit exceeded
70 Incorrect 117 ms 43496 KB Output isn't correct
71 Incorrect 174 ms 54384 KB Output isn't correct
72 Incorrect 180 ms 54252 KB Output isn't correct
73 Incorrect 175 ms 54228 KB Output isn't correct
74 Incorrect 177 ms 54936 KB Output isn't correct
75 Incorrect 174 ms 54432 KB Output isn't correct
76 Incorrect 176 ms 54304 KB Output isn't correct
77 Incorrect 173 ms 54324 KB Output isn't correct
78 Incorrect 175 ms 54376 KB Output isn't correct
79 Incorrect 174 ms 54976 KB Output isn't correct
80 Incorrect 176 ms 54280 KB Output isn't correct
81 Incorrect 173 ms 54848 KB Output isn't correct
82 Incorrect 175 ms 55252 KB Output isn't correct
83 Incorrect 174 ms 55664 KB Output isn't correct
84 Incorrect 173 ms 55988 KB Output isn't correct
85 Incorrect 180 ms 55808 KB Output isn't correct
86 Incorrect 175 ms 56380 KB Output isn't correct
87 Incorrect 178 ms 55952 KB Output isn't correct
88 Incorrect 176 ms 55404 KB Output isn't correct
89 Incorrect 177 ms 55136 KB Output isn't correct
90 Incorrect 120 ms 44392 KB Output isn't correct
91 Incorrect 179 ms 55180 KB Output isn't correct
92 Incorrect 176 ms 54348 KB Output isn't correct
93 Incorrect 176 ms 54332 KB Output isn't correct
94 Incorrect 182 ms 54268 KB Output isn't correct
95 Incorrect 170 ms 54456 KB Output isn't correct
96 Incorrect 175 ms 54564 KB Output isn't correct
97 Incorrect 174 ms 54396 KB Output isn't correct
98 Incorrect 173 ms 55372 KB Output isn't correct
99 Incorrect 182 ms 54672 KB Output isn't correct
100 Incorrect 174 ms 55008 KB Output isn't correct