Submission #815254

#TimeUsernameProblemLanguageResultExecution timeMemory
815254lkh3happyComparing Plants (IOI20_plants)C++14
Compilation error
0 ms0 KiB
//#include "plants.h" #include <stdio.h> #include <algorithm> #include <vector> #include <assert.h> using namespace std; int r[222222], lz[888888], rnk[222222], k; pair<int, int> t[888888]; void scl(int l, int r, int n){ t[n]={0, l}; lz[n]=0; if(l==r) return; int m=l+r>>1; scl(l, m, n*2); scl(m+1, r, n*2+1); } void lzup(int l, int r, int n){ t[n].first+=lz[n]; if(l^r) lz[n*2]+=lz[n], lz[n*2+1]+=lz[n]; lz[n]=0; } void upd(int l, int r, int n, int s, int e, int x){ lzup(l, r, n); if(r<s || e<l) return; if(s<=l && r<=e){ lz[n]+=x; lzup(l, r, n); return; } int m=l+r>>1; upd(l, m, n*2, s, e, x); upd(m+1, r, n*2+1, s, e, x); t[n]=min(t[n*2], t[n*2+1]); } pair<int, int> mn(int l, int r, int n, int s, int e){ lzup(l, r, n); if(r<s || e<l) return {1e9, 1e9}; if(s<=l && r<=e) return t[n]; int m=l+r>>1; return min(mn(l, m, n*2, s, e), mn(m+1, r, n*2+1, s, e)); } pair<int, int> fmn(int l, int r, int n, int s, int e){ if(e<1) return mn(l, r, n, r+s, r+e); if(s>r) return mn(l, r, n, s-r, e-r); if(e>r){ pair<int, int> x=mn(l, r, n, s, r); if(!x.first) return x; return min(x, mn(l, r, n, 1, e-r)); } if(s<1){ pair<int, int> x=mn(l, r, n, r+s, r); if(!x.first) return x; return min(mn(l, r, n, 1, e), x); } return mn(l, r, n, s, e); } void fupd(int l, int r, int n, int s, int e, int x){ if(s>0 && e<=r) return upd(l, r, n, s, e, x); if(e<1) return upd(l, r, n, r+s, r+e, x); if(s>r) return upd(l, r, n, s-r, e-r, x); if(e>r) return upd(l, r, n, s, r, x), upd(l, r, n, 1, e-r, x); if(s<1) return upd(l, r, n, 1, e, x), upd(l, r, n, r+s, r, x); } void init(int _k, vector<int> _r){ int n=_r.size(), k=_k; scl(1, n, 1); vector<int> v; for(int i=1;i<=n;i++) r[i]=_r[i-1], upd(1, n, 1, i, i, r[i]); for(int i=1;i<=n;i++) if(!r[i] && fmn(1, n, 1, i-k+1, i-1).first) rnk[i]=1, v.push_back(i); for(int i=0;i<v.size();i++){ fupd(1, n, 1, v[i]-k+1, v[i]-1, -1); fupd(1, n, 1, v[i], v[i], 1e9); pair<int, int> lx=fmn(1, n, 1, v[i]-k+1, v[i]-1), rx=fmn(1, n, 1, v[i]+1, v[i]+k-1); if(!lx.first && fmn(1, n, 1, lx.second-k+1, i-1).first) assert(!rnk[lx.second]), rnk[lx.second]=rnk[v[i]]+1, v.push_back(lx.second); if(!rx.first && fmn(1, n, 1, rx.second-k+1, i-1).first) assert(!rnk[lx.second]), rnk[rx.seconassert(!rnk[lx.second]), d]=rnk[v[i]]+1, v.push_back(rx.second); } return; } int compare_plants(int x, int y){ x++; y++; return (rnk[x]>rnk[y])?-1:1; }

Compilation message (stderr)

plants.cpp: In function 'void scl(int, int, int)':
plants.cpp:15:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   15 |     int m=l+r>>1;
      |           ~^~
plants.cpp: In function 'void upd(int, int, int, int, int, int)':
plants.cpp:33:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     int m=l+r>>1;
      |           ~^~
plants.cpp: In function 'std::pair<int, int> mn(int, int, int, int, int)':
plants.cpp:42:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |     int m=l+r>>1;
      |           ~^~
plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:76:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
plants.cpp:80:97: error: 'struct std::pair<int, int>' has no member named 'seconassert'
   80 |         if(!rx.first && fmn(1, n, 1, rx.second-k+1, i-1).first) assert(!rnk[lx.second]), rnk[rx.seconassert(!rnk[lx.second]), d]=rnk[v[i]]+1, v.push_back(rx.second);
      |                                                                                                 ^~~~~~~~~~~
plants.cpp:80:127: error: 'd' was not declared in this scope
   80 |         if(!rx.first && fmn(1, n, 1, rx.second-k+1, i-1).first) assert(!rnk[lx.second]), rnk[rx.seconassert(!rnk[lx.second]), d]=rnk[v[i]]+1, v.push_back(rx.second);
      |                                                                                                                               ^