Submission #906122

#TimeUsernameProblemLanguageResultExecution timeMemory
906122JakobZorzQuality Of Living (IOI10_quality)C++17
Compilation error
0 ms0 KiB
#include"quality.h" #include<iostream> using namespace std; int w2,h2,w,h; int mat[3000][3000]; bool check(int val){ vector<int>cols(w2); for(int y=0;y<=h2-h;y++){ int low=0; for(int x2=0;x2<w-1;x2++) for(int y2=y;y2<y+h;y2++) low+=(mat[x2][y2]<=val); if(y==0){ for(int x=0;x<w2;x++) for(int y2=0;y2<h;y2++) cols[x]+=(mat[x][y2]<=val); }else{ for(int x=0;x<w2;x++){ cols[x]-=(mat[x][y-1]<=val); cols[x]+=(mat[x][y+h-1]<=val); } } for(int x=0;x<=w2-w;x++){ if(x) low-=cols[x-1]; low+=cols[x+w-1]; if(low>=(w*h+1)/2){ //cout<<val<<" "<<low<<" "<<(w*h+1)/2<<" false\n"; return true; } } } //cout<<val<<" true\n"; return false; } int rectangle(int R,int C,int H,int W,int Q[3001][3001]){ w2=R; h2=C; w=H; h=W; for(int x=0;x<w2;x++) for(int y=0;y<h2;y++) mat[x][y]=Q[x][y]; int bl=0,br=w2*h2; while(bl<br-1){ int mid=(bl+br)/2; if(check(mid)) br=mid; else bl=mid; } return br; }

Compilation message (stderr)

quality.cpp: In function 'bool check(int)':
quality.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int>cols(w2);
      |     ^~~~~~
quality.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include<iostream>
  +++ |+#include <vector>
    3 | using namespace std;
quality.cpp:9:12: error: expected primary-expression before 'int'
    9 |     vector<int>cols(w2);
      |            ^~~
quality.cpp:20:21: error: 'cols' was not declared in this scope
   20 |                     cols[x]+=(mat[x][y2]<=val);
      |                     ^~~~
quality.cpp:23:17: error: 'cols' was not declared in this scope
   23 |                 cols[x]-=(mat[x][y-1]<=val);
      |                 ^~~~
quality.cpp:31:22: error: 'cols' was not declared in this scope
   31 |                 low-=cols[x-1];
      |                      ^~~~
quality.cpp:32:18: error: 'cols' was not declared in this scope
   32 |             low+=cols[x+w-1];
      |                  ^~~~