Submission #120554

# Submission time Handle Problem Language Result Execution time Memory
120554 2019-06-24T22:55:33 Z _Samir Automobil (COCI17_automobil) C++17
0 / 100
29 ms 8320 KB
/*
   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+=(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

automobil.cpp:32:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main()
       ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Incorrect 3 ms 384 KB Output isn't correct
8 Incorrect 2 ms 384 KB Output isn't correct
9 Incorrect 2 ms 384 KB Output isn't correct
10 Incorrect 3 ms 384 KB Output isn't correct
11 Incorrect 7 ms 1792 KB Output isn't correct
12 Incorrect 20 ms 5760 KB Output isn't correct
13 Incorrect 3 ms 640 KB Output isn't correct
14 Incorrect 21 ms 7040 KB Output isn't correct
15 Incorrect 18 ms 5248 KB Output isn't correct
16 Incorrect 29 ms 8288 KB Output isn't correct
17 Incorrect 27 ms 8320 KB Output isn't correct
18 Incorrect 28 ms 8320 KB Output isn't correct
19 Incorrect 28 ms 8312 KB Output isn't correct
20 Incorrect 28 ms 8320 KB Output isn't correct