Submission #256032

#TimeUsernameProblemLanguageResultExecution timeMemory
256032b00n0rpRectangles (IOI19_rect)C++17
Compilation error
0 ms0 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define pb push_back #define REP(i,n) for(int i = 0; i < n; i++) #define FOR(i,a,b) for(int i = a; i < b; i++) ll count_rectangles(vector<vi> a) { int n,m, n = a.size(); m = a[0].size(); MX = 705; bitset<MX> hor[MX][MX],ver[MX][MX]; bitset<MX> gg[MX]; REP(i,n){ REP(j,m){ int mx = -1; FOR(k,j,m){ mx = max(mx,a[i][k]); hor[j][k][i] = (j and k < m-1 and mx < min(a[i][j-1],a[i][k+1])); } } } REP(j,m){ REP(i,n){ int mx = -1; FOR(k,i,n){ mx = max(mx,a[k][j]); ver[i][k][j] = (i and k < n-1 and mx < min(a[i-1][j],a[k+1][j])); } } } ll ans = 0; REP(i1,n){ REP(j1,m){ FOR(i2,i1,n){ gg[i2].reset(); } FOR(i2,i1,n){ FOR(j2,j1,m){ if(!ver[i1][i2][j2]) break; gg[i2][j2] = 1; } } FOR(j2,j1,m){ FOR(i2,i1,n){ if(!hor[j1][j2][i2]) break; ans += gg[i2][j2]; } } } } return ans; }

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:13:2: error: redeclaration of 'int n'
  n = a.size();
  ^
rect.cpp:12:6: note: 'int n' previously declared here
  int n,m,
      ^
rect.cpp:15:2: error: 'MX' was not declared in this scope
  MX = 705;
  ^~
rect.cpp:16:11: error: could not convert template argument 'MX' from '<type error>' to 'long unsigned int'
  bitset<MX> hor[MX][MX],ver[MX][MX];
           ^
rect.cpp:17:11: error: could not convert template argument 'MX' from '<type error>' to 'long unsigned int'
  bitset<MX> gg[MX];
           ^
rect.cpp:23:5: error: 'hor' was not declared in this scope
     hor[j][k][i] = (j and k < m-1 and mx < min(a[i][j-1],a[i][k+1]));
     ^~~
rect.cpp:32:5: error: 'ver' was not declared in this scope
     ver[i][k][j] = (i and k < n-1 and mx < min(a[i-1][j],a[k+1][j]));
     ^~~
rect.cpp:40:5: error: 'gg' was not declared in this scope
     gg[i2].reset();
     ^~
rect.cpp:44:10: error: 'ver' was not declared in this scope
      if(!ver[i1][i2][j2]) break;
          ^~~
rect.cpp:45:6: error: 'gg' was not declared in this scope
      gg[i2][j2] = 1;
      ^~
rect.cpp:50:10: error: 'hor' was not declared in this scope
      if(!hor[j1][j2][i2]) break;
          ^~~
rect.cpp:51:13: error: 'gg' was not declared in this scope
      ans += gg[i2][j2];
             ^~