結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー 👑 kmjpkmjp
提出日時 2015-02-02 00:09:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,884 ms / 5,000 ms
コード長 1,347 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 146,916 KB
実行使用メモリ 19,576 KB
最終ジャッジ日時 2023-09-05 09:59:20
合計ジャッジ時間 9,241 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
19,428 KB
testcase_01 AC 1,482 ms
19,428 KB
testcase_02 AC 1,884 ms
19,448 KB
testcase_03 AC 331 ms
19,500 KB
testcase_04 AC 1,447 ms
19,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,S,X,Y,Z,T,U,V;
int Q;
ll A[2020000];
ll C[80000];
ll TT[2500];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>X>>Y>>Z;
	
	A[0]=S;
	FOR(i,N) A[i+1]=(X*A[i]+Y)%Z;
	FOR(i,N) C[i/50]|=(A[i]%2)<<(i%50);
	
	cin>>Q;
	while(Q--) {
		cin>>S>>T>>U>>V;
		ll sp=T-S+1;
		S--,U--;
		x=S%50;
		FOR(i,sp/50+2) TT[1+i]=C[S/50+i];
		FOR(i,sp/50+2) TT[1+i]=(TT[1+i]>>x) | (((TT[i+2]&((1LL<<x)-1)))<<(50-x));
		FOR(i,sp/50+4) {
			if((i+1)*50<=sp) continue;
			else if((i+1)*50-sp<=50) TT[i+1]&=(1LL<<(sp%50))-1;
			else TT[i+1]=0;
		}
		x=U%50;
		for(i=sp/50+2;i>=0;i--) TT[i+1]=((TT[i+1]<<x) | (TT[i]>>(50-x))) & ((1LL<<50)-1);
		FOR(i,sp/50+2) C[i+U/50] ^= TT[i+1];
	}
	
	
	FOR(i,N) _P("%c","EO"[(C[i/50]>>(i%50))&1]);
	_P("\n");
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0