結果
問題 |
No.142 単なる配列の操作に関する実装問題
|
ユーザー |
|
提出日時 | 2025-07-23 08:35:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,141 bytes |
コンパイル時間 | 1,880 ms |
コンパイル使用メモリ | 201,880 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-23 08:36:12 |
合計ジャッジ時間 | 12,528 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int S,X,Y,Z; cin >> S >> X >> Y >> Z; vector<bool> B(N); for(int i=0; i<N; i++){ if(S&1) B.at(i) = true; S = (1LL*S*X+Y)%Z; } const int mod = 64; using ull = unsigned long long; int n = (N+mod-1)/mod; vector<ull> A(n),A2(n); int pos = 0,bit = 0; for(int i=0; i<N; i++){ if(B.at(i)) A.at(pos) += 1ULL<<bit; bit++; if(bit == mod) pos++,bit = 0; } ull maxv = numeric_limits<ull>::max(); auto move = [&](int l,int r,int L,int R) -> void { int posl = l/mod,lmod = l%mod; int posL = L/mod,Lmod = L%mod; int len = r-l; while(len >= mod){ if(lmod <= Lmod){ int movebit = mod-Lmod; len -= movebit; ull bring = A.at(posl)&((1ULL<<(lmod+movebit))-(1ULL<<lmod)); A2.at(posL) ^= (bring>>lmod)<<Lmod; Lmod = mod,lmod += movebit; } else{ int movebit = mod-lmod; len -= movebit; ull bring = A.at(posl)&(maxv-(1ULL<<lmod)+1); A2.at(posL) ^= (bring>>lmod)<<Lmod; lmod = mod,Lmod += movebit; } if(lmod == mod) lmod = 0,posl++; if(Lmod == mod) Lmod = 0,posL++; } while(len--){ if(A.at(posl)&(1ULL<<lmod)) A2.at(posL) ^= 1ULL<<Lmod; lmod++,Lmod++; if(lmod == mod) lmod = 0,posl++; if(Lmod == mod) Lmod = 0,posL++; } len = r-l; posL = L/mod; while(len > 0){ A.at(posL) ^= A2.at(posL); A2.at(posL) = 0; posL++,len -= mod; } }; int Q; cin >> Q; while(Q--){ int l,r,L,R; cin >> l >> r >> L >> R; move(l-1,r,L-1,R); } pos = 0,bit = 0; for(int i=0; i<N; i++){ if(A.at(pos)&1) cout << "O"; else cout << "E"; A.at(pos) >>= 1; bit++; if(bit == mod) bit = 0,pos++; } cout << endl; }