Submission #481827

# Submission time Handle Problem Language Result Execution time Memory
481827 2021-10-22T02:30:48 Z theshadow_04 Quality Of Living (IOI10_quality) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define Task "QUALITY"
#define F first
#define S second

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 3005;

int r, c, h, w, p[maxn][maxn];
int small[maxn][maxn], big[maxn][maxn];

int Get1(int x, int y, int u, int v) {
  return small[u][v] - small[u][y - 1] - small[x - 1][v] + small[x - 1][y - 1];
}

int Get2(int x, int y, int u, int v) {
  return big[u][v] - big[u][y - 1] - big[x - 1][v] + big[x - 1][y - 1];
}

bool Check(int x) {
  for(int i = 1; i <= r; ++ i) {
    for(int j = 1; j <= c; ++ j) {
      small[i][j] = small[i - 1][j] + small[i][j - 1] - small[i - 1][j - 1] + (p[i][j] < x);
      big[i][j] = big[i - 1][j] + big[i][j - 1] - big[i - 1][j - 1] + (p[i][j] > x);
    }
  }
  for(int i = h; i <= r; ++ i) {
    for(int j = w; j <= c; ++ j) {
      int cur1 = Get1(i - h + 1, j - w + 1, i, j);
      int cur2 = Get2(i - h + 1, j - w + 1, i, j);
      if(cur1 >= cur2) return 1;
    }
  }
  return 0;
}

int Rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
  cin >> r >> c >> h >> w;
  r = R, c = C, h = H, w = W;
  for(int i = 1; i <= r; ++ i) {
    for(int j = 1; j <= c; ++ j) p[i][j] = Q[i][j];
  }
  int Le = h * w / 2, Ri = r * c + 1;
  while(Ri - Le > 1) {
    int mid = (Le + Ri) >> 1;
    if(Check(mid)) Ri = mid;
    else Le = mid;
  }
  return Ri;
}

//signed main() {
//  ios_base::sync_with_stdio(0);
//  cin.tie(0), cout.tie(0);
//  if(fopen(Task".inp", "r")) {
//     freopen(Task".inp", "r", stdin);
//     freopen(Task".out", "w", stdout);
//  }
//  Solve();
//}

Compilation message

/usr/bin/ld: /tmp/ccWxSGr0.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