(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1100791

#TimeUsernameProblemLanguageResultExecution timeMemory
1100791AlexandreQuality Of Living (IOI10_quality)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 3100; int R,C,H,W; int m[MAXN][MAXN], SP[MAXN][MAXN], h[MAXN][MAXN], has[MAXN][MAXN], SPH[MAXN][MAXN]; bool teste(int v){ for(int i = 1; i <= R; i++){ for(int j = 1; j <= C; j++){ SP[i][j] = 0; h[i][j] = 0; has[i][j] = 0; SPH[i][j] = 0; } } for(int i = 1; i <= R; i++){ for(int j = 1; j <= C; j++){ if(m[i][j]<v){ h[i][j] = 1; }else{ h[i][j] = 0; } if(m[i][j]==v) has[i][j] = 1; if(i==1 && j==1){ SP[i][j] = h[i][j]; continue; } if(i==1){ SP[i][j] = SP[i][j-1] + h[i][j]; continue; } if(j==1){ SP[i][j] = SP[i-1][j] + h[i][j]; continue; } SP[i][j] = SP[i-1][j] + SP[i][j-1] - SP[i-1][j-1] + h[i][j]; } } for(int i = 1; i <= R; i++){ for(int j = 1; j <= C; j++){ if(i==1 && j==1){ SPH[i][j] = has[i][j]; continue; } if(i==1){ SPH[i][j] = SPH[i][j-1] + has[i][j]; continue; } if(j==1){ SPH[i][j] = SPH[i-1][j] + has[i][j]; continue; } SPH[i][j] = SPH[i-1][j] + SPH[i][j-1] - SPH[i-1][j-1] + has[i][j]; } } for(int i = H; i <= R; i++){ for(int j = W; j <= C; j++){ int total = SP[i][j] - SP[i][j-W] - SP[i-H][j] + SP[i-H][j-W]; int contem = SPH[i][j] - SPH[i][j-W] - SPH[i-H][j] + SPH[i-H][j-W]; if((total == (H*W-1)/2) && contem!=0) return true; } } return false; } int bb(){ int ini = 1; int fim = R*C; while(ini<fim){ int m = (ini+fim)/2; if(teste(m)){ fim = m; }else{ ini = m + 1; } } return fim; } int main(){ scanf("%d %d %d %d",&R,&C,&H,&W); for(int i = 1; i <= R; i++){ for(int j = 1; j <= C; j++){ scanf("%d",&m[i][j]); } } printf("%d\n",bb()); }

Compilation message (stderr)

quality.cpp: In function 'int main()':
quality.cpp:117:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  117 |     scanf("%d %d %d %d",&R,&C,&H,&W);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
quality.cpp:123:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  123 |             scanf("%d",&m[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc0F2AJ3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckizCD1.o:quality.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc0F2AJ3.o: in function `main':
grader.cpp:(.text.startup+0xe9): undefined reference to `rectangle(int, int, int, int, int (*) [3001])'
collect2: error: ld returned 1 exit status