답안 #1012574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012574 2024-07-02T11:01:10 Z amirhoseinfar1385 웜뱃 (IOI13_wombats) C++17
컴파일 오류
0 ms 0 KB
#include "wombats.h"
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
const unsigned int maxn=5000+10,maxm=200+10;
unsigned int allr[maxn][maxm],allc[maxn][maxm],dp[maxn][maxm],n,m,ps[maxm],suf[maxm],inf=1e11+5,psmx[maxn],sufmx[maxn];
 
void calc(){
    for(unsigned int k=1;k<=m;k++){
        for(unsigned int j=1;j<=m;j++){
            ps[j]=ps[j-1]+allr[n][j-1];
        }
        for(unsigned int j=m;j>=1;j--){
            suf[j]=suf[j+1]+allr[n][j];
        }
        for(unsigned int j=1;j<=m;j++){
            if(j<=k){
                dp[j][k]=ps[k]-ps[j];
            }else{
                dp[j][k]=suf[k]-suf[j];
            }
        }
    //    for(unsigned int j=1;j<=m;j++){
      //      cout<<dp[j][k]<<" ";
     //   }
       // cout<<endl;
        psmx[0]=sufmx[m+1]=inf;
        for(unsigned int i=n-1;i>=1;i--){
            for(unsigned int j=1;j<=m;j++){
                ps[j]=ps[j-1]+allr[i][j-1];
            }
            for(unsigned int j=m;j>=1;j--){
                suf[j]=suf[j+1]+allr[i][j];
            }
            for(unsigned int j=1;j<=m;j++){
                psmx[j]=min(psmx[j-1],suf[j]+dp[j][k]+allc[i][j]);
            }
            for(unsigned int j=m;j>=1;j--){
                sufmx[j]=min(sufmx[j+1],ps[j]+dp[j][k]+allc[i][j]);
            }
            for(unsigned int j=1;j<=m;j++){
            //    cout<<psmx[j-1]<<" "<<suf[j]<<" "<<sufmx[j+1]<<" "<<ps[j]<<endl;
                dp[j][k]=min(dp[j][k]+allc[i][j],min(psmx[j-1]-suf[j],sufmx[j+1]-ps[j]));
            }
        //    cout<<"salam"<<endl;
          //  for(unsigned int j=1;j<=m;j++){
            //    cout<<dp[j][k]<<" ";
        //    }
          //  cout<<endl;
        }
    }
}
 
void init(unsigned int R,unsigned int C,unsigned int H[5000][200],unsigned int V[5000][200]) {
    n=R;
    m=C;
    for(unsigned int i=1;i<=n;i++){
        for(unsigned int j=1;j<=m-1;j++){
            allr[i][j]=H[i-1][j-1];
        }
    }
    for(unsigned int i=1;i<=n-1;i++){
        for(unsigned int j=1;j<=m;j++){
            allc[i][j]=V[i-1][j-1];          
        }
    }
    calc();
}
 
void changeH( int P, int Q, int W) {
    P++;
    Q++;
    allr[P][Q]=W;
    calc();
}
 
void changeV( int P, int Q, int W) {
    P++;
    Q++;
    allc[P][Q]=W;
    calc();
}
 
int escape( int V1, int V2) {
    V1++;
    V2++;
    return dp[V1][V2];    
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp:7:94: warning: overflow in conversion from 'double' to 'unsigned int' changes value from '1.00000000005e+11' to '4294967295' [-Woverflow]
    7 | unsigned int allr[maxn][maxm],allc[maxn][maxm],dp[maxn][maxm],n,m,ps[maxm],suf[maxm],inf=1e11+5,psmx[maxn],sufmx[maxn];
      |                                                                                          ~~~~^~
/usr/bin/ld: /tmp/cck4GIuC.o: in function `main':
grader.c:(.text.startup+0x129): undefined reference to `init'
collect2: error: ld returned 1 exit status