Submission #594095

# Submission time Handle Problem Language Result Execution time Memory
594095 2022-07-12T05:26:31 Z 반딧불(#8432) Sandcastle 2 (JOI22_ho_t5) C++17
10 / 100
5000 ms 6228 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int xx[]={0, 1, 0, -1}, yy[]={1, 0, -1, 0};

struct dat{
    int x, y, v;
    dat(){}
    dat(int x, int y, int v): x(x), y(y), v(v){}
    bool operator<(const dat &r)const{
        return v<r.v;
    }
};

int n, m;
int arr[1502][1502];
ll ans;

int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            scanf("%d", &arr[i][j]);
        }
    }
    for(int a=1; a<=n; a++){
        for(int b=a; b<=n; b++){
            for(int c=1; c<=m; c++){
                for(int d=c; d<=m; d++){
                    int minV = 2e9, x = 0, y = 0, cnt = 1;
                    for(int i=a; i<=b; i++) for(int j=c; j<=d; j++){
                        if(minV > arr[i][j]) minV = arr[i][j], x = i, y = j;
                    }
                    while(1){
                        int minV = 2e9, minD = -1;
                        for(int dir=0; dir<4; dir++){
                            int tx = x+xx[dir], ty = y+yy[dir];
                            if(tx<a || tx>b || ty<c || ty>d || arr[x][y] > arr[tx][ty]) continue;
                            if(minV > arr[tx][ty]) minV = arr[tx][ty], minD = dir;
                        }
                        if(minD == -1) break;
                        cnt++;
                        x += xx[minD], y += yy[minD];
                    }
                    if(cnt == (b-a+1)*(d-c+1)) ans++;
                }
            }
        }
    }
    printf("%lld", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d", &arr[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5092 ms 468 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Execution timed out 5095 ms 6228 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Execution timed out 5095 ms 6228 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Execution timed out 5095 ms 6228 KB Time limit exceeded
8 Halted 0 ms 0 KB -