Submission #549732

#TimeUsernameProblemLanguageResultExecution timeMemory
549732PherokungThe Kingdom of JOIOI (JOI17_joioi)C++14
Compilation error
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 valid(int n,int m,int val,int &ans){ int i,j,mi[2],ma[2]; bitset<N> dp[N]; mi[0]=mi[1]=1e9; ma[0]=ma[1]=0; for(i=0;i<=m;i++)dp[n+1][i]=true; for(i=0;i<=n;i++)dp[i]=1; for(i=n;i>0;i--)for(j=1;a[i][j]<=val&&dp[i+1][j]&&dp[i][j-1];j++)dp[i][j]=true; if(dp[1][m])return true; if(!dp[n][1])return false; for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ mi[dp[i][j]]=min(mi[dp[i][j]],a[i][j]); ma[dp[i][j]]=max(ma[dp[i][j]],a[i][j]); } } ans=min(ans,max(ma[0]-mi[0],ma[1]-mi[1])); if(mi[1]>=mi[0])return false; return ma[1]-mi[1]>ma[0]-mi[0]; } void sol(int n,int m){ int be = 1,ed = 1e9; while(be < ed){ int mid = (be+ed)/2; 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("%d",&A[i][j]); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j] = A[i][j]; sol(n,m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[n-i+1][j] = A[i][j]; sol(n,m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[m-j+1][n-i+1] = A[i][j]; sol(m,n); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[j][n-i+1] = A[i][j]; sol(m,n); printf("%d",ans); }

Compilation message (stderr)

joioi.cpp: In function 'void sol(int, int)':
joioi.cpp:34:6: error: 'cal' was not declared in this scope
   34 |   if(cal(n,m,mid)) ed = mid;
      |      ^~~
joioi.cpp: In function 'int main()':
joioi.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
joioi.cpp:41:51: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&A[i][j]);
      |                                              ~~~~~^~~~~~~~~~~~~~~