답안 #258651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258651 2020-08-06T10:20:05 Z uacoder123 삶의 질 (IOI10_quality) C++14
0 / 100
1 ms 768 KB
#include <bits/stdc++.h>
#include "quality.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
typedef tree<pair<lli,int>,null_type,less<pair<lli,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int r,c,h,w,arr[3001][3001],pr[3001],p[3001][3001];
int check(int m)
{
  int s=0,ch=0;
  for(int i=0;i<r;++i)
  {
    p[i+1][c-w+1]=0;
    for(int j=c-w;j<c;++j)
    {
      if(arr[i][j]<m)
        p[i+1][c-w+1]+=-1;
      else if(arr[i][j]>m)
        p[i+1][c-w+1]+=1;
    }
    if(i>=h)
      s-=p[i-h+1][c-w+1];
    s+=p[i+1][c-w+1];
    if(i>=h-1)
    {
      pr[i]=s;
      if(s<=0)
        ch=1;
    }
  }
  if(ch)
    return(ch);
  for(int j=0;j<c;++j)
  {
    for(int i=0;i<r;++i)
    {
      p[i+1][j+1]=p[i][j+1];
      if(arr[i][j]<m)
        p[i+1][j+1]+=-1;
      else if(arr[i][j]>m)
        p[i+1][j+1]+=1;
    }
  }
  for(int i=h-1;i<r;++i)
  {
    for(int j=c-w-1;j>=0;--j)
    {
      pr[i]=pr[i]-(p[i+1][j+w+1]-p[i-h+1][j+w+1])+p[i+1][j+1]-p[i+1-h][j+1];
      if(pr[i]<=0)
        return ch=1;
    }
  }
  return(ch);
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) 
{

      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
  r=R;
  c=C;
  h=H;
  w=W;
  for(int i=0;i<r;++i)
    for(int j=0;j<c;++j)
      arr[i][j]=Q[i][j];
  int le=1,ri=r*c,ans=r*c;
  while(le<=ri)
  {
    int mi=(le+ri)/2;
    if(check(mi))
    {
      exit(1);
      ri=mi-1;
      ans=mi;
    }
    else
    {
      le=mi+1;
    }
  }
  return(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -