답안 #768130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768130 2023-06-27T13:54:29 Z Username4132 Dijamant (COCI22_dijamant) C++14
70 / 70
259 ms 86204 KB
#include<iostream>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)

const int MAXN = 2010;
int n, m, ans, sum[2*MAXN][2*MAXN], pr[MAXN][MAXN];
bool arr[MAXN][MAXN];

inline int su(int x1, int y1, int x2, int y2){
    return sum[x1][y1]+sum[x2][y2]-sum[x1][y2]-sum[x2][y1];
}

bool test_diamond(int cx, int cy, int sz){
    if(sz<=0 || cx<sz || cy<sz || cx>=n-sz || cy>=m-sz) return false;
    int x=cx+cy+1, y=cx-cy+m;
    int s1 = su(x-sz-1, y-sz-1, x+sz, y+sz);
    int s2 = su(x-sz, y-sz, x+sz-1, y+sz-1);
    return s1==(sz<<2) && s2==0;
}

int main(){
    scanf("%d %d", &n, &m);
    forn(i, n) forn(j, m){
        char ch; scanf(" %c", &ch);
        sum[i+j+1][i-j+m] = arr[i][j] = (ch=='#');
    }
    forn(i, n+m) forn(j, n+m) sum[i+1][j+1]+=sum[i+1][j]+sum[i][j+1]-sum[i][j];
    forn(i, n){
        int lst = -1;
        forn(j, m){
            if(arr[i][j]) lst=j;
            pr[i][j]=lst;
        }
    }
    forn(i, n) forn(j, m) ans+=test_diamond(i, j, j - pr[i][j]);
    printf("%d\n", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:24:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         char ch; scanf(" %c", &ch);
      |                  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1724 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1748 KB Output is correct
9 Correct 1 ms 1748 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1852 KB Output is correct
12 Correct 1 ms 1748 KB Output is correct
13 Correct 1 ms 1724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1724 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1748 KB Output is correct
9 Correct 1 ms 1748 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1852 KB Output is correct
12 Correct 1 ms 1748 KB Output is correct
13 Correct 1 ms 1724 KB Output is correct
14 Correct 219 ms 82892 KB Output is correct
15 Correct 223 ms 83536 KB Output is correct
16 Correct 241 ms 80748 KB Output is correct
17 Correct 230 ms 81008 KB Output is correct
18 Correct 238 ms 86204 KB Output is correct
19 Correct 229 ms 79104 KB Output is correct
20 Correct 259 ms 86016 KB Output is correct
21 Correct 232 ms 79004 KB Output is correct
22 Correct 237 ms 82636 KB Output is correct
23 Correct 228 ms 79076 KB Output is correct
24 Correct 243 ms 83044 KB Output is correct
25 Correct 190 ms 79048 KB Output is correct
26 Correct 222 ms 80180 KB Output is correct