Submission #887482

#TimeUsernameProblemLanguageResultExecution timeMemory
887482hafoThe Kingdom of JOIOI (JOI17_joioi)C++14
0 / 100
1 ms2516 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define Size(x) (int) x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 21; const int maxn = 2e3 + 7; const ll oo = 1e9 + 69; int n, m, a[maxn][maxn], mx, mn, b[maxn][maxn]; bool ok(int d) { int last = 0; for(int i = 1; i <= n; i++) { int r = m; for(int j = m; j >= 1; j--) { if(a[i][j] >= mx - d) r--; else break; } for(int j = 1; j <= last; j++) { if(a[i][j] > mn + d) return 0; } maxi(last, r); } return 1; } void flip() { for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { b[j][n - i + 1] = a[i][j]; } } swap(n, m); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) a[i][j] = b[i][j]; } } bool check(int d) { int ans = 0; for(int i = 0; i < 4; i++) { ans |= ok(d); flip(); } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(TASK".inp", "r", stdin); //freopen(TASK".out", "w", stdout); cin>>n>>m; mx = 0; mn = oo; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin>>a[i][j]; maxi(mx, a[i][j]); mini(mn, a[i][j]); } } int l = 0, r = 1e9, mid, res; while(l <= r) { mid = l + r >> 1; if(check(mid)) { res = mid; r = mid - 1; } else l = mid + 1; } cout<<res; return 0; }

Compilation message (stderr)

joioi.cpp: In function 'int main()':
joioi.cpp:84:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   84 |         mid = l + r >> 1;
      |               ~~^~~
joioi.cpp:90:11: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   90 |     cout<<res;
      |           ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...