답안 #762103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762103 2023-06-20T20:16:01 Z alexander707070 Sky Walking (IOI19_walk) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define MAXN 407
using namespace std;
 
int n,m,pr[MAXN][MAXN],nxt[MAXN][MAXN];
int a[MAXN][MAXN],last,ans;
int maxs[MAXN][MAXN][MAXN],bro[MAXN][MAXN][MAXN];
int pref[MAXN][MAXN][MAXN];

bool check(int i,int j,int l,int r){
    for(int k=i;k<=j;k++){
        if(bro[k][l][r]>=a[k][l-1] or bro[k][l][r]>=a[k][r+1])return false;
    }
    return true;
}

long long count_rectangles(vector< vector<int> > A){
    n=int(A.size()); m=int(A[0].size());

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            a[i][f]=A[i-1][f-1];
        }
    }

    for(int i=1;i<=m;i++){
        for(int f=1;f<=n;f++){
            maxs[i][f][f]=a[f][i];
            for(int k=f+1;k<=n;k++){
                maxs[i][f][k]=max(maxs[i][f][k-1],a[k][i]);
            }
        }
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            bro[i][f][f]=a[i][f];
            for(int k=f+1;k<=m;k++){
                bro[i][f][k]=max(bro[i][f][k-1],a[i][k]);
            }
        }
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            for(int k=f;k<=m;k++){
                pref[i][f][k]=pref[i-1][f][k];
            }
        }

        for(int f=2;f<=m-1;f++){
            pr[i][f]=0; nxt[i][f]=m+1;
            for(int k=f-1;k>=1;k--){
                if(a[i][k]>a[i][f]){pr[i][f]=k;break;}
            }
            for(int k=f+1;k<=m;k++){
                if(a[i][k]>a[i][f]){nxt[i][f]=k;break;}
            }

            pref[i][pr[i][f]][nxt[i][f]]=pref[i-1][pr[i][f]][nxt[i][f]]+1;
        }
    }

    for(int i=2;i<=n-1;i++){
        for(int f=i;f<=n-1;f++){
            last=2;

            for(int k=2;k<=m-1;k++){
                if(maxs[k][i][f]<a[i-1][k] and maxs[k][i][f]<a[f+1][k])continue;

                for(int p=last;p<=k-1;p++){
                    if(pr[f][p]+1<last or nxt[f][p]-1>k-1)continue;
                    //if(pref[f][pr[f][p]][nxt[f][p]] - pref[i-1][pr[f][p]][nxt[f][p]] == f-i+1)ans++;
                    if(check(i,f,pr[f][p]+1,nxt[f][p]-1))ans++;
                }
                last=k+1;
            }
         
            for(int p=last;p<=m-1;p++){
                if(pr[f][p]+1<last or nxt[f][p]-1>m-1)continue;
                //if(pref[f][pr[f][p]][nxt[f][p]] - pref[i-1][pr[f][p]][nxt[f][p]] == f-i+1)ans++;
                if(check(i,f,pr[f][p]+1,nxt[f][p]-1))ans++;
            }
        }
    }
    
    return ans;
}

/*
int main(){

    cout<<count_rectangles({{4, 8, 7, 5, 6},
{7, 4, 10, 3, 5},
{9, 7, 20, 14, 2},
{9, 14, 7, 3, 6},
{5, 7, 5, 2, 7},
{4, 5, 13, 5, 6}})<<"\n";

    return 0;
}
*/

Compilation message

/usr/bin/ld: /tmp/ccOGrMLJ.o: in function `main':
grader.cpp:(.text.startup+0x385): undefined reference to `min_distance(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, int, int)'
collect2: error: ld returned 1 exit status