Submission #936086

# Submission time Handle Problem Language Result Execution time Memory
936086 2024-03-01T06:13:51 Z guagua0407 Bomb (IZhO17_bomb) C++17
14 / 100
1000 ms 43356 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define all(x) x.begin(),x.end()

const int mxn=2505;
char c[mxn][mxn];
int pre[mxn][mxn];
bool used[mxn][mxn];
int mn[mxn];
int n,m;

bool check(int x,int y){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            used[i][j]=false;
        }
    }
    for(int j=1;j<=m;j++){
        mn[j]=0;
    }
    int cur=0;
    for(int i=y;i<=n;i++){
        int prv=0;
        for(int j=x;j<=m;j++){
            int sum=pre[i][j]-pre[i][j-x]-pre[i-y][j]+pre[i-y][j-x];
            if(sum!=x*y){
                continue;
            }
            for(int k=max(prv+1,j-x+1);k<=j;k++){
                for(int l=i;l>=max(mn[k]+1,i-y+1);l--){
                    used[l][k]=true;
                    cur++;
                }
                mn[k]=i;
            }
            prv=j;
        }
    }
    return cur==pre[n][m];
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    auto st=clock();
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>c[i][j];
            pre[i][j]=pre[i][j-1]+pre[i-1][j]-pre[i-1][j-1]+(c[i][j]=='1');
        }
    }
    int ans=0;
    int r=n;
    for(int len=1;len<=m;len++){
        while(r>=1 and !check(len,r)){
            r--;
        }
        //cout<<r<<'\n';
        ans+=r;
    }
    cout<<ans<<'\n';
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:49:10: warning: unused variable 'st' [-Wunused-variable]
   49 |     auto st=clock();
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2512 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 67 ms 23832 KB Output is correct
4 Correct 54 ms 23644 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Incorrect 1 ms 2652 KB Output isn't correct
9 Incorrect 1 ms 2660 KB Output isn't correct
10 Incorrect 1 ms 2396 KB Output isn't correct
11 Incorrect 1 ms 2520 KB Output isn't correct
12 Incorrect 1 ms 2392 KB Output isn't correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Incorrect 1 ms 2396 KB Output isn't correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2908 KB Output is correct
18 Incorrect 1 ms 2908 KB Output isn't correct
19 Incorrect 2 ms 5040 KB Output isn't correct
20 Incorrect 2 ms 4952 KB Output isn't correct
21 Incorrect 1 ms 2652 KB Output isn't correct
22 Incorrect 1 ms 4956 KB Output isn't correct
23 Incorrect 2 ms 4956 KB Output isn't correct
24 Incorrect 1 ms 4956 KB Output isn't correct
25 Incorrect 3 ms 4956 KB Output isn't correct
26 Correct 4 ms 4956 KB Output is correct
27 Correct 56 ms 8280 KB Output is correct
28 Incorrect 23 ms 8488 KB Output isn't correct
29 Incorrect 123 ms 8796 KB Output isn't correct
30 Incorrect 102 ms 9424 KB Output isn't correct
31 Incorrect 62 ms 8796 KB Output isn't correct
32 Incorrect 61 ms 9052 KB Output isn't correct
33 Incorrect 134 ms 9576 KB Output isn't correct
34 Incorrect 22 ms 8536 KB Output isn't correct
35 Incorrect 98 ms 9564 KB Output isn't correct
36 Correct 254 ms 9560 KB Output is correct
37 Incorrect 1 ms 2648 KB Output isn't correct
38 Execution timed out 1088 ms 43348 KB Time limit exceeded
39 Incorrect 1 ms 2652 KB Output isn't correct
40 Execution timed out 1085 ms 15076 KB Time limit exceeded
41 Incorrect 1 ms 2652 KB Output isn't correct
42 Incorrect 3 ms 4952 KB Output isn't correct
43 Execution timed out 1059 ms 42908 KB Time limit exceeded
44 Incorrect 197 ms 9760 KB Output isn't correct
45 Execution timed out 1045 ms 42904 KB Time limit exceeded
46 Execution timed out 1010 ms 42832 KB Time limit exceeded
47 Execution timed out 1020 ms 42904 KB Time limit exceeded
48 Execution timed out 1026 ms 42900 KB Time limit exceeded
49 Execution timed out 1077 ms 42792 KB Time limit exceeded
50 Execution timed out 1060 ms 42836 KB Time limit exceeded
51 Execution timed out 1059 ms 42908 KB Time limit exceeded
52 Execution timed out 1090 ms 43296 KB Time limit exceeded
53 Execution timed out 1032 ms 43284 KB Time limit exceeded
54 Execution timed out 1026 ms 43356 KB Time limit exceeded
55 Execution timed out 1047 ms 43296 KB Time limit exceeded
56 Execution timed out 1061 ms 43172 KB Time limit exceeded
57 Execution timed out 1095 ms 43152 KB Time limit exceeded
58 Execution timed out 1028 ms 43344 KB Time limit exceeded
59 Execution timed out 1051 ms 43144 KB Time limit exceeded
60 Execution timed out 1080 ms 43344 KB Time limit exceeded
61 Execution timed out 1034 ms 43344 KB Time limit exceeded
62 Execution timed out 1032 ms 43344 KB Time limit exceeded
63 Execution timed out 1070 ms 43264 KB Time limit exceeded
64 Execution timed out 1031 ms 43272 KB Time limit exceeded
65 Execution timed out 1027 ms 43344 KB Time limit exceeded
66 Execution timed out 1052 ms 43136 KB Time limit exceeded
67 Execution timed out 1058 ms 43348 KB Time limit exceeded
68 Execution timed out 1027 ms 43348 KB Time limit exceeded
69 Execution timed out 1034 ms 43344 KB Time limit exceeded
70 Execution timed out 1073 ms 35412 KB Time limit exceeded
71 Execution timed out 1059 ms 43348 KB Time limit exceeded
72 Execution timed out 1020 ms 43348 KB Time limit exceeded
73 Execution timed out 1038 ms 43152 KB Time limit exceeded
74 Execution timed out 1060 ms 43348 KB Time limit exceeded
75 Execution timed out 1070 ms 43348 KB Time limit exceeded
76 Execution timed out 1041 ms 43344 KB Time limit exceeded
77 Execution timed out 1039 ms 43344 KB Time limit exceeded
78 Execution timed out 1068 ms 43348 KB Time limit exceeded
79 Execution timed out 1041 ms 43228 KB Time limit exceeded
80 Execution timed out 1042 ms 43204 KB Time limit exceeded
81 Execution timed out 1036 ms 43148 KB Time limit exceeded
82 Execution timed out 1047 ms 43240 KB Time limit exceeded
83 Execution timed out 1010 ms 43344 KB Time limit exceeded
84 Execution timed out 1050 ms 43168 KB Time limit exceeded
85 Execution timed out 1048 ms 43348 KB Time limit exceeded
86 Execution timed out 1016 ms 43148 KB Time limit exceeded
87 Execution timed out 1046 ms 43348 KB Time limit exceeded
88 Execution timed out 1060 ms 43144 KB Time limit exceeded
89 Execution timed out 1028 ms 43348 KB Time limit exceeded
90 Execution timed out 1076 ms 35440 KB Time limit exceeded
91 Execution timed out 1060 ms 43344 KB Time limit exceeded
92 Execution timed out 1043 ms 43280 KB Time limit exceeded
93 Execution timed out 1046 ms 43348 KB Time limit exceeded
94 Execution timed out 1032 ms 43192 KB Time limit exceeded
95 Execution timed out 1063 ms 43348 KB Time limit exceeded
96 Execution timed out 1035 ms 43288 KB Time limit exceeded
97 Execution timed out 1025 ms 43208 KB Time limit exceeded
98 Execution timed out 1067 ms 43264 KB Time limit exceeded
99 Execution timed out 1018 ms 43348 KB Time limit exceeded
100 Execution timed out 1030 ms 43344 KB Time limit exceeded