Submission #1100799

#TimeUsernameProblemLanguageResultExecution timeMemory
1100799AlexandreQuality Of Living (IOI10_quality)C++14
Compilation error
0 ms0 KiB
#include "quality.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 3100;
int m[MAXN][MAXN], SP[MAXN][MAXN], h[MAXN][MAXN], has[MAXN][MAXN], SPH[MAXN][MAXN];

bool teste(int v){
    
    for(int i = 1; i <= R; i++){
        for(int j = 1; j <= C; j++){
            
            SP[i][j] = 0;
            h[i][j] = 0;
            has[i][j] = 0;
            SPH[i][j] = 0;
            
        }
    }
    
    for(int i = 1; i <= R; i++){
       
        for(int j = 1; j <= C; j++){
           
            if(m[i][j]<v){
               
                h[i][j] = 1;
               
            }else{
               
                h[i][j] = 0;
               
            }
            
            if(m[i][j]==v) has[i][j] = 1;
           
            if(i==1 && j==1){
                SP[i][j] = h[i][j];
                continue;
            }
            if(i==1){
                SP[i][j] = SP[i][j-1] + h[i][j];
                continue;
            }
            if(j==1){
                SP[i][j] = SP[i-1][j] + h[i][j];
                continue;
            }
            SP[i][j] = SP[i-1][j] + SP[i][j-1] - SP[i-1][j-1] + h[i][j];
           
        }
       
    }
    
    for(int i = 1; i <= R; i++){
        
        for(int j = 1; j <= C; j++){
           
            if(i==1 && j==1){
                SPH[i][j] = has[i][j];
                continue;
            }
            if(i==1){
                SPH[i][j] = SPH[i][j-1] + has[i][j];
                continue;
            }
            if(j==1){
                SPH[i][j] = SPH[i-1][j] + has[i][j];
                continue;
            }
            SPH[i][j] = SPH[i-1][j] + SPH[i][j-1] - SPH[i-1][j-1] + has[i][j];
            
        }
    }
   
    for(int i = H; i <= R; i++){
       
        for(int j = W; j <= C; j++){
           
           int total = SP[i][j] - SP[i][j-W] - SP[i-H][j] + SP[i-H][j-W];
           int contem = SPH[i][j] - SPH[i][j-W] - SPH[i-H][j] + SPH[i-H][j-W];
           if((total == (H*W-1)/2) && contem!=0) return true;
           
        }
       
    }
   
    return false;
}

int bb(){
   
    int ini = 1;
    int fim = R*C;
   
    while(ini<fim){
       
        int m = (ini+fim)/2;
        if(teste(m)){
           
            fim = m;
           
        }else{
           
            ini = m + 1;
           
        }
       
    }
   
    return fim;
   
}

int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
	
	for(int i = 1; i <= R; i++){
		
		for(int j = 1; j <= C; j++){
			
			m[i][j] = Q[i][j];
			
		}
		
	}
	
	return bb();
}

Compilation message (stderr)

quality.cpp: In function 'bool teste(int)':
quality.cpp:10:25: error: 'R' was not declared in this scope
   10 |     for(int i = 1; i <= R; i++){
      |                         ^
quality.cpp:11:29: error: 'C' was not declared in this scope
   11 |         for(int j = 1; j <= C; j++){
      |                             ^
quality.cpp:21:25: error: 'R' was not declared in this scope
   21 |     for(int i = 1; i <= R; i++){
      |                         ^
quality.cpp:23:29: error: 'C' was not declared in this scope
   23 |         for(int j = 1; j <= C; j++){
      |                             ^
quality.cpp:55:25: error: 'R' was not declared in this scope
   55 |     for(int i = 1; i <= R; i++){
      |                         ^
quality.cpp:57:29: error: 'C' was not declared in this scope
   57 |         for(int j = 1; j <= C; j++){
      |                             ^
quality.cpp:76:17: error: 'H' was not declared in this scope
   76 |     for(int i = H; i <= R; i++){
      |                 ^
quality.cpp:76:25: error: 'R' was not declared in this scope
   76 |     for(int i = H; i <= R; i++){
      |                         ^
quality.cpp:78:21: error: 'W' was not declared in this scope
   78 |         for(int j = W; j <= C; j++){
      |                     ^
quality.cpp:78:29: error: 'C' was not declared in this scope
   78 |         for(int j = W; j <= C; j++){
      |                             ^
quality.cpp: In function 'int bb()':
quality.cpp:94:15: error: 'R' was not declared in this scope
   94 |     int fim = R*C;
      |               ^
quality.cpp:94:17: error: 'C' was not declared in this scope
   94 |     int fim = R*C;
      |                 ^