# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
878865 | 2023-11-25T11:09:05 Z | Gray | Bomb (IZhO17_bomb) | C++17 | 731 ms | 95448 KB |
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> #include <cassert> #define ll long long #define ln "\n" #define ff first #define ss second #define ld long double const ll INF = 2e18; const ll MOD = 1e9+7; using namespace std; void solve(){ ll n, m; cin >> n >> m; vector<vector<char>> grid(n, vector<char>(m)); for (ll i=0; i<n; i++){ for (ll j=0; j<m; j++) cin >> grid[i][j]; } vector<vector<ll>> dist(n, vector<ll>(m, 0)); for (ll i=0; i<n; i++){ ll loj = -1; for (ll j=0; j<m; j++){ if (grid[i][j] == '0'){ loj = j; } dist[i][j] = j-loj; } } ll mnw = m, mnh = n; for (ll j=0; j<m; j++){ vector<ll> tpdi(n); stack<ll> mni; for (ll i=0; i<n; i++){ while (!mni.empty() and dist[mni.top()][j]>=dist[i][j]) mni.pop(); if (!mni.empty()) tpdi[i] = i-mni.top(); else tpdi[i] = i+1; mni.push(i); } mni = stack<ll>(); for (ll i = n-1; i>=0; i--){ ll tdp = 0; while (!mni.empty() and dist[mni.top()][j]>=dist[i][j]) mni.pop(); if (!mni.empty()){ // cout << mni.top() << ln; tdp = mni.top()-i; }else tdp = n-i; mni.push(i); if (grid[i][j]=='0') continue; mnw = min(mnw, dist[i][j]); mnh = min(mnh, tdp+tpdi[i]-1); // cout << i << " " << j << ": " << dist[i][j] << " ; " << tdp << " " << tpdi[i] << ln; } } cout << mnw*mnh << ln; } void setIO(){ // ios_base::sync_with_stdio(false); // cin.tie(nullptr); // cout.tie(nullptr); freopen("bomb.in", "r", stdin); freopen("bomb.out", "w", stdout); } int main(){ setIO(); ll t=1; // cin >> t; while (t--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 517 ms | 95332 KB | Output isn't correct |
2 | Incorrect | 512 ms | 95360 KB | Output isn't correct |
3 | Incorrect | 519 ms | 95376 KB | Output isn't correct |
4 | Incorrect | 536 ms | 95360 KB | Output isn't correct |
5 | Incorrect | 500 ms | 95284 KB | Output isn't correct |
6 | Incorrect | 519 ms | 95360 KB | Output isn't correct |
7 | Incorrect | 524 ms | 95356 KB | Output isn't correct |
8 | Incorrect | 502 ms | 95364 KB | Output isn't correct |
9 | Incorrect | 519 ms | 95364 KB | Output isn't correct |
10 | Incorrect | 496 ms | 95360 KB | Output isn't correct |
11 | Incorrect | 557 ms | 95356 KB | Output isn't correct |
12 | Incorrect | 497 ms | 95300 KB | Output isn't correct |
13 | Incorrect | 524 ms | 95380 KB | Output isn't correct |
14 | Incorrect | 555 ms | 95336 KB | Output isn't correct |
15 | Incorrect | 510 ms | 95356 KB | Output isn't correct |
16 | Incorrect | 507 ms | 95376 KB | Output isn't correct |
17 | Incorrect | 492 ms | 95360 KB | Output isn't correct |
18 | Incorrect | 509 ms | 95376 KB | Output isn't correct |
19 | Incorrect | 523 ms | 95360 KB | Output isn't correct |
20 | Incorrect | 539 ms | 95360 KB | Output isn't correct |
21 | Incorrect | 510 ms | 95372 KB | Output isn't correct |
22 | Incorrect | 497 ms | 95352 KB | Output isn't correct |
23 | Incorrect | 527 ms | 95360 KB | Output isn't correct |
24 | Incorrect | 506 ms | 95360 KB | Output isn't correct |
25 | Incorrect | 532 ms | 95356 KB | Output isn't correct |
26 | Incorrect | 540 ms | 95372 KB | Output isn't correct |
27 | Incorrect | 493 ms | 95356 KB | Output isn't correct |
28 | Incorrect | 509 ms | 95360 KB | Output isn't correct |
29 | Incorrect | 496 ms | 95364 KB | Output isn't correct |
30 | Incorrect | 493 ms | 95360 KB | Output isn't correct |
31 | Incorrect | 505 ms | 95364 KB | Output isn't correct |
32 | Incorrect | 494 ms | 95380 KB | Output isn't correct |
33 | Incorrect | 506 ms | 95356 KB | Output isn't correct |
34 | Incorrect | 500 ms | 95360 KB | Output isn't correct |
35 | Incorrect | 499 ms | 95356 KB | Output isn't correct |
36 | Incorrect | 552 ms | 95376 KB | Output isn't correct |
37 | Incorrect | 506 ms | 95432 KB | Output isn't correct |
38 | Incorrect | 513 ms | 95360 KB | Output isn't correct |
39 | Incorrect | 504 ms | 95296 KB | Output isn't correct |
40 | Incorrect | 515 ms | 95388 KB | Output isn't correct |
41 | Incorrect | 527 ms | 95372 KB | Output isn't correct |
42 | Incorrect | 553 ms | 95276 KB | Output isn't correct |
43 | Incorrect | 546 ms | 95360 KB | Output isn't correct |
44 | Incorrect | 538 ms | 95376 KB | Output isn't correct |
45 | Incorrect | 520 ms | 95364 KB | Output isn't correct |
46 | Incorrect | 530 ms | 95276 KB | Output isn't correct |
47 | Incorrect | 532 ms | 95364 KB | Output isn't correct |
48 | Incorrect | 512 ms | 95372 KB | Output isn't correct |
49 | Incorrect | 537 ms | 95364 KB | Output isn't correct |
50 | Incorrect | 552 ms | 95384 KB | Output isn't correct |
51 | Incorrect | 524 ms | 95380 KB | Output isn't correct |
52 | Incorrect | 540 ms | 95356 KB | Output isn't correct |
53 | Incorrect | 520 ms | 95320 KB | Output isn't correct |
54 | Incorrect | 731 ms | 95360 KB | Output isn't correct |
55 | Incorrect | 600 ms | 95376 KB | Output isn't correct |
56 | Incorrect | 506 ms | 95356 KB | Output isn't correct |
57 | Incorrect | 513 ms | 95352 KB | Output isn't correct |
58 | Incorrect | 527 ms | 95424 KB | Output isn't correct |
59 | Incorrect | 517 ms | 95372 KB | Output isn't correct |
60 | Incorrect | 500 ms | 95356 KB | Output isn't correct |
61 | Incorrect | 509 ms | 95356 KB | Output isn't correct |
62 | Incorrect | 520 ms | 95380 KB | Output isn't correct |
63 | Incorrect | 496 ms | 95380 KB | Output isn't correct |
64 | Incorrect | 540 ms | 95356 KB | Output isn't correct |
65 | Incorrect | 521 ms | 95356 KB | Output isn't correct |
66 | Incorrect | 507 ms | 95360 KB | Output isn't correct |
67 | Incorrect | 537 ms | 95360 KB | Output isn't correct |
68 | Incorrect | 585 ms | 95372 KB | Output isn't correct |
69 | Incorrect | 515 ms | 95272 KB | Output isn't correct |
70 | Incorrect | 504 ms | 95356 KB | Output isn't correct |
71 | Incorrect | 534 ms | 95360 KB | Output isn't correct |
72 | Incorrect | 524 ms | 95360 KB | Output isn't correct |
73 | Incorrect | 512 ms | 95428 KB | Output isn't correct |
74 | Incorrect | 509 ms | 95372 KB | Output isn't correct |
75 | Incorrect | 497 ms | 95356 KB | Output isn't correct |
76 | Incorrect | 496 ms | 95360 KB | Output isn't correct |
77 | Incorrect | 518 ms | 95448 KB | Output isn't correct |
78 | Incorrect | 537 ms | 95372 KB | Output isn't correct |
79 | Incorrect | 511 ms | 95396 KB | Output isn't correct |
80 | Incorrect | 503 ms | 95356 KB | Output isn't correct |
81 | Incorrect | 539 ms | 95372 KB | Output isn't correct |
82 | Incorrect | 501 ms | 95356 KB | Output isn't correct |
83 | Incorrect | 510 ms | 95368 KB | Output isn't correct |
84 | Incorrect | 495 ms | 95360 KB | Output isn't correct |
85 | Incorrect | 507 ms | 95376 KB | Output isn't correct |
86 | Incorrect | 559 ms | 95356 KB | Output isn't correct |
87 | Incorrect | 492 ms | 95360 KB | Output isn't correct |
88 | Incorrect | 533 ms | 95360 KB | Output isn't correct |
89 | Incorrect | 583 ms | 95356 KB | Output isn't correct |
90 | Incorrect | 502 ms | 95360 KB | Output isn't correct |
91 | Incorrect | 504 ms | 95244 KB | Output isn't correct |
92 | Incorrect | 520 ms | 95372 KB | Output isn't correct |
93 | Incorrect | 512 ms | 95364 KB | Output isn't correct |
94 | Incorrect | 545 ms | 95364 KB | Output isn't correct |
95 | Incorrect | 536 ms | 95328 KB | Output isn't correct |
96 | Incorrect | 519 ms | 95360 KB | Output isn't correct |
97 | Incorrect | 545 ms | 95372 KB | Output isn't correct |
98 | Incorrect | 516 ms | 95356 KB | Output isn't correct |
99 | Incorrect | 522 ms | 95448 KB | Output isn't correct |
100 | Incorrect | 512 ms | 95360 KB | Output isn't correct |