Submission #51528

#TimeUsernameProblemLanguageResultExecution timeMemory
51528MoesashiMinamotoThe Kingdom of JOIOI (JOI17_joioi)C++14
0 / 100
2 ms520 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int h[4], w[4]; int a[4][2003][2003]; int mi; void preproc() { for(int t = 1; t < 4; t++) { h[t] = w[t-1]; w[t] = h[t-1]; for (int i = 1; i <= h[t-1]; i++) { for (int j = 1; j <= w[t-1]; j++) { a[t][j][h[t-1]-i+1] = a[t-1][i][j]; } } } } bool chec(int k) { for (int t = 0; t < 4; t++) { int lim, nexlim = w[t]; int ma = -INT_MAX, mii = INT_MAX; for (int i = 1; i <= h[t]; i++) { lim = nexlim; for (int j = 1; j <= lim; j++) { if (a[t][i][j] <= mi + k) { continue; } else { nexlim = j-1; break; } } for (int j = lim+1; j <= w[t]; j++) { mii = min(mii, a[t][i][j]); ma = max(ma, a[t][i][j]); } } if (ma - mii <= k) return true; } return false; } signed main() { scanf("%lld%lld", &h[0], &w[0]); mi = INT_MAX; for (int i = 1; i <= h[0]; i++) { for (int j = 1; j <= w[0]; j++) { scanf("%lld", &a[0][i][j]); mi = min(mi, a[0][i][j]); } } preproc(); /*for (int t = 0; t < 4; t++) { for (int i = 1; i <= h[t]; i++) { for (int j = 1; j <= w[t]; j++) { printf ("%d ", a[t][i][j]); } printf("\n"); } printf("\n"); }*/ int res = 0; for (int j = 33; j >= 0; j--) { if (res + (1ll << j) <= 1000000000) { int cur = res + (1ll << j); if (!chec(cur)) { res = cur; } } } printf("%lld", res+1); }

Compilation message (stderr)

joioi.cpp: In function 'int main()':
joioi.cpp:59:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &h[0], &w[0]);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
joioi.cpp:65:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &a[0][i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...