# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85832 | kraljlavova1 | Automobil (COCI17_automobil) | C++11 | 57 ms | 35556 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>
using namespace std;
typedef long long int llint;
const int MAX=1000010,MOD=1e9+7;
int k,x,y;
int bio_r[MAX],bio_s[MAX];
char c;
llint n,m,sol,sums;
llint mr[MAX],ms[MAX];
llint sum_r[MAX],sum_s[MAX];
vector<pair<llint,llint> >vr,vs,vn;
int main(){
for(int i=0;i<MAX;i++) mr[i]=1;
for(int i=0;i<MAX;i++) ms[i]=1;
cin>>n>>m>>k;
sum_r[0]=(m*(m+1)/2)%MOD;
for(int i=1;i<n;i++){
llint mk=(m*m)%MOD;
sum_r[i]=(sum_r[i-1]+mk)%MOD;
}
sum_s[0]=((n*(n-1)/2)*m+n)%MOD;
for(int i=1;i<m;i++){
sum_s[i]=(sum_s[i-1]+n)%MOD;
}
for(int i=0;i<k;i++){
cin>>c>>x>>y;
--x;
if(c=='R'){
bio_r[x]=1;
mr[x]=(mr[x]*y)%MOD;
}
else{
bio_s[x]=1;
ms[x]=(ms[x]*y)%MOD;
}
}
for(int i=0;i<MAX;i++){
if(bio_r[i]){
vr.push_back({i,mr[i]});
}
if(bio_s[i]){
vs.push_back({i,ms[i]});
}
}
for(int i=0;i<vs.size();i++){
vn.push_back({vs[i].second-1,vs[i].first+1});
}
llint sum=0,dif=0;
for(int i=0;i<vn.size();i++){
sum=(sum+(vn[i].second*vn[i].first))%MOD;
dif=(dif+m*vn[i].first)%MOD;
}
sum_r[0]=(sum_r[0]+sum)%MOD;
sol=(sol+sum_r[0]*mr[0])%MOD;
for(int i=1;i<n;i++){
sum=(sum+dif)%MOD;
sum_r[i]=(sum_r[i]+sum)%MOD;
sol=(sol+sum_r[i]*mr[i])%MOD;
}
cout<<sol;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |