結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー t98slidert98slider
提出日時 2022-06-20 11:06:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,515 ms / 5,000 ms
コード長 1,322 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 166,372 KB
実行使用メモリ 22,148 KB
最終ジャッジ日時 2024-04-20 23:52:30
合計ジャッジ時間 8,209 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 489 ms
21,900 KB
testcase_01 AC 1,289 ms
22,028 KB
testcase_02 AC 1,515 ms
22,148 KB
testcase_03 AC 436 ms
22,084 KB
testcase_04 AC 1,171 ms
22,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    unsigned long long n, s, x, y, z;
    cin >> n >> s >> x >> y >> z;
    vector<unsigned long long> a(n);
    array<unsigned long long, 200000> v{}, temp{};
    a[0] = s;
    for(int i = 1; i < n; i++){
        a[i] = (x * a[i - 1] + y) % z;
    }
    int sz = (n + 63) / 64, q, S, T, U, V;
    for(int i = 0, j = 0, k = 0; i < n; i++){
        v[k] |= (a[i] & 1ULL) << j;
        if(++j == 64) j = 0, k++;
    }
    cin >> q;
    while(q--){
        cin >> S >> T >> U >> V;
        S--, U--;
        int len = T - S, r = ((len + 63) / 64), smod = S & 63, umod = U & 63;
        fill(temp.begin(), temp.begin() + r + 1, 0);
        for(int i = 0; i < len / 64; i++){
            temp[i] |= v[S / 64 + i] >> smod;
            if(smod)temp[i] |= v[S / 64 + i + 1] << 64 - smod;
        }
        for(int i = 0, idx = S + len / 64 * 64; i < (len & 63); i++, idx++){
            if((v[idx / 64] >> (idx & 63)) & 1)temp[len / 64] |= 1ULL << i;
        }
        for(int i = 0; i < r; i++){
			v[U / 64 + i] ^= temp[i] << umod;
			if(umod) v[U / 64 + i + 1] ^= temp[i] >> 64 - umod;
		}
    }
    for(int i = 0, j = 0, k = 0; i < n; i++){
        cout << ((v[k] >> j) & 1 ? 'O' : 'E');
        if(++j == 64)j = 0, k++;
    }
    cout << '\n';
}
0