# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
776351 | LeVanThuc | Art Exhibition (JOI18_art) | C++17 | 2 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
if(x<y)
{
x=y;
return 1;
}
return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
if(x>y)
{
x=y;
return 1;
}
return 0;
}
void online()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.inp", "r", stdin);
freopen("output.out","w", stdout);
#else
#endif
}
const int M=998244353,N=5e5+10;
int in[31][N],dp[N],f[31][N],n,k,m;
int solve(int b)
{
dp[0]=1;
for(int i=1;i<=n+1;i++)
{
maximize(f[b][i],f[b][i-1]);
in[b][i]+=in[b][i-1];
if(in[b][i])
{
dp[i]=0;
}
else
{
dp[i]=dp[i-1];
if(f[b][i])
dp[i]-=dp[f[b][i]-1];
if(dp[i]<0) dp[i]+=M;
}
dp[i]=dp[i]+dp[i-1];
if(dp[i]>=M) dp[i]-=M;
}
return (dp[n+1]-dp[n]+M)%M;
}
int main()
{
online();
cin>>n>>k>>m;
for(int i=1;i<=m;i++)
{
int l,r,x;
cin>>l>>r>>x;
for(int b=0;b<k;b++)
{
if(BIT(b,x))
{
in[b][l]++;
in[b][r+1]--;
}
else maximize(f[b][r+1],l);
}
}
int ans=1;
for(int i=0;i<k;i++) ans=1ll*ans*solve(i)%M;
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |