제출 #396529

#제출 시각아이디문제언어결과실행 시간메모리
396529blueRectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include "rect.h"
#include <vector>
using namespace std;


/*
For each (i, j)
T[i][j] = furthest row I such that T[I][j], T[I+1][j], ... T[i-1][j] all have height less than (i, j)
Similarly, D[i][j], R[i][j], L[i][j]

A rectangle (r1, r2, c1, c2) is good if(minD[r1-1][c1..c2] > r2) and so on
*/

long long count_rectangles(vector< vector<int> > a)
{
    int n = a.size(), m = a[0].size();
    long long res = 0;

    for(int r1 = 1; r1 <= n-2; r1++)
    {
        for(int r2 = r1; r2 <= n-2; r2++)
        {
            for(int c1 = 1; c1 <= m-2; c1++)
            {
                if(a[i][c1] >= a[r1-1][c1] || a[i][c1] >= a[r2+1][c1])
                    break;
                    
                for(int c2 = c1; c2 <= m-2; c2++)
                {
                    if(a[i][c2] >= a[r1-1][c2] || a[i][c2] >= a[r2+1][c2])
                        break;
                        
                    bool flag = 1;
                    for(int i = r1; i <= r2; i++)
                        for(int j = c1; j <= c2; j++)
                            flag &= (a[i][j] < a[i][c1-1]) && (a[i][j] < a[i][c2+1]);
                    if(flag) res++;
                }
            }
        }
    }

    return res;
}

컴파일 시 표준 에러 (stderr) 메시지

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:25:22: error: 'i' was not declared in this scope
   25 |                 if(a[i][c1] >= a[r1-1][c1] || a[i][c1] >= a[r2+1][c1])
      |                      ^
rect.cpp:30:26: error: 'i' was not declared in this scope
   30 |                     if(a[i][c2] >= a[r1-1][c2] || a[i][c2] >= a[r2+1][c2])
      |                          ^