結果

問題 No.1443 Andd
ユーザー saxofone111saxofone111
提出日時 2021-03-28 14:03:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,439 bytes
コンパイル時間 2,506 ms
コンパイル使用メモリ 214,164 KB
実行使用メモリ 28,188 KB
最終ジャッジ日時 2024-05-06 22:39:29
合計ジャッジ時間 6,042 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec A(N);
  ll s = 0;
  llvec S(N+1, 0);
  rep(i, N){
    cin >> A[i];
    S[i+1] =S[i] + A[i];
  }
  
  vector<llvec> dp1(N+1, llvec(1<<10, 0));// AND
  vector<llvec> dp2(N+1, llvec(1<<10, 0));// plus
  dp1[0][0] = 1;
  set<ll> ss;
  rep(i, N){
    set<ll> tmp;
    set<ll> next;
    rep(j, 1<<10){      
      if(dp1[i][j]==1){
        dp1[i+1][j & A[i]] = 1;
        dp1[i+1][(j + A[i])%(1<<10)] = 1;
        tmp.insert(j + A[i]);
        if(j+A[i]>=(1<<10))next.insert(j + A[i]);
        tmp.insert(j & A[i]);
      }
    }
    for(auto iss: ss){
      if(iss+A[i]>=(1<<10))next.insert(iss + A[i]);
      tmp.insert(iss+A[i]);
    }
    cout << tmp.size() << endl;
    ss = next;
  }
  return 0;
}
0