Submission #777424

#TimeUsernameProblemLanguageResultExecution timeMemory
777424PetrixQuality Of Living (IOI10_quality)C++17
Compilation error
0 ms0 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; int rectangle(int r,int c,int h,int w,int q[3001][3001]){ int sm[3001][3001],bi[3001][3001],v[3001][3001],st,dr,mij; for(i=1;i<=r;i++){ for(j=1;j<=c;j++){ v[i][j]=q[i-1][j-1]; } } st=0;dr=r*c;ans=r*c; while(st<dr){ int s,b; mij=(st+dr)/2; bool adv=0; for(i=1;i<=r;i++){ s=0;b=0; for(j=1;j<=c;j++){ sm[i][j]=sm[i-1][j]+s; if(v[i][j]<mij){ sm[i][j]++;s++; } bi[i][j]=bi[i-1][j]+b; if(v[i][j]>mij){ bi[i][j]++;b++; } } } for(i=1;i<=r-h+1;i++){ for(j=0;j<c-w+1;j++){ s=sm[i+h-1][j+w-1]-sm[i+h-1][j-1]-sm[i-1][j+w-1]+sm[i-1][j-1]; b=bi[i+h-1][j+w-1]-bi[i+h-1][j-1]-bi[i-1][j+w-1]+bi[i-1][j-1]; int n=r*c; if(s==b && s<=n/2 && n<=n/2) ans=min(ans,mij); if(s>=b) adv=1; } } if(adv==0) st=mij+1; else dr=mij-1; } return ans; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:7:9: error: 'i' was not declared in this scope
    7 |     for(i=1;i<=r;i++){
      |         ^
quality.cpp:8:13: error: 'j' was not declared in this scope
    8 |         for(j=1;j<=c;j++){
      |             ^
quality.cpp:12:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     st=0;dr=r*c;ans=r*c;
      |                 ^~~
      |                 abs
quality.cpp:17:13: error: 'i' was not declared in this scope
   17 |         for(i=1;i<=r;i++){
      |             ^
quality.cpp:19:17: error: 'j' was not declared in this scope
   19 |             for(j=1;j<=c;j++){
      |                 ^
quality.cpp:30:13: error: 'i' was not declared in this scope
   30 |         for(i=1;i<=r-h+1;i++){
      |             ^
quality.cpp:31:17: error: 'j' was not declared in this scope
   31 |             for(j=0;j<c-w+1;j++){
      |                 ^