結果
問題 |
No.142 単なる配列の操作に関する実装問題
|
ユーザー |
|
提出日時 | 2025-07-23 08:47:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,187 bytes |
コンパイル時間 | 2,329 ms |
コンパイル使用メモリ | 205,524 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-23 08:48:08 |
合計ジャッジ時間 | 11,935 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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; } int Q; cin >> Q; vector<tuple<int,int,int,int>> lrLR(Q); for(auto &[l,r,L,R] : lrLR) cin >> l >> r >> L >> R; 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++; } int start = L/mod; posL = min(posL,n-1); for(int i=start; i<=posL; i++){ A.at(i) ^= A2.at(i); A2.at(i) = 0; } }; for(auto [l,r,L,R] : lrLR) move(l-1,r,L-1,R); pos = 0,bit = 0; for(int i=0; i<N; i++){ if(A.at(pos)&(1ULL<<bit)) cout << "O"; else cout << "E"; bit++; if(bit == mod) bit = 0,pos++; } cout << endl; }