답안 #919022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919022 2024-01-31T04:59:11 Z hungtien2202 Bob (COCI14_bob) C++14
0 / 120
1000 ms 8528 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,m;
ll grid[1005][1005];

ll solve(int target) {
    ll cnt = 0;

    for (int l=1;l<=m;l++) {
        vector<ll> heights(n, 0);
        for (int r=l;r<=m;r++) {
            for (int i=1;i<=n;i++) {
                if (grid[i][r] == target) {
                    heights[i-1]++;
                } else {
                    heights[i-1] = 0;
                }
            }
            ll cur = 0;
            for (int i=1;i<=n;i++) {
                if (heights[i-1] == r - l + 1) {
                    cur++;
                }
                else {
                    cnt += cur*(cur+1) /2;
                    cur = 0;
                }
            }
            cnt += cur*(cur+1) / 2;
        }
    }
    return cnt;
}

int main() {
    scanf("%ld", &n);
    scanf("%ld", &m);
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=m;j++) {
            scanf("%ld", &grid[i][j]);
        }
    }
    cout << solve(1) + solve(2);
    return 0;
}

Compilation message

bob.cpp: In function 'int main()':
bob.cpp:38:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'long long int*' [-Wformat=]
   38 |     scanf("%ld", &n);
      |            ~~^   ~~
      |              |   |
      |              |   long long int*
      |              long int*
      |            %lld
bob.cpp:39:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'long long int*' [-Wformat=]
   39 |     scanf("%ld", &m);
      |            ~~^   ~~
      |              |   |
      |              |   long long int*
      |              long int*
      |            %lld
bob.cpp:42:22: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'long long int*' [-Wformat=]
   42 |             scanf("%ld", &grid[i][j]);
      |                    ~~^   ~~~~~~~~~~~
      |                      |   |
      |                      |   long long int*
      |                      long int*
      |                    %lld
bob.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%ld", &n);
      |     ~~~~~^~~~~~~~~~~
bob.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%ld", &m);
      |     ~~~~~^~~~~~~~~~~
bob.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             scanf("%ld", &grid[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 183 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 190 ms 4720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 194 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 188 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1025 ms 8276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1044 ms 8528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1048 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1055 ms 8284 KB Time limit exceeded
2 Halted 0 ms 0 KB -