結果

問題 No.1741 Arrays and XOR Procedure
ユーザー monnumonnu
提出日時 2021-11-12 22:39:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 3,567 ms
コンパイル使用メモリ 226,308 KB
実行使用メモリ 4,704 KB
最終ジャッジ日時 2023-08-17 02:54:10
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 37 ms
4,704 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 31 ms
4,684 KB
testcase_06 AC 37 ms
4,596 KB
testcase_07 AC 36 ms
4,644 KB
testcase_08 AC 31 ms
4,628 KB
testcase_09 AC 31 ms
4,468 KB
testcase_10 AC 33 ms
4,440 KB
testcase_11 AC 25 ms
4,444 KB
testcase_12 AC 20 ms
4,380 KB
testcase_13 AC 30 ms
4,392 KB
testcase_14 AC 22 ms
4,388 KB
testcase_15 AC 28 ms
4,524 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 11 ms
4,376 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 35 ms
4,660 KB
testcase_21 AC 27 ms
4,380 KB
testcase_22 AC 25 ms
4,380 KB
testcase_23 AC 10 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 34 ms
4,588 KB
testcase_26 AC 15 ms
4,380 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 26 ms
4,380 KB
testcase_29 AC 30 ms
4,380 KB
testcase_30 AC 26 ms
4,376 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 16 ms
4,376 KB
testcase_33 AC 18 ms
4,380 KB
testcase_34 AC 8 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 4 ms
4,380 KB
testcase_37 AC 15 ms
4,380 KB
testcase_38 AC 34 ms
4,592 KB
testcase_39 AC 13 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 7 ms
4,380 KB
testcase_42 AC 3 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 300000

int main(){
  int N;
  cin>>N;
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin>>B[i];
  }

  vector<int> cnt(N,0);
  for(int i=1;i<N;i++){
    int x=i;
    cnt[i]=cnt[i-1];
    while(x%2==0){
      x/=2;
      cnt[i]++;
    }
  }

  int x=0;
  for(int i=0;i<N;i++){
    if(B[i]==1&&cnt[N-1]-cnt[i]-cnt[(N-1)-i]==0){
      x=1-x;
    }
  }
  ll zero=0;
  ll one=0;
  if(x==0){
    zero=1;
  }else{
    one=1;
  }

  for(int i=0;i<N;i++){
    if(B[i]==-1){
      if(cnt[N-1]-cnt[i]-cnt[(N-1)-i]==0){
        ll sum=(zero+one)%MOD;
        zero=sum;
        one=sum;
      }else{
        zero=2*zero%MOD;
        one=2*one%MOD;
      }
    }
  }
  cout<<one<<'\n';
}
0