結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー beetbeet
提出日時 2018-11-25 22:41:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,958 ms / 5,000 ms
コード長 1,046 bytes
コンパイル時間 2,025 ms
コンパイル使用メモリ 205,268 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 20:14:50
合計ジャッジ時間 18,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,205 ms
4,376 KB
testcase_01 AC 2,907 ms
4,380 KB
testcase_02 AC 2,958 ms
4,380 KB
testcase_03 AC 2,165 ms
4,376 KB
testcase_04 AC 2,596 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,s,x,y,z;
  scanf("%d %d %d %d %d",&n,&s,&x,&y,&z);
  
  const int MAX=1e5+100;
  using BS = bitset<MAX>;
  vector<BS> res(22);
  BS all(0);
  for(int i=0;i<MAX;i++) all[i]=1;  
  for(int i=0,a=s;i<n;i++){
    res[i/MAX][i%MAX]=a&1;
    a=(1LL*x*a+y)%z;
  }
  
  int q;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    a--;c--;
    
    BS tmp(0);
    
    int p=(a/MAX+1)*MAX;
    if(p<=b){
      tmp|=res[a/MAX]>>(a%MAX);
      tmp|=(res[p/MAX]&(all>>(MAX-(b-p))))<<(p-a);
    }else{
      tmp|=(res[a/MAX]>>(a%MAX))&(all>>(MAX-(b-a)));
    }

    int q=(c/MAX+1)*MAX;
    res[c/MAX]^=tmp<<(c%MAX);
    res[q/MAX]^=tmp>>(q-c);
  }

  for(int i=0;i<n;i++)
    printf("%c",res[i/MAX][i%MAX]?'O':'E');
  puts("");
  return 0;
}
0