Submission #120555

#TimeUsernameProblemLanguageResultExecution timeMemory
120555_SamirAutomobil (COCI17_automobil)C++14
0 / 100
28 ms8320 KiB
/* we will use dp , our state will be left most house i visited , the right most house i visited and the time till now , each time will try to visit new house from the left or the right */ #include<queue> #include<map> #include <string> #include<bits/stdc++.h> #define pi 3.141592654 #define forr(i,a,b) for(int i=a;i<=b;i++) #define F first #define S second #define input ios_base::sync_with_stdio(0);cin.tie(0); //#define x real() //#define y imag() using namespace std; typedef pair<double,double>pdd; typedef long long ll; typedef pair<ll, ll>pii; //typedef complex<double> point; //template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); } //typedef bitset<30> mask; //int x[8]={1,0,0,-1,-1,-1,1,1}; //int y[8]={0,1,-1,0,-1,1,-1,1}; //#define var(x) ((x)<<1) //#define nvar(x) ((x)^1) const int N=100000,M=100000; ll n,m,k; map<ll,ll>r,c; ll sum,mod=1e9+7,R[1000004],pls; main() { //cout<<Pow((ll)1000000,(ll)110); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); // char input[15]; // scanf("%s", &input); array of char // gets(c+1); array of char //printf("%s, ",name[k[i]].c_str()); printf of string //priority_queue<ll,vector<ll>,greater<ll>>y; input; cin>>n>>m>>k; for(ll i=1;i<=n;i++) R[i]=(i-1)*m*m+m*(m+1)/2; char t; ll x,y; forr(i,1,k) { cin>>t>>x>>y; if(t=='S') { if(c.count(x)==0)c[x]=1; c[x]*=y; } else { if(r.count(x)==0)r[x]=1; r[x]*=y; } } for(auto b:c) { ll g =b.F*n+n*(n-1)/2*m; for(auto a:r) { ll num=(a.F-1)*m+b.F; R[a.F]-=num; R[a.F]+=num*b.S; g-=num; } pls+=max((ll)0,b.S-1)*g; pls%=mod; } for(auto a:r)R[a.F]=R[a.F]*a.S; forr(i,1,n) { sum+=R[i]; sum%=mod; } cout<<(sum+pls+mod)%mod; return 0; }

Compilation message (stderr)

automobil.cpp:32:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main()
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...