제출 #549728

#제출 시각아이디문제언어결과실행 시간메모리
549728PherokungThe Kingdom of JOIOI (JOI17_joioi)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 2005 #define F first #define S second int n,m,A[N][N],a[N][N],dp[N][N],ans=1e9; typedef pair<int,int> pa; bool cal(int n,int m,int v){ memset(dp,0,sizeof dp); for(int i=1;i<=n;i++) dp[0][i] = 1; for(int i=1;i<=m;i++) dp[i][0] = 1; for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) if(a[j][i] <= v && dp[j][i-1] && dp[j-1][i]) dp[j][i] = 1; int mx0=0,mx1=0,mn0=1e9,mn1=1e9; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){ if(!dp[i][j]) mx0 = max(mx0,a[i][j]), mn0 = min(mn0,a[i][j]); else mx1 = max(mx1,a[i][j]), mn1 = min(mn1,a[i][j]); } if(!dp[1][1]) return 0; if(dp[n][m]) return 1; ans = min(ans,max(mx1-mn1,mx0-mn0)); if(mn1 > mn0) return 0; return mx1-mn1 > mx0-mn0; } void sol(int n,int m){ int be = 1,ed = 1e9; while(be < ed){ int mid = (be+ed)/2; // printf("%d : %d %d\n",mid,V.F,V.S); if(cal(n,m,mid)) ed = mid; else be = mid+1; } } int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lld",&a[i][j]); sol(n,m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) b[i][j] = a[i][j]; for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) a[i][j] = b[n-j+1][i]; sol(m,n); for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) b[i][j] = a[i][j]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j] = b[m-j+1][i]; sol(n,m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) b[i][j] = a[i][j]; for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) a[i][j] = b[n-j+1][i]; sol(m,n); printf("%lld",ans); printf("%d",ans); }

컴파일 시 표준 에러 (stderr) 메시지

joioi.cpp: In function 'int main()':
joioi.cpp:38:56: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   38 |  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lld",&a[i][j]);
      |                                                     ~~~^  ~~~~~~~~
      |                                                        |  |
      |                                                        |  int*
      |                                                        long long int*
      |                                                     %d
joioi.cpp:41:49: error: 'b' was not declared in this scope
   41 |     for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) b[i][j] = a[i][j];
      |                                                 ^
joioi.cpp:42:59: error: 'b' was not declared in this scope
   42 |     for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) a[i][j] = b[n-j+1][i];
      |                                                           ^
joioi.cpp:45:46: error: 'b' was not declared in this scope
   45 |  for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) b[i][j] = a[i][j];
      |                                              ^
joioi.cpp:46:59: error: 'b' was not declared in this scope
   46 |     for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j] = b[m-j+1][i];
      |                                                           ^
joioi.cpp:49:46: error: 'b' was not declared in this scope
   49 |  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) b[i][j] = a[i][j];
      |                                              ^
joioi.cpp:50:59: error: 'b' was not declared in this scope
   50 |     for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) a[i][j] = b[n-j+1][i];
      |                                                           ^
joioi.cpp:53:13: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   53 |  printf("%lld",ans);
      |          ~~~^  ~~~
      |             |  |
      |             |  int
      |             long long int
      |          %d
joioi.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
joioi.cpp:38:51: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lld",&a[i][j]);
      |                                              ~~~~~^~~~~~~~~~~~~~~~~