Submission #208883

# Submission time Handle Problem Language Result Execution time Memory
208883 2020-03-12T11:57:18 Z DodgeBallMan Quality Of Living (IOI10_quality) C++14
Compilation error
0 ms 0 KB
#include "quality.h"
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 3e3+5;

int sum[N][N], n, c, r, h, w;
pii pos[N*N];


bool chk( int mid, int rec[][] ) {
    memset( sum, 0, sizeof sum );
    for( int i = mid + 1 ; i <= n ; i++ ) sum[pos[i].x][pos[i].y]++;
    for( int i = 1 ; i <= r ; i++ )
        for( int j = 1 ; j <= c ; j++ )
            sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    for( int i = h ; i <= r ; i++ ) 
        for( int j = w ; j <= c ; j++ ) 
            if( sum[i][j] - sum[i-h][j] - sum[i][j-w] + sum[i-h][j-w] <= h * w / 2 ) return true;
        
    return false;
}

int rectangle( int R, int C, int H, int W, int rec[][] ) {
    r = R, c = C, w = W, h = H;
    n = r*c;
	for( int i = 0 ; i < r ; i++ ) for( int j = 0 ; j < c ; j++ ) pos[rec[i][j]] = pii( i+1, j+1 );
    int l = 1, r = n;
    while( l < r ) {
        int mid = l + r + 1 >> 1;
        if( chk( mid, rec ) ) l = m;
        else r = m - 1;
    }
	return l;
}

Compilation message

quality.cpp:16:30: error: declaration of 'rec' as multidimensional array must have bounds for all dimensions except the first
 bool chk( int mid, int rec[][] ) {
                              ^
quality.cpp: In function 'bool chk(...)':
quality.cpp:18:18: error: 'mid' was not declared in this scope
     for( int i = mid + 1 ; i <= n ; i++ ) sum[pos[i].x][pos[i].y]++;
                  ^~~
quality.cpp: At global scope:
quality.cpp:29:54: error: declaration of 'rec' as multidimensional array must have bounds for all dimensions except the first
 int rectangle( int R, int C, int H, int W, int rec[][] ) {
                                                      ^
quality.cpp: In function 'int rectangle(...)':
quality.cpp:30:9: error: 'R' was not declared in this scope
     r = R, c = C, w = W, h = H;
         ^
quality.cpp:30:16: error: 'C' was not declared in this scope
     r = R, c = C, w = W, h = H;
                ^
quality.cpp:30:23: error: 'W' was not declared in this scope
     r = R, c = C, w = W, h = H;
                       ^
quality.cpp:30:30: error: 'H' was not declared in this scope
     r = R, c = C, w = W, h = H;
                              ^
quality.cpp:32:68: error: 'rec' was not declared in this scope
  for( int i = 0 ; i < r ; i++ ) for( int j = 0 ; j < c ; j++ ) pos[rec[i][j]] = pii( i+1, j+1 );
                                                                    ^~~
quality.cpp:32:68: note: suggested alternative: 'getc'
  for( int i = 0 ; i < r ; i++ ) for( int j = 0 ; j < c ; j++ ) pos[rec[i][j]] = pii( i+1, j+1 );
                                                                    ^~~
                                                                    getc
quality.cpp:35:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = l + r + 1 >> 1;
                   ~~~~~~^~~
quality.cpp:36:23: error: 'rec' was not declared in this scope
         if( chk( mid, rec ) ) l = m;
                       ^~~
quality.cpp:36:23: note: suggested alternative: 'getc'
         if( chk( mid, rec ) ) l = m;
                       ^~~
                       getc
quality.cpp:36:35: error: 'm' was not declared in this scope
         if( chk( mid, rec ) ) l = m;
                                   ^
quality.cpp:37:18: error: 'm' was not declared in this scope
         else r = m - 1;
                  ^