Submission #85832

#TimeUsernameProblemLanguageResultExecution timeMemory
85832kraljlavova1Automobil (COCI17_automobil)C++11
100 / 100
57 ms35556 KiB
#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)

automobil.cpp: In function 'int main()':
automobil.cpp:45:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vs.size();i++){
              ~^~~~~~~~~~
automobil.cpp:49:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vn.size();i++){
              ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...