답안 #91271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91271 2018-12-26T20:07:13 Z Vardanyan Bomb (IZhO17_bomb) C++14
11 / 100
1000 ms 8316 KB
#include<bits/stdc++.h>

using namespace std;
const int N = 2505;
int a[N][N];
int pref[N][N];
int pref2[N][N];
int calc1(int x1,int y1,int x2,int y2){
    return pref[x2][y2]-pref[x2][y1-1]-pref[x1-1][y2]+pref[x1-1][y1-1];
}
int calc2(int x1,int y1,int x2,int y2){
    return pref2[x2][y2]-pref2[x2][y1-1]-pref2[x1-1][y2]+pref2[x1-1][y1-1];
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n>450 || m>450) return 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            char c;
            scanf(" %c",&c);
            a[i][j] = (c == '1');
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            pref[i][j] = pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+a[i][j];
        }
    }
    int l = 1;
    int r = n*m;
    int ans = 1;
    while(r>=1){
        int mid = r;
        bool F = false;
        for(int q = 1;q<=sqrt(mid);q++){
            if(mid%q) continue;
            int x = mid/q;
            int y = q;
            bool f = true;
            for(int i = 1;i<=n;i++)
            for(int j = 1;j<=m;j++) pref2[i][j] = 0;
            for(int i = 1;i<=n;i++){
                for(int j = 1;j<=m;j++){
                  //  if(a[i][j]!=1) continue;
                    pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1];
                    if(i+x-1<=n && j+y-1<=m){
                        if(calc1(i,j,i+x-1,j+y-1) == mid){
                            pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1]+1;
                        }
                    }
                    if(a[i][j] == 0) continue;
                    int x1 = i-x+1;
                    int y1 = j-y+1;
                    x1 = max(1,x1);
                    y1 = max(1,y1);
                    if(calc2(x1,y1,i,j) == 0){
                        f = false;
                        break;
                    }
                }
            }
            if(f){
                F = true;
                break;
            }
            swap(x,y);
            f = true;
            for(int i = 1;i<=n;i++)
            for(int j = 1;j<=m;j++) pref2[i][j] = 0;
            for(int i = 1;i<=n;i++){
                for(int j = 1;j<=m;j++){
                    if(a[i][j]!=1) continue;
                    if(i+x-1<=n && j+y-1<=m){
                        if(calc1(i,j,i+x-1,j+y-1) == mid){
                            pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1]+1;
                        }
                        else{
                            pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1];
                        }
                    }
                    int x1 = i-x+1;
                    int y1 = j-y+1;
                    x1 = max(1,x1);
                    y1 = max(1,y1);
                    if(calc2(x1,y1,i,j) == 0){
                        f = false;
                        break;
                    }
                }
            }

            if(f){
                F = true;
                break;
            }
        }
        if(F){
            ans = mid;
            break;
        }
        r--;
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:31:9: warning: unused variable 'l' [-Wunused-variable]
     int l = 1;
         ^
bomb.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
bomb.cpp:22:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&c);
             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 636 KB Output is correct
3 Incorrect 2 ms 636 KB Output isn't correct
4 Incorrect 2 ms 636 KB Output isn't correct
5 Incorrect 2 ms 636 KB Output isn't correct
6 Incorrect 2 ms 636 KB Output isn't correct
7 Correct 2 ms 636 KB Output is correct
8 Incorrect 3 ms 720 KB Output isn't correct
9 Incorrect 3 ms 720 KB Output isn't correct
10 Correct 2 ms 720 KB Output is correct
11 Incorrect 3 ms 848 KB Output isn't correct
12 Correct 2 ms 848 KB Output is correct
13 Correct 2 ms 848 KB Output is correct
14 Correct 2 ms 848 KB Output is correct
15 Incorrect 3 ms 848 KB Output isn't correct
16 Incorrect 3 ms 848 KB Output isn't correct
17 Incorrect 147 ms 1448 KB Output isn't correct
18 Correct 245 ms 1512 KB Output is correct
19 Incorrect 701 ms 1836 KB Output isn't correct
20 Incorrect 745 ms 1888 KB Output isn't correct
21 Correct 325 ms 1888 KB Output is correct
22 Correct 649 ms 1888 KB Output is correct
23 Execution timed out 1085 ms 1888 KB Time limit exceeded
24 Incorrect 422 ms 1888 KB Output isn't correct
25 Execution timed out 1075 ms 1892 KB Time limit exceeded
26 Correct 577 ms 1892 KB Output is correct
27 Execution timed out 1085 ms 5088 KB Time limit exceeded
28 Execution timed out 1079 ms 5216 KB Time limit exceeded
29 Execution timed out 1084 ms 6752 KB Time limit exceeded
30 Execution timed out 1078 ms 7904 KB Time limit exceeded
31 Execution timed out 1084 ms 7904 KB Time limit exceeded
32 Execution timed out 1080 ms 7904 KB Time limit exceeded
33 Execution timed out 1077 ms 8288 KB Time limit exceeded
34 Execution timed out 1081 ms 8288 KB Time limit exceeded
35 Execution timed out 1085 ms 8288 KB Time limit exceeded
36 Execution timed out 1085 ms 8288 KB Time limit exceeded
37 Incorrect 3 ms 8288 KB Output isn't correct
38 Incorrect 2 ms 8288 KB Output isn't correct
39 Incorrect 3 ms 8288 KB Output isn't correct
40 Incorrect 1 ms 8288 KB Output isn't correct
41 Correct 3 ms 8288 KB Output is correct
42 Incorrect 717 ms 8288 KB Output isn't correct
43 Incorrect 2 ms 8288 KB Output isn't correct
44 Execution timed out 1088 ms 8316 KB Time limit exceeded
45 Incorrect 2 ms 8316 KB Output isn't correct
46 Incorrect 2 ms 8316 KB Output isn't correct
47 Incorrect 2 ms 8316 KB Output isn't correct
48 Incorrect 2 ms 8316 KB Output isn't correct
49 Incorrect 2 ms 8316 KB Output isn't correct
50 Incorrect 2 ms 8316 KB Output isn't correct
51 Incorrect 2 ms 8316 KB Output isn't correct
52 Incorrect 2 ms 8316 KB Output isn't correct
53 Incorrect 2 ms 8316 KB Output isn't correct
54 Incorrect 2 ms 8316 KB Output isn't correct
55 Incorrect 2 ms 8316 KB Output isn't correct
56 Incorrect 1 ms 8316 KB Output isn't correct
57 Incorrect 2 ms 8316 KB Output isn't correct
58 Incorrect 2 ms 8316 KB Output isn't correct
59 Incorrect 2 ms 8316 KB Output isn't correct
60 Incorrect 2 ms 8316 KB Output isn't correct
61 Incorrect 2 ms 8316 KB Output isn't correct
62 Incorrect 1 ms 8316 KB Output isn't correct
63 Incorrect 1 ms 8316 KB Output isn't correct
64 Incorrect 1 ms 8316 KB Output isn't correct
65 Incorrect 2 ms 8316 KB Output isn't correct
66 Incorrect 2 ms 8316 KB Output isn't correct
67 Incorrect 2 ms 8316 KB Output isn't correct
68 Incorrect 2 ms 8316 KB Output isn't correct
69 Incorrect 2 ms 8316 KB Output isn't correct
70 Incorrect 1 ms 8316 KB Output isn't correct
71 Incorrect 2 ms 8316 KB Output isn't correct
72 Incorrect 1 ms 8316 KB Output isn't correct
73 Incorrect 1 ms 8316 KB Output isn't correct
74 Incorrect 2 ms 8316 KB Output isn't correct
75 Incorrect 2 ms 8316 KB Output isn't correct
76 Incorrect 2 ms 8316 KB Output isn't correct
77 Incorrect 2 ms 8316 KB Output isn't correct
78 Incorrect 1 ms 8316 KB Output isn't correct
79 Incorrect 2 ms 8316 KB Output isn't correct
80 Incorrect 1 ms 8316 KB Output isn't correct
81 Incorrect 2 ms 8316 KB Output isn't correct
82 Incorrect 1 ms 8316 KB Output isn't correct
83 Incorrect 2 ms 8316 KB Output isn't correct
84 Incorrect 1 ms 8316 KB Output isn't correct
85 Incorrect 2 ms 8316 KB Output isn't correct
86 Incorrect 1 ms 8316 KB Output isn't correct
87 Incorrect 2 ms 8316 KB Output isn't correct
88 Incorrect 1 ms 8316 KB Output isn't correct
89 Incorrect 1 ms 8316 KB Output isn't correct
90 Incorrect 2 ms 8316 KB Output isn't correct
91 Incorrect 1 ms 8316 KB Output isn't correct
92 Incorrect 2 ms 8316 KB Output isn't correct
93 Incorrect 1 ms 8316 KB Output isn't correct
94 Incorrect 1 ms 8316 KB Output isn't correct
95 Incorrect 1 ms 8316 KB Output isn't correct
96 Incorrect 2 ms 8316 KB Output isn't correct
97 Incorrect 2 ms 8316 KB Output isn't correct
98 Incorrect 2 ms 8316 KB Output isn't correct
99 Incorrect 2 ms 8316 KB Output isn't correct
100 Incorrect 1 ms 8316 KB Output isn't correct