Submission #956488

# Submission time Handle Problem Language Result Execution time Memory
956488 2024-04-02T05:30:30 Z modwwe Automobil (COCI17_automobil) C++17
100 / 100
4 ms 18012 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define int long long
#define d6 1000010
#define down cout<<'\n';
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define debug(x) cerr<<x<<" ";
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define sz(s) s.size()
#define pii pair<int,int>
#define pb push_back
#define checktime   cout << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define reb(i,m,n) for(int i=m;i>=n;i--)
#define ALL(v) v.begin(), v.end()
#define base 31
#define base2 37
using namespace std;
void phongbeo();
void de();
template<typename A, typename B>istream& operator>>(istream& in, pair<A, B> &v)
{
    in >> v.first >> v.second;
    return in;
}
template<typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B> &v)
{
    out << v.first << " " << v.second << " ";
    return out;
}
template < class T > bool minimize(T& a, const T& b)
{
    return b < a ? a = b, 1 : 0;
}
template < class T > bool maximize(T& a, const T& b)
{
    return a < b ? a = b, 1 : 0;
}
mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count    ());
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy2[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int mod2=1e9+7;
const int mod=1e9+7;
const int  mod1=998244353;
struct ib
{
    int a;
    int b;
};
struct icd
{
    int a,b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
int minn=1e12+1,maxx=-1e9;
int n,m,s2,s4,s3,sf,k,r,dem=0,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,l;
int  s,i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
//fin(task),fou(task);
#endif
    NHP
//modwwe
    phongbeo(),down
#ifndef ONLINE_JUDGE
    //checktime
#endif
}
int a[d6];
int b[d6];
bool d[d6];
bool d2[d6];
int get(int x,int y)
{
    if(x>y) swap(x,y);
    int ss=x+y;
    int sy=y-x+1;
    if(ss%2==0) ss/=2;
    else sy/=2;
    return (ss*sy)%mod2;
}
void phongbeo()
{
    cin>>n>>m>>k;
    for(int i=1; i<=m; i++)
        a[i]=1;
    for(int j=1; j<=n; j++)
        b[j]=1;
    vector<int> v2;
    vector<int> v;
    for(int i=1; i<=k; i++)
    {
        string s;
        cin>>s>>l>>r;
        if(s=="S")
        {
            a[l]*=r,a[l]=a[l]%mod2;
            if(!d[l]&&a[l]!=1)d[l]=1,v.pb(l);
        }
        else
        {
            b[l]*=r,b[l]=b[l]%mod2;
            if(!d2[l]&&b[l]!=1)d2[l]=1,v2.pb(l);
        }
    }
    sort(v.begin(),v.end());
    sort(v2.begin(),v2.end());
    s2=0;
    v2.pb(n+1);
    for(auto x:v2)
    {
        s3+=b[x];
        s5+=b[x]*(x-1);
        if(s2<=x-2)
            s5+=get(s2,x-2);
            s3=s3%mod2;
            s5=s5%mod2;
        s2=x;
    }
    s3+=n-v2.size()+1;
    s3=s3%mod2;
    for(auto x:v)
    {
        s4+=(((a[x]*x-x)%mod2)*s3)%mod2;
        s4+=(((a[x]*m)%mod2)*s5)%mod2;
    s4=s4%mod2;
    }
    cout<<(s4+(((s5*(m-v.size()))%mod2)*m)%mod2+(s3*get(1,m))%mod2)%mod2;
    //<<" "<<s5*m+s3*get(1,m)<<" "<<get(1,m);
    /**for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
    {
        s2=(j-1)*m+i;
        s3+=(((s2*b[i])%mod2)*a[j])%mod2;
        s3=s3%mod2;
    }
    cout<<s3;*/
}

Compilation message

automobil.cpp:74:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   74 | main()
      | ^~~~
automobil.cpp: In function 'void phongbeo()':
automobil.cpp:131:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  131 |         if(s2<=x-2)
      |         ^~
automobil.cpp:133:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  133 |             s3=s3%mod2;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4560 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4696 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 3 ms 14940 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 3 ms 14680 KB Output is correct
15 Correct 3 ms 14940 KB Output is correct
16 Correct 4 ms 18008 KB Output is correct
17 Correct 4 ms 18012 KB Output is correct
18 Correct 4 ms 18012 KB Output is correct
19 Correct 4 ms 18012 KB Output is correct
20 Correct 4 ms 17916 KB Output is correct