結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー chocoruskchocorusk
提出日時 2020-02-09 07:26:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,895 ms / 5,000 ms
コード長 1,841 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 112,248 KB
実行使用メモリ 23,172 KB
最終ジャッジ日時 2024-04-08 11:59:15
合計ジャッジ時間 8,716 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
23,172 KB
testcase_01 AC 1,538 ms
23,172 KB
testcase_02 AC 1,895 ms
23,172 KB
testcase_03 AC 470 ms
23,172 KB
testcase_04 AC 1,484 ms
23,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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_popcount
using 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;
}
0