結果
| 問題 | No.142 単なる配列の操作に関する実装問題 |
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-04-30 23:50:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,560 ms / 5,000 ms |
| コード長 | 3,152 bytes |
| 記録 | |
| コンパイル時間 | 852 ms |
| コンパイル使用メモリ | 88,224 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 17:17:23 |
| 合計ジャッジ時間 | 7,645 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 |
ソースコード
#include <cstdio>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <bitset>
#define BITLEN 60
using namespace std;
long long arrays[100000];
int main(){
int N,S,X,Y,Z;
cin>>N>>S>>X>>Y>>Z;
long long a=S;
arrays[1]|=a%2;
for(int i=1;i<N;i++){
a=(X*a+Y)%Z;
arrays[i/BITLEN+1]|=((a%2)<<(i%BITLEN));
}
/*
for( int i = 0 ; i <N ; i++ ){
cout << (((arrays[i/BITLEN+1]&(1LL<<(i%BITLEN)))==0)?"E":"O");
}
cout << endl;
*/
/*
for( int i = 0 ; i < (N+BITLEN-1)/BITLEN; i++ ){
cout << static_cast<std::bitset<BITLEN> >(arrays[i])<<", ";
}
*/
int Q;
cin>>Q;
for(int i=0;i<Q;i++){
int s,t,u,v;
cin>>s>>t>>u>>v;
s--;t--;u--;v--;
int sr=s%BITLEN;
int ur=u%BITLEN;
int dif=ur-sr;
//cout <<"dif"<<dif<<endl;
int len=t/BITLEN-s/BITLEN+1;
long long tmp[len+2];
tmp[0]=0;
tmp[len+1]=0;
for( int j = 1+s/BITLEN; j <= 1+t/BITLEN; j++ ){
int ind=j-s/BITLEN;
tmp[ind]=arrays[j];
//cout << ind<<":"<<static_cast<std::bitset<BITLEN> >(tmp[ind])<<", ";
if( j== 1+s/BITLEN ){
tmp[ind]&=(1LL<<BITLEN)-(1LL<<(s%BITLEN));
}
if( j== 1+t/BITLEN ){
tmp[ind]&=(1LL<<(t%BITLEN+1))-1;
}
//cout << ind<<":"<<static_cast<std::bitset<BITLEN> >(tmp[ind])<<", ";
}
//cout << endl;
if( dif >=0 ){
long long carry = 0;
for( int i = 1; i <= len+1; i++ ){
//cout << static_cast<std::bitset<BITLEN> >(tmp[i])<<endl;
long long ncarry=tmp[i]>>(BITLEN-dif);
tmp[i]=((tmp[i]<<dif)+carry)&((1LL<<BITLEN)-1);
carry=ncarry;
}
for( int i = 1; i <= len+1; i++ ){
//cout << static_cast<std::bitset<BITLEN> >(arrays[t/BITLEN+i])<<"^";
//cout << static_cast<std::bitset<BITLEN> >(tmp[i])<<endl;
arrays[u/BITLEN+i]^=tmp[i];
}
}
if( dif < 0 ){
long long carry = 0;
for( int i = len ; i >= 0 ; i--){
//cout << static_cast<std::bitset<BITLEN> >(tmp[i])<<endl;
long long ncarry = (tmp[i]&((1LL<<-dif)-1))<<(BITLEN+dif);
tmp[i]=carry+(tmp[i]>>-dif);
carry=ncarry;
}
for( int i = 0; i <= len ; i++ ){
//cout << static_cast<std::bitset<BITLEN> >(arrays[t/BITLEN+i])<<"^";
//cout << static_cast<std::bitset<BITLEN> >(tmp[i])<<endl;
arrays[u/BITLEN+i]^=tmp[i];
}
}
/*
for( int i = 0 ; i <N ; i++ ){
cout << (((arrays[i/BITLEN+1]&(1LL<<(i%BITLEN)))==0)?"E":"O");
}
cout << endl;
*/
}
for( int i = 0 ; i <N ; i++ ){
cout << (((arrays[i/BITLEN+1]&(1LL<<(i%BITLEN)))==0)?"E":"O");
}
cout<<endl;
return 0;
}
yaoshimax