結果
問題 | No.142 単なる配列の操作に関する実装問題 |
ユーザー |
![]() |
提出日時 | 2020-02-09 07:26:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,865 ms / 5,000 ms |
コード長 | 1,841 bytes |
コンパイル時間 | 1,112 ms |
コンパイル使用メモリ | 111,644 KB |
実行使用メモリ | 24,196 KB |
最終ジャッジ日時 | 2024-10-01 05:45:13 |
合計ジャッジ時間 | 8,506 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#include <utility>#include <functional>#include <time.h>#include <stack>#include <array>#define popcount __builtin_popcountusing namespace std;typedef long long int ll;typedef pair<int, int> P;int n;ll seed, x, y, z;ll a[2000020];int q;int main(){cin>>n>>seed>>x>>y>>z;cin>>q;a[0]=seed;for(int i=1; i<n; i++) a[i]=(x*a[i-1]+y)%z;using ull=unsigned long long;ull c[2000000/64]={};for(int i=0; i<n; i++){if(a[i]&1) c[i>>6]^=(1ull<<(i&63));}for(int i=0; i<q; i++){int s, t, u, v;cin>>s>>t>>u>>v;s--; t--; u--; v--;int d=t-s+1;if(u<=s){for(int j=0; j<d; j+=64){ull x=(c[(s+j)>>6]>>((s+j)&63))^((c[((s+j)>>6)+1]&((1ull<<((s+j)&63))-1))<<(64-((s+j)&63)));if(j+63>=d) x&=((1ull<<(d-j))-1);c[(u+j)>>6]^=(x<<((u+j)&63));if(((u+j)&63)>0) c[((u+j)>>6)+1]^=(x>>(64-((u+j)&63)));}}else{for(int j=((d-1)>>6)<<6; j>=0; j-=64){ull x=(c[(s+j)>>6]>>((s+j)&63))^((c[((s+j)>>6)+1]&((1ull<<((s+j)&63))-1))<<(64-((s+j)&63)));if(j+63>=d) x&=((1ull<<(d-j))-1);c[(u+j)>>6]^=(x<<((u+j)&63));if(((u+j)&63)>0) c[((u+j)>>6)+1]^=(x>>(64-((u+j)&63)));}}}string ans;for(int i=0; i<n; i++){if(c[i>>6]&(1ull<<(i&63))) ans+='O';else ans+='E';}cout<<ans<<endl;return 0;}