답안 #594188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594188 2022-07-12T08:01:35 Z 조영욱(#8434) Sandcastle 2 (JOI22_ho_t5) C++17
10 / 100
5000 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

int n,m;
int arr[100][100];
typedef pair<int,int> P;
typedef pair<int,P> iP;

int main() {
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            scanf("%d",&arr[i][j]);
        }
    }
    if (n==1) {
        long long ret=-m;
        int pr=0;
        for(int i=1;i<m;i++) {
            if (arr[0][i-1]>arr[0][i]) {
                ret+=1LL*(i-pr)*(i+1-pr)/2;
                pr=i;
            }
        }
        ret+=1LL*(m-pr)*(m+1-pr)/2;
        pr=0;
        for(int i=1;i<m;i++) {
            if (arr[0][i-1]<arr[0][i]) {
                ret+=1LL*(i-pr)*(i+1-pr)/2;
                pr=i;
            }
        }
        ret+=1LL*(m-pr)*(m+1-pr)/2;
        printf("%lld",ret);
        return 0;
    }
    int ret=0;
    for(int x1=0;x1<n;x1++) {
        for(int y1=0;y1<m;y1++) {
            for(int x2=x1;x2<n;x2++) {
                for(int y2=y1;y2<m;y2++) {
                    vector<iP> v;
                    for(int i=x1;i<=x2;i++) {
                        for(int j=y1;j<=y2;j++) {
                            v.push_back(iP(arr[i][j],P(i,j)));
                        }
                    }
                    sort(v.begin(),v.end());
                    bool flag=true;
                    for(int i=0;i+1<v.size();i++) {
                        if (abs(v[i+1].second.first-v[i].second.first)+abs(v[i+1].second.second-v[i].second.second)!=1) {
                            flag=false;
                            break;
                        }
                    }
                    if (flag) {
                        ret++;
                    }
                }
            }
        }
    }
    printf("%d",ret);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                     for(int i=0;i+1<v.size();i++) {
      |                                 ~~~^~~~~~~~~
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |             scanf("%d",&arr[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 5 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Execution timed out 5034 ms 212 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Execution timed out 5034 ms 212 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Execution timed out 5034 ms 212 KB Time limit exceeded
8 Halted 0 ms 0 KB -