Submission #1080374

#TimeUsernameProblemLanguageResultExecution timeMemory
1080374speedcodeRectangles (IOI19_rect)C++17
Compilation error
0 ms0 KiB

#include <bits/stdc++.h>
using namespace std;

long long count_rectangles(std::vector<std::vector<int>> a)
{
    if(n < 3 || m < 3) return 0;

    int n = a.size();
    int m = a[0].size();
    int valid[m];
    for(int i = 0; i < m; i++) 
        valid[i] = a[0][i] > a[1][i] && a[2][i] > a[1][i];
    long long res = 0;
    for(int start = 1; start < m-1; start++){
        int ma = a[1][start];
        int end = start;
        while(end < m-1){
            if(a[1][start-1] <= ma) break;
            if(a[1][end+1] <= ma) {
                end++;
                ma = max(ma, a[1][end]);
                continue;
            }
            if(!valid[end]) break;
            cout << start << ' ' << end << endl;
            res++;
            end++;
            ma = max(ma, a[1][end]);
        }
    }

    return res;
}

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:7:8: error: 'n' was not declared in this scope
    7 |     if(n < 3 || m < 3) return 0;
      |        ^
rect.cpp:7:17: error: 'm' was not declared in this scope
    7 |     if(n < 3 || m < 3) return 0;
      |                 ^
rect.cpp:9:9: warning: unused variable 'n' [-Wunused-variable]
    9 |     int n = a.size();
      |         ^