제출 #836342

#제출 시각아이디문제언어결과실행 시간메모리
836342AntekbRectangles (IOI19_rect)C++17
0 / 100
7 ms616 KiB
#include<bits/stdc++.h> #include "rect.h" #define st first #define nd second #define pb push_back #define eb emplace_back #define pp pop_back #define mp make_pair #define all(x) (x).begin(), (x).end() using namespace std; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<pii>; using ll = long long; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); void debug(){cerr<<"\n";} template<typename H, typename... T> void debug(H h, T... t){ cerr<<h; if(sizeof...(t))cerr<<", "; debug(t...); } #define deb(x...) cerr<<#x<<" = ";debug(x); const int N=1e5+5; ll count_rectangles(std::vector<std::vector<int> > tab) { int n=tab.size(), m=tab[0].size(); vector<vector<vi>> par(n, vector<vi>(m)); for(int i=1; i<m-1; i++){ vi V={0}; for(int j=1; j<n; j++){ while(V.size() && tab[j][i]>tab[V.back()][i]){ if(V.back()!=j-1)par[j][i].pb(V.back()); V.pp(); } if(V.size() && V.back()!=j-1)par[j][i].pb(V.back()); V.pb(j); } } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ //deb(i, j); for(int k:par[i][j]){ //deb(k); } } } vector<pii> prv; vi dp2; ll ans=0; for(int r=1; r<n-1; r++){ vector<pii> akt; vi dp; vi V={m-1}; for(int j=m-2; j>=0; j--){ while(V.size() && tab[r][j]>tab[r][V.back()]){ if(V.back()!=j+1){ akt.eb(j, V.back()); } V.pp(); } if(V.size() && V.back()!=j+1){ akt.eb(j, V.back()); } V.pb(j); } dp.resize(akt.size(), 1); int wsk=0; for(int i=0; i<akt.size(); i++){ while(wsk<prv.size() && (akt[i].st<prv[wsk].st || (akt[i].st==prv[wsk].st && akt[i].nd>prv[wsk].nd)))wsk++; if(wsk<prv.size() && akt[i]==prv[wsk])dp[i]+=dp2[wsk]; } vi wsk2(m); for(int i=0; i<akt.size(); i++){ //deb(r, i, akt[i].st, akt[i].nd, dp[i]); for(int l=akt[i].st+1; l<akt[i].nd; l++){ wsk2[l]=0; } for(int k=r-1; k>=r-dp[i]; k--){ bool b=1; for(int l=akt[i].st+1; l<akt[i].nd; l++){ while(wsk2[l]<par[r+1][l].size() && par[r+1][l][wsk2[l]]>k){ wsk2[l]++; } if(wsk2[l]==par[r+1][l].size() || par[r+1][l][wsk2[l]]!=k){ //deb(k, l, wsk2[l], par[r+1][l].size()); b=0; break; } } if(b){ //deb(r, akt[i].st, akt[i].nd, k); ans++; } } } prv=akt; dp2=dp; } return ans; }

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

rect.cpp: In function 'll count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:46:12: warning: unused variable 'k' [-Wunused-variable]
   46 |    for(int k:par[i][j]){
      |            ^
rect.cpp:72:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for(int i=0; i<akt.size(); i++){
      |                ~^~~~~~~~~~~
rect.cpp:73:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |    while(wsk<prv.size() && (akt[i].st<prv[wsk].st
      |          ~~~^~~~~~~~~~~
rect.cpp:75:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |    if(wsk<prv.size() && akt[i]==prv[wsk])dp[i]+=dp2[wsk];
      |       ~~~^~~~~~~~~~~
rect.cpp:78:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for(int i=0; i<akt.size(); i++){
      |                ~^~~~~~~~~~~
rect.cpp:86:19: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |      while(wsk2[l]<par[r+1][l].size() && par[r+1][l][wsk2[l]]>k){
rect.cpp:89:16: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |      if(wsk2[l]==par[r+1][l].size() || par[r+1][l][wsk2[l]]!=k){
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...