Submission #1017300

#TimeUsernameProblemLanguageResultExecution timeMemory
1017300NintsiChkhaidzeQuality Of Living (IOI10_quality)C++17
0 / 100
1 ms4440 KiB
#include "quality.h" #include <bits/stdc++.h> #define pb push_back using namespace std; int a[3001][3001],pr[3001][3001]; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { vector <int> values; for (int i=0;i<R;i++) for (int j=0;j<C;j++) values.pb(Q[i][j]); sort(values.begin(),values.end()); int l = 0,r = (int)values.size() - 1,ans = -1; // for (int y: values) cout<<y<<" "; // cout<<endl; // l = r = 19; while (l <= r){ int mid = (l + r) >> 1; int mdn = values[mid],X,Y; for (int i=0;i<R;i++){ for (int j=0;j<C;j++){ if (Q[i][j] > mdn) a[i][j] = +1; else if (Q[i][j] < mdn) a[i][j] = -1; else a[i][j] = 0,X=i,Y=j; // cout<<a[i][j]<<" "; } // cout<<endl; } bool check = 0; for (int i =0; i <R; i++){ for (int j=0;j<C;j++){ pr[i][j] = pr[i-1][j] + pr[i][j - 1] - pr[i - 1][j - 1] + a[i][j]; } } // cout<<"! "<<X <<" "<<Y<<endl; for (int i = 0 ;i + H - 1 < R; i++){ for (int j = 0; j + W - 1 < C; j++){ if (!(X >= i && X <= i + H - 1 && Y >= j && Y <= j + W - 1)) continue; int sum = pr[i+H-1][j+W-1] - pr[i+H-1][j-1] - pr[i-1][j+W-1] + pr[i-1][j-1]; if (sum==0) { // cout<<"&&& "<<i<<" "<<j<<endl; check=1;break;} } } if (check){ ans = mdn; r = mid - 1; }else{ l = mid + 1; } } return ans; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:44:9: warning: 'Y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     if (!(X >= i && X <= i + H - 1 && Y >= j && Y <= j + W - 1)) continue;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
quality.cpp:44:5: warning: 'X' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     if (!(X >= i && X <= i + H - 1 && Y >= j && Y <= j + W - 1)) continue;
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...