結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー beet
提出日時 2021-04-05 00:29:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4,096 ms / 5,000 ms
コード長 1,082 bytes
コンパイル時間 3,271 ms
コンパイル使用メモリ 197,780 KB
最終ジャッジ日時 2025-01-20 11:48:25
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   scanf("%d %d %d %d %d",&n,&s,&x,&y,&z);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |   scanf("%d",&q);
      |   ~~~~~^~~~~~~~~
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d %d %d %d",&a,&b,&c,&d);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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

const int BIT=17;
const int MAX=1<<BIT;
const int MSK=MAX-1;
using BS = bitset<MAX>;
BS res[1<<(22-BIT)];

signed main(){
  int n,s,x,y,z;
  scanf("%d %d %d %d %d",&n,&s,&x,&y,&z);

  BS all(0);
  for(int i=0;i<MAX;i++) all[i]=1;
  for(int i=0,a=s;i<n;i++){
    res[i>>BIT][i&MSK]=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>>BIT)+1)<<BIT;
    if(p<=b){
      tmp|=res[a>>BIT]>>(a&MSK);
      tmp|=(res[p>>BIT]&(all>>(MAX-(b-p))))<<(p-a);
    }else{
      tmp|=(res[a>>BIT]>>(a&MSK))&(all>>(MAX-(b-a)));
    }

    int q=((c>>BIT)+1)<<BIT;
    res[c>>BIT]^=tmp<<(c&MSK);
    res[q>>BIT]^=tmp>>(q-c);
  }

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