Submission #743564

#TimeUsernameProblemLanguageResultExecution timeMemory
743564bgnbvnbvAutomobil (COCI17_automobil)C++14
60 / 100
4 ms3668 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<ll,ll> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e5; const ll inf=1e18; const ll mod=1e9+7; ll get(ll l,ll r,ll s) { // return (r+l)*((r-l)/s+1)/2; ll sum=(r+l); ll cnt=(r-l)/s+1; if(sum%2==0) { sum/=2; sum%=mod; cnt%=mod; return sum*cnt%mod; } else { cnt/=2; sum%=mod; cnt%=mod; return sum*cnt%mod; } } ll n,m,k; ll mulr[maxN],mulc[maxN]; vector<pli>vecr,vecc; void solve() { cin >> n >> m >> k; for(int i=1;i<=n;i++) mulr[i]=1; for(int i=1;i<=m;i++) mulc[i]=1; for(int i=1;i<=k;i++) { char t; cin >> t; if(t=='R') { ll x,y; cin >> x >> y; mulr[x]*=y; mulr[x]%=mod; } else { ll x,y; cin >> x >> y; mulc[x]*=y; mulc[x]%=mod; } } for(int i=1;i<=n;i++) { if(mulr[i]!=1) { vecr.pb({i,mulr[i]}); } } for(int i=1;i<=m;i++) { if(mulc[i]!=1) { vecc.pb({i,mulc[i]}); } } ll sum=0; for(int i=1;i<=n;i++) { sum+=get((i-1)*m+1,i*m,1); if(sum>=mod) sum-=mod; } for(int i=0;i<vecr.size();i++) { ll r=vecr[i].fi; ll cc=get((r-1)*m+1,r*m,1); for(int j=0;j<vecc.size();j++) { ll c=vecc[j].fi; cc-=((r-1)*m+c)%mod; if(cc<0) cc+=mod; } cc=cc*(vecr[i].se-1)%mod; sum+=cc; if(sum>=mod) sum-=mod; } for(int i=0;i<vecc.size();i++) { ll c=vecc[i].fi; ll cc=get(c,c+(n-1)*m,m); for(int j=0;j<vecr.size();j++) { ll r=vecr[j].fi; cc-=((r-1)*m+c)%mod; if(cc<0) cc+=mod; } cc=cc*(vecc[i].se-1)%mod; sum+=cc; if(sum>=mod) sum-=mod; } for(int i=0;i<vecr.size();i++) { for(int j=0;j<vecc.size();j++) { ll r=vecr[i].fi; ll c=vecc[j].fi; ll mul=vecr[i].se*vecc[j].se%mod; sum+=(((r-1)*m+c)%mod)*(mul-1)%mod; sum%=mod; if(sum<0) sum+=mod; } } cout << sum; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }

Compilation message (stderr)

automobil.cpp: In function 'void solve()':
automobil.cpp:80:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i=0;i<vecr.size();i++)
      |                 ~^~~~~~~~~~~~
automobil.cpp:84:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for(int j=0;j<vecc.size();j++)
      |                     ~^~~~~~~~~~~~
automobil.cpp:94:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |     for(int i=0;i<vecc.size();i++)
      |                 ~^~~~~~~~~~~~
automobil.cpp:98:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |         for(int j=0;j<vecr.size();j++)
      |                     ~^~~~~~~~~~~~
automobil.cpp:108:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |     for(int i=0;i<vecr.size();i++)
      |                 ~^~~~~~~~~~~~
automobil.cpp:110:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |         for(int j=0;j<vecc.size();j++)
      |                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...