Submission #419806

#TimeUsernameProblemLanguageResultExecution timeMemory
419806Runtime_error_The Kingdom of JOIOI (JOI17_joioi)C++14
100 / 100
1574 ms102064 KiB
#include <bits/stdc++.h> #define ll long long #define pi pair<ll,ll> #define mid (l+r)/2 #define pb push using namespace std; const ll inf = 2e3+9,MX = 1e9+9; ll n,m,ts,OriginalArr[inf][inf],a[inf][inf],mn = MX,mx,vis[inf][inf]; pi MaxVals; queue<ll> q; bool check(ll k,bool ReverseRow,bool ReverseCol){ for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j] = OriginalArr[ (ReverseCol?n-i+1:i) ][ (ReverseRow?m-j+1:j) ]; int Col = 1; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) if(a[i][j] > mn+k) Col = max(Col,j+1); for(int j=1;j<Col;j++) if(a[i][j] < mx-k) return 0; } return 1; } signed main(){ scanf("%lld%lld",&n,&m); for(ll i=1;i<=n;i++){ for(ll j=1;j<=m;j++){ scanf("%lld",&OriginalArr[i][j]); mx = max(mx,OriginalArr[i][j]); mn = min(mn,OriginalArr[i][j]); } } ll l = -1, r = mx-mn; while(r-l>1){ if(check(mid,0,0) || check(mid,1,0) || check(mid,0,1) || check(mid,1,1)) r = mid; else l = mid; } printf("%lld\n",r); }

Compilation message (stderr)

joioi.cpp: In function 'int main()':
joioi.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
joioi.cpp:33:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 scanf("%lld",&OriginalArr[i][j]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...