結果

問題 No.868 ハイパー部分和問題
ユーザー ei1333333ei1333333
提出日時 2019-08-16 22:38:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,395 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 214,264 KB
実行使用メモリ 6,408 KB
最終ジャッジ日時 2023-10-24 01:58:39
合計ジャッジ時間 9,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In member function 'int OfflineDynamicConnectivity::run(std::bitset<15001>, int, int)':
main.cpp:135:3: warning: no return statement in function returning non-void [-Wreturn-type]
  135 |   }
      |   ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

struct OfflineDynamicConnectivity {

  int Q, segsz;
  vector< vector< int > > seg;


  OfflineDynamicConnectivity(int Q) : Q(Q) {
    segsz = 1;
    while(segsz < Q) segsz <<= 1;
    seg.resize(2 * segsz - 1);
  }


  void add(int a, int b, int x, int k, int l, int r) {
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      seg[k].emplace_back(x);
      return;
    }
    add(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    add(a, b, x, 2 * k + 2, (l + r) >> 1, r);
  }

  void add(int a, int b, int x) {
    add(a, b, x, 0, 0, segsz);
  }


  int run(bitset< 15001 > bit, int K, int k = 0) {
    int add = 0;
    for(auto &e : seg[k]) {
      bit |= bit << e;
    }

    if(k < segsz - 1) {
      run(bit, K, 2 * k + 1);
      run(bit, K, 2 * k + 2);
    } else if(k - (segsz - 1) < Q) {
      if(k - (segsz - 1) > 0) {
        if(bit[K]) {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
      }
    }

  }
};


int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;
  int Q;
  cin >> Q;
  OfflineDynamicConnectivity odc(Q + 1);
  vector< int > pv(N);
  for(int i = 1; i <= Q; i++) {
    int x, v;
    cin >> x >> v;
    --x;
    odc.add(pv[x], i, A[x]);
    A[x] = v;
    pv[x] = i;
  }
  for(int i = 0; i < N; i++) {
    odc.add(pv[i], Q + 1, A[i]);
  }
  bitset< 15001 > bit;
  bit[0] = 1;
  odc.run(bit, K);
}

0