# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93867 | igzi | Ruka (COI15_ruka) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define maxN 100100
#define maxC 510
using namespace std;
long long n,m,i,s,p,q,t,tmp;
int f[2*maxN*maxC],x[maxN],y[maxN],z[maxN;
vector <long long> ans(maxN,0);
stack <long long> h;
struct query{
char c;
long long x,y;
};
query k[maxN];
void update(long long p,long long v){
//cout<<p<<" "<<v<<endl;
p+=maxN*maxC;
while(p<2*maxN*maxC){
f[p]+=v;
p+=p & (-p);
}
}
long long query(long long p){
p+=maxN*maxC;
long long ans=0;
while(p>0){
ans+=f[p];
p-=p & -p;
}
return ans;
}
void resi(){
long long i;
for(i=0;i<2*maxN*maxC;i++) f[i]=0;
s=1;
for(i=0;i<n;i++){
update(s+min(y[i],(long long)0),1);
update(s+max(y[i],(long long)(long long)0),-1);
s+=y[i];
}
tmp=s;
s--;
t=q=p=0;
for(i=0;i<m;i++){
if(k[i].c=='Q'){
ans[q]+=query(-t);
q++;
}
if(k[i].c=='F'){
if(p==n-1) continue;
update(tmp-s+min((long long)0,y[p]),-1);
update(tmp-s+max((long long)0,y[p]),1);
s-=y[p];
p++;
}
if(k[i].c=='B'){
if(p==0) continue;
s+=y[p-1];
update(tmp-s+min((long long)(long long)0,y[p-1]),1);
update(tmp-s+max((long long)0,y[p-1]),-1);
p--;
}
if(k[i].c=='C'){
update(tmp-s+min((long long)0,y[p]),-1);
update(tmp-s+max((long long)0,y[p]),1);
t+=k[i].y-y[p];
s+=k[i].y-y[p];
y[p]=k[i].y;
update(tmp-s+min((long long)0,y[p]),1);
update(tmp-s+max((long long)0,y[p]),-1);
}
}
while(h.size()) h.pop();
s=1;
t=p=q=0;
for(i=0;i<m;i++){
if(k[i].c=='Q'){
ans[q]+=t;
q++;
}
if(k[i].c=='F'){
if(p==n-1) continue;
h.push(s);
s+=z[p];
if(h.top()*s<0) t++;
p++;
}
if(k[i].c=='B'){
if(p==0) continue;
if(h.size() && h.top()*s<0) t--;
h.pop();
s-=z[p-1];
p--;
}
if(k[i].c=='C'){
z[p]=k[i].y;
}
}
}
int main(){
std::ios_base::sync_with_stdio(false);
cin>>n;
for(i=0;i<n;i++) {cin>>x[i]>>y[i]; z[i]=y[i];}
cin>>m;
for(i=0;i<m;i++){
char c;
int a,b;
a=b=0;
cin>>c;
k[i].c=c;
if(k[i].c=='C') cin>>a>>b;
k[i].x=a;
k[i].y=b;
}
resi();
for(i=0;i<n;i++) {swap(x[i],y[i]); z[i]=y[i];}
for(i=0;i<m;i++){
if(k[i].c=='C') swap(k[i].x,k[i].y);
}
resi();
for(i=0;i<q;i++) cout<<ans[i]<<endl;
}
Compilation message (stderr)
ruka.cpp:8:42: error: expected ']' before ';' token int f[2*maxN*maxC],x[maxN],y[maxN],z[maxN; ^ ruka.cpp: In function 'void resi()': ruka.cpp:43:31: error: no matching function for call to 'min(int&, long long int)' update(s+min(y[i],(long long)0),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: ruka.cpp:43:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') update(s+min(y[i],(long long)0),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:243:5: note: template argument deduction/substitution failed: ruka.cpp:43:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') update(s+min(y[i],(long long)0),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>) min(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: ruka.cpp:43:31: note: mismatched types 'std::initializer_list<_Tp>' and 'int' update(s+min(y[i],(long long)0),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare) min(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: ruka.cpp:43:31: note: mismatched types 'std::initializer_list<_Tp>' and 'int' update(s+min(y[i],(long long)0),1); ^ ruka.cpp:44:42: error: no matching function for call to 'max(int&, long long int)' update(s+max(y[i],(long long)(long long)0),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: ruka.cpp:44:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') update(s+max(y[i],(long long)(long long)0),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: ruka.cpp:44:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') update(s+max(y[i],(long long)(long long)0),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: ruka.cpp:44:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' update(s+max(y[i],(long long)(long long)0),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: ruka.cpp:44:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' update(s+max(y[i],(long long)(long long)0),-1); ^ ruka.cpp:57:39: error: no matching function for call to 'min(long long int, int&)' update(tmp-s+min((long long)0,y[p]),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: ruka.cpp:57:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+min((long long)0,y[p]),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:243:5: note: template argument deduction/substitution failed: ruka.cpp:57:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+min((long long)0,y[p]),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>) min(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: ruka.cpp:57:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+min((long long)0,y[p]),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare) min(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: ruka.cpp:57:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+min((long long)0,y[p]),-1); ^ ruka.cpp:58:39: error: no matching function for call to 'max(long long int, int&)' update(tmp-s+max((long long)0,y[p]),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: ruka.cpp:58:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+max((long long)0,y[p]),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: ruka.cpp:58:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+max((long long)0,y[p]),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: ruka.cpp:58:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+max((long long)0,y[p]),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: ruka.cpp:58:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+max((long long)0,y[p]),1); ^ ruka.cpp:65:52: error: no matching function for call to 'min(long long int, int&)' update(tmp-s+min((long long)(long long)0,y[p-1]),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: ruka.cpp:65:52: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+min((long long)(long long)0,y[p-1]),1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:243:5: note: template argument deduction/substitution failed: ruka.cpp:65:52: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+min((long long)(long long)0,y[p-1]),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>) min(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: ruka.cpp:65:52: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+min((long long)(long long)0,y[p-1]),1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare) min(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: ruka.cpp:65:52: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+min((long long)(long long)0,y[p-1]),1); ^ ruka.cpp:66:41: error: no matching function for call to 'max(long long int, int&)' update(tmp-s+max((long long)0,y[p-1]),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: ruka.cpp:66:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+max((long long)0,y[p-1]),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: ruka.cpp:66:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') update(tmp-s+max((long long)0,y[p-1]),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: ruka.cpp:66:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+max((long long)0,y[p-1]),-1); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: ruka.cpp:66:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' update(tmp-s+max((long long)0,y[p-1]),-1); ^ ruka.cpp:70:39: error: no matching function for call to 'min(long long int, int&)' update(tmp-s+min((long long)0,y[p]),-1); ^ In file included from /usr/include/c++/7/bits/specfun.h:45:0, from /usr/include/c++/7/cmath:1914, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from ruka.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&) min(const _