結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー 沙耶花沙耶花
提出日時 2021-10-28 08:18:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,361 ms / 5,000 ms
コード長 1,205 bytes
コンパイル時間 4,339 ms
コンパイル使用メモリ 258,048 KB
実行使用メモリ 19,408 KB
最終ジャッジ日時 2024-04-16 13:00:26
合計ジャッジ時間 9,957 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 351 ms
19,328 KB
testcase_01 AC 1,097 ms
19,400 KB
testcase_02 AC 1,361 ms
19,320 KB
testcase_03 AC 321 ms
19,408 KB
testcase_04 AC 1,058 ms
19,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000
unsigned long long temp[2000];

int main(){
	
	long long N,S,X,Y,Z;
	cin>>N>>S>>X>>Y>>Z;
	
	vector<long long> a(N);
	a[0] = S;
	rep(i,N-1){
		a[i+1] = X * a[i] + Y;
		a[i+1] %= Z;
	}
	
	int sz = (N+63)/64;
	
	vector<unsigned long long> v(sz,0);
	rep(i,N){
		if(a[i]%2==1){
			v[i/64] |= 1ULL<<(i%64);
		}
	}
	v.push_back(0);
	int Q;
	cin>>Q;
	
	rep(_,Q){
		int s,t,u,hoge;
		scanf("%d %d %d %d",&s,&t,&u,&hoge);
		s--;t--;u--;hoge--;
		int len = t-s+1;
		
		rep(i,(len+63)/64)temp[i] = 0;
		
		rep(i,len/64){
			temp[i] = (v[s/64 + i]>>(s%64));
			if(s%64!=0)temp[i] ^= (v[s/64+1 + i]<<(64-s%64));
		}
		rep(i,len%64){
			int ind = s + len/64 * 64 + i;
			if((v[ind/64]>>(ind%64))&1)temp[len/64] |= 1ULL<<i;
		}
		rep(i,(len+63)/64){
			//cout<<(bitset<64>)temp[i]<<endl;
			v[u/64 + i] ^= temp[i]<<(u%64);
			if(u%64!=0)v[u/64 + i + 1] ^= temp[i]>>(64-u%64);
		}
	}
	rep(i,N){
		int b = (v[i/64]>>(i%64))&1;
		if(b==0)printf("E");
		else printf("O");
	}
	cout<<endl;
	
	return 0;
}
0