結果
| 問題 |
No.2498 OX Operations
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2023-10-07 00:23:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 762 ms / 4,000 ms |
| コード長 | 2,031 bytes |
| コンパイル時間 | 4,384 ms |
| コンパイル使用メモリ | 263,804 KB |
| 最終ジャッジ日時 | 2025-02-17 05:57:30 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:51:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | rep(i,N)scanf("%d",&m[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:57:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
57 | scanf("%d %d %d",&l,&r,&x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
using A = array<int,2>;
A op(A a,A b){
return a;
}
A e(){
A ret;
ret[0] = 0,ret[1] = (1<<30)-1;
return ret;
}
A mapping(A a,A b){
A ret;
ret[0] = (b[0] & a[1]) | ((~b[0]) & a[0]);
ret[1] = (b[1] & a[1]) | ((~b[1]) & a[0]);
return ret;
}
A composition(A a,A b){
A ret;
ret[0] = (b[0] & a[1]) | ((~b[0]) & a[0]);
ret[1] = (b[1] & a[1]) | ((~b[1]) & a[0]);
return ret;
}
A id(){
A ret;
ret[0] = 0,ret[1] = (1<<30)-1;
return ret;
}
int main(){
int N,Q;
cin>>N>>Q;
vector<int> m(N);
rep(i,N)scanf("%d",&m[i]);
lazy_segtree<A,op,e,A,mapping,composition,id> seg(N);
rep(i,Q){
char c;
cin>>c;
int l,r,x;
scanf("%d %d %d",&l,&r,&x);
l--;
A t;
t[0] = 0,t[1] = 0;
rep(j,30){
//cout<<j<<endl;
if(c=='o'){
if((x>>j)&1)t[0] |= 1<<j,t[1] |= 1<<j;
else t[1] |= 1<<j;
}
else{
if((x>>j)&1)t[0] |= 1<<j;
else t[1] |= 1<<j;
}
}
seg.apply(l,r,t);
}
// cout<<'h'<<endl;
vector<mint> dp(31,0);
dp[0] = 1;
rep(i,N){
auto ret = seg.get(i);
vector tdp(2,vector<mint>(31,0));
int M = m[i];
tdp[0][0] = 1;
int C = 1;
{
vector ndp(2,vector<mint>(31,0));
for(int j=29;j>=0;j--){
ndp.assign(2,vector<mint>(31,0));
rep(l,2){
rep(k,C){
if(tdp[l][k]==0)continue;
rep(n,2){
int kk = k,ll = l;
if(l==0){
if((M>>j)&1){
if(n==0)ll++;
}
else{
if(n==1)continue;
}
}
if((ret[n]>>j)&1)kk++;
ndp[ll][kk] += tdp[l][k];
}
}
}
C++;
swap(tdp,ndp);
}
}
vector<mint> ndp(31,0);
rep(j,31){
rep(k,31){
ndp[max(j,k)] += dp[j] * (tdp[0][k] + tdp[1][k]);
}
}
swap(dp,ndp);
}
mint ans = 0;
rep(i,dp.size())ans += dp[i] * i;
cout<<ans.val()<<endl;
return 0;
}
沙耶花