結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー t98slidert98slider
提出日時 2022-06-20 11:12:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,367 ms / 5,000 ms
コード長 1,331 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 167,684 KB
実行使用メモリ 19,108 KB
最終ジャッジ日時 2023-08-03 00:08:53
合計ジャッジ時間 7,388 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 306 ms
18,932 KB
testcase_01 AC 1,081 ms
19,052 KB
testcase_02 AC 1,367 ms
19,108 KB
testcase_03 AC 276 ms
18,868 KB
testcase_04 AC 1,043 ms
18,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned long long n, s, x, y, z;
    cin >> n >> s >> x >> y >> z;
    vector<unsigned long long> a(n);
    array<unsigned long long, 40000> v{};
    array<unsigned long long, 2000> temp{};
    a[0] = s;
    for(int i = 1; i < n; i++){
        a[i] = (x * a[i - 1] + y) % z;
    }
    int sz = (n + 63) >> 6, 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;
        temp[len >> 6] = 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 >> 6) << 6); i < (len & 63); i++, idx++){
            if((v[idx >> 6] >> (idx & 63)) & 1)temp[len >> 6] |= 1ULL << i;
        }
        for(int i = 0; i < r; i++){
			v[(U >> 6) + i] ^= temp[i] << umod;
			if(umod) v[(U >> 6) + i + 1] ^= temp[i] >> 64 - umod;
		}
    }
    for(int i = 0; i < n; i++){
        cout << ((v[i >> 6] >> (i & 63)) & 1 ? 'O' : 'E');
    }
    cout << '\n';
}
0