Submission #729483

#TimeUsernameProblemLanguageResultExecution timeMemory
729483MilosMilutinovicRectangles (IOI19_rect)C++14
Compilation error
0 ms0 KiB
// todo
#include "rect.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

PII goL[2505][2505], goR[2505][2505], goU[2505][2505], goD[2505][2505];
vector<PII> ver[2505], hor[2505];

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

    rep(i, n) {
        vector<int> stk;
        rep(j, m) {
            while(!stk.empty() && a[i][j] > a[i][stk.back()]) stk.pop_back();
            goL[i][j] = MP(i, stk.empty() ? -1 : stk.back());
            stk.push_back(j);
        }
    }
    rep(i, n) {
        vector<int> stk;
        for(int j = m - 1; j >= 0; j--) {
            while(!stk.empty() && a[i][j] > a[i][stk.back()]) stk.pop_back();
            goR[i][j] = MP(i, stk.empty() ? -1 : stk.back());
            stk.push_back(j);
        }
    }
    rep(j, m) {
        vector<int> stk;
        rep(i, n) {
            while(!stk.empty() && a[i][j] > a[stk.back()][j]) stk.pop_back();
            goU[i][j] = MP(stk.empty() ? -1 : stk.back(), j);
            stk.push_back(i);
        }
    }
    rep(j, m) {
        vector<int> stk;
        for(int i = n - 1; i >= 0; i--) {
            while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
            goD[i][j] = MP(stk.back() ? -1 : stk.back(), j);
            stk.push_back(i);
        }
    }

    rep(i, n) rep(j, m) {
        if(goL[i][j].second != -1) ver[i].push_back(MP(goL[i][j].second, j));
        if(goR[i][j].second != -1) ver[i].push_back(MP(j, goR[i][j].second));
    }
}

Compilation message (stderr)

rect.cpp: In function 'LL count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:46:40: error: expected primary-expression before ';' token
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                                        ^
rect.cpp:46:40: error: expected ']' before ';' token
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                                        ^
      |                                        ]
rect.cpp:46:40: error: expected ')' before ';' token
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                  ~                     ^
      |                                        )
rect.cpp:46:13: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |             ^~~~~
rect.cpp:46:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                                         ^
rect.cpp:46:42: error: expected ';' before ']' token
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                                          ^
      |                                          ;
rect.cpp:46:41: warning: statement has no effect [-Wunused-value]
   46 |             while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
      |                                         ^
rect.cpp:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
   56 | }
      | ^