Submission #776351

#TimeUsernameProblemLanguageResultExecution timeMemory
776351LeVanThucArt Exhibition (JOI18_art)C++17
0 / 100
2 ms340 KiB
#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)

art.cpp: In function 'void online()':
art.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("input.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     freopen("output.out","w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...