제출 #144708

#제출 시각아이디문제언어결과실행 시간메모리
144708nvmdavaRectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; #define ff ff #define ss ss #define N 2505 int n, m; int p[N], lc[N], rc[N]; map<int, int> cnt[2][N][N]; int arr[N][N], bit[N][N]; int temp[N]; void buildtree(int sz){ vector<int> v = {0}; for(int i = 1; i <= sz; i++){ vector<int> t; while(temp[v.back()] < temp[i]){ t.push_back(v.back()); v.pop_back(); } v.push_back(i); for(int j = t.size() - 1; j > 0; j--){ p[t[j - 1]] = t[j]; } if(!t.empty())p[t.back()] = i; } for(int i = v.size() - 1; i > 0; i--) p[v[i]] = v[i - 1]; for(int i = 1; i <= sz; i++){ if(p[i] > i){ lc[p[i]] = i; } else { rc[p[i]] = i; } } } void travtree(int i1, int i2, int v, int l, int r){ if(l != 0 && r != (i1 == 1 ? n + 1 : m + 1) && r - l > 1 && temp[l] != temp[v] && temp[r] != temp[v]){ if(i1 == 0) cnt[i1][i2][r - 1][r - l - 1]++; else cnt[i1][r - 1][i2][r - l - 1]++; } if(lc[v] != 0){ travtree(i1, i2, lc[v], l, v); } if(rc[v] != 0){ travtree(i1, i2, rc[v], v, r); } } void build(){ for(int i = 1; i <= n; i++){ memset(lc, 0, sizeof lc); memset(rc, 0, sizeof rc); for(int j = 0; j <= m; j++) temp[j] = arr[i][j]; buildtree(m); travtree(0, i, 0, 0, m + 1); } for(int j = 1; j <= m; j++){ memset(lc, 0, sizeof lc); memset(rc, 0, sizeof rc); for(int i = 0; i <= n; i++) temp[i] = arr[i][j]; buildtree(n); travtree(1, j, 0, 0, n + 1); } } void update(int x, int y, int v){ for(int i = x; i < N; i += i & -i){ for(int j = y; j < N; j += j & -j){ bit[i][j] += v; } } } int query(int x, int y){ int res = 0; for(int i = x; i > 0; i -= i & -i){ for(int j = y; j > 0; j -= j & -j){ res += bit[i][j]; } } return res; } long long count_rectangles(vector<vector<int> > a){ n = a.size(); m = a[0].size(); memset(arr, 0x3f, sizeof arr); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ arr[i + 1][j + 1] = a[i][j]; } } build(); int res = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ for(auto& x : cnt[0][i][j]){ auto it = cnt[0][i - 1][j].find(x.ff); if(it != cnt[0][i - 1][j].end()) x.ss = 1 + it -> ss; update(x.ff, x.ss, 1); } for(auto& x : cnt[1][i][j]){ auto it = cnt[1][i][j - 1].find(x.ff); if(it != cnt[1][i][j - 1].end()) x.ss = 1 + it -> ss; res += query(x.ss, N - 1); res -= query(x.ss, x.ff - 1); } for(auto& x : cnt[0][i][j]) update(x.ff, x.ss, -1); } } return res; }

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

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:4:12: error: 'struct std::pair<const int, int>' has no member named 'ff'
 #define ff ff
            ^
rect.cpp:114:39: note: in expansion of macro 'ff'
     auto it = cnt[0][i - 1][j].find(x.ff);
                                       ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:116:8: note: in expansion of macro 'ss'
      x.ss = 1 + it -> ss;
        ^~
rect.cpp:4:12: error: 'struct std::pair<const int, int>' has no member named 'ff'
 #define ff ff
            ^
rect.cpp:117:14: note: in expansion of macro 'ff'
     update(x.ff, x.ss, 1);
              ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:117:20: note: in expansion of macro 'ss'
     update(x.ff, x.ss, 1);
                    ^~
rect.cpp:4:12: error: 'struct std::pair<const int, int>' has no member named 'ff'
 #define ff ff
            ^
rect.cpp:120:39: note: in expansion of macro 'ff'
     auto it = cnt[1][i][j - 1].find(x.ff);
                                       ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:122:8: note: in expansion of macro 'ss'
      x.ss = 1 + it -> ss;
        ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:123:20: note: in expansion of macro 'ss'
     res += query(x.ss, N - 1);
                    ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:124:20: note: in expansion of macro 'ss'
     res -= query(x.ss, x.ff - 1);
                    ^~
rect.cpp:4:12: error: 'struct std::pair<const int, int>' has no member named 'ff'
 #define ff ff
            ^
rect.cpp:124:26: note: in expansion of macro 'ff'
     res -= query(x.ss, x.ff - 1);
                          ^~
rect.cpp:4:12: error: 'struct std::pair<const int, int>' has no member named 'ff'
 #define ff ff
            ^
rect.cpp:127:14: note: in expansion of macro 'ff'
     update(x.ff, x.ss, -1);
              ^~
rect.cpp:5:12: error: 'struct std::pair<const int, int>' has no member named 'ss'
 #define ss ss
            ^
rect.cpp:127:20: note: in expansion of macro 'ss'
     update(x.ff, x.ss, -1);
                    ^~