제출 #891811

#제출 시각아이디문제언어결과실행 시간메모리
891811Trisanu_DasRectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
 
int n, m;
int bit[2505];
int a[2][2505][2505], lst[2][2505][2505], cnt[2][2505][2505];
vector<pair<int, int> > p[2]; 
vector<int> s[2][2505];
 
void upd(int idx, int val){
  for(idx++; idx < 2505; idx += (idx & -idx)) bit[idx] += val;
}
 
int qry(int idx){
  int ans = 0;
  for(idx++; idx; idx -= (idx & -idx)) ans += bit[idx];
  return ans;
}
 
long long count_rectangles(vector<vector<int>> A) {
	n = A.size(), m = A[0].size();
	for(int i = 0; i < n; i++) s[0][i].push_back(0);
	for(int i = 0; i < m; i++) s[1][i].push_back(0);
	long long ans = 0;
	for(int i = 0; i < n - 1; i++){
      for(int j = 0; j < m - 1; j++){
          a[0][i][j] = a[1][j][i] = A[i][j];
          a[0][i][j + 1] = A[i][j + 1];
          a[1][j][i + 1] = A[i + 1][j];
          for(int t = 0; t < 2; t++){
              bool eq = 0;
              p[t].clear();
              while(!s[t][i].empty()){
                  int c = s[t][i].back();
                  if(c < j && !eq){
                      if(lst[t][c][j + 1] != i - 1) cnt[t][c][j + 1] = 0;
                      cnt[t][c][j + 1]++, lst[t][c][j + 1] = i;
                      p[t].push_back({j - c, cnt[t][c][j + 1]});
                      if(t) swap(p[t].back().first, p[t].back().second);
                  }
                  eq = a[t][i][c] == a[t][i][j + 1];
                  if(a[t][i][c] <= a[t][i][j + 1]) s[t][i].pop_back();
                  else break;
              }
              s[t][i].push_back(j + 1);
              swap(i, j);
              sort(p[t].begin(), p[t].end(), greater<pair<int, int> >());
          }
          int it = 0;
          for(pair<int, int> v : p[0]){
              for(; it < p[1].size() && v.f <= p[1][it].first; it++) upd(p[1][it].second, 1);
              ans += qry(v.second);
          }
          for(int jt = 0; jt < it; jt++) upd(p[1][jt].second, -1);
      }
    }
	return ans;
}

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

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:52:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |               for(; it < p[1].size() && v.f <= p[1][it].first; it++) upd(p[1][it].second, 1);
      |                     ~~~^~~~~~~~~~~~~
rect.cpp:52:43: error: 'struct std::pair<int, int>' has no member named 'f'
   52 |               for(; it < p[1].size() && v.f <= p[1][it].first; it++) upd(p[1][it].second, 1);
      |                                           ^