結果

問題 No.814 ジジ抜き
ユーザー lumc_lumc_
提出日時 2019-04-12 23:36:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 5,431 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 123,896 KB
実行使用メモリ 36,352 KB
最終ジャッジ日時 2024-09-15 06:23:30
合計ジャッジ時間 36,546 ms
ジャッジサーバーID
(参考情報)
judge3 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 105 ms
10,480 KB
testcase_05 AC 103 ms
10,612 KB
testcase_06 TLE -
testcase_07 AC 1,482 ms
19,044 KB
testcase_08 TLE -
testcase_09 AC 2,437 ms
23,372 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,458 ms
17,280 KB
testcase_13 AC 889 ms
14,080 KB
testcase_14 AC 2,326 ms
22,400 KB
testcase_15 AC 844 ms
13,184 KB
testcase_16 AC 884 ms
12,928 KB
testcase_17 TLE -
testcase_18 AC 1,697 ms
18,304 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <list>
#include <ostream>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
template < int n, class... T >
typename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple(
    std::ostream &, std::tuple< T... > const &) {}
template < int n, class... T >
typename std::enable_if< (n < sizeof...(T)) >::type __output_tuple(
    std::ostream &os, std::tuple< T... > const &t) {
  os << (n == 0 ? "" : ", ") << std::get< n >(t);
  __output_tuple< n + 1 >(os, t);
}
template < class... T >
std::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) {
  os << "(";
  __output_tuple< 0 >(os, t);
  os << ")";
  return os;
}
template < class T, class U >
std::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template < class T >
std::ostream &operator<<(std::ostream &os, const std::stack< T > &a) {
  os << "{";
  for(auto tmp = a; tmp.size(); tmp.pop())
    os << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  os << "}";
  return os;
}
template < class T, class Container, class Compare >
std::ostream &operator<<(std::ostream &os,
    std::priority_queue< T, Container, Compare > a) {
  os << "{ (top) ";
  while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
template < class T, class Container >
std::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) {
  os << "{ ";
  while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
#ifdef DEBUG
#if !defined(DEBUG_OUT)
#define DEBUG_OUT std::cerr
#endif
#define dump(...)                                                                \
  [&]() {                                                                        \
    auto __debug_tap = std::make_tuple(__VA_ARGS__);                             \
    DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \
    << std::endl;                                                      \
  }()
template < class T >
inline void dump2D(T &d, size_t sizey, size_t sizex) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << "\t";
    for(size_t j = 0; j < sizex; j++)
      DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t");
    DEBUG_OUT << std::endl;
  }
}
template < class T >
inline void dump1D(T &d, size_t sizey) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " ");
  }
  DEBUG_OUT << std::endl;
}
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        os << "{";
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : ", ") << *ite;
        os << "}";
        return os;
      }
#else
#define dump(...) (42)
#define dump2D(...) (42)
#define dump1D(...) (42)
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : " ") << *ite;
        return os;
      }
#endif
// }}}


ll rot(ll x, int r, int b = 32) {
  r %= b;
  if(r < 0) r += b;
  if(r == 0) return x;
  return (x >> r) | ((x & ((1ll << r) - 1)) << (b - r));
}

const int N = 3e5;
ll k[N];
ll l[N];
int d[N];

void flip(set<ll> & st, ll v) {
  if(st.count(v)) st.erase(v);
  else st.emplace(v);
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);

  dump(bitset<32>(rot(0b001101001, 2)));

  int n;
  cin >> n;
  vector<vector<int>> v(63);
  for(int i = 0; i < n; i++) {
    cin >> k[i] >> l[i] >> d[i];
    v[d[i]].emplace_back(i);
  }
  dump(1);
  set<ll> t;
  for(int i = 0; i < 63; i++) {
    for(auto p : v[i]) {
      l[p] = rot(l[p], i, 63);
      flip(t, l[p]);
      flip(t, l[p] + k[p]);
      dump(l[p], l[p] + k[p]);
    }
    set<ll> s;
    ll A = -1, B;
    for(auto e : t) {
      if(A == -1) {
        A = e;
      } else {
        B = e;
        B--;

        // ...0
        {
          ll AA = A, BB = B;
          if(AA & 1) AA++;
          if(BB & 1) BB--;
          if(AA <= BB) {
            flip(s, rot(AA, 1, 63));
            flip(s, rot(BB, 1, 63) + 1);
          }
        }

        // ...1
        {
          ll AA = A, BB = B;
          if(!(AA & 1)) AA++;
          if(!(BB & 1)) BB--;
          if(AA <= BB) {
            flip(s, rot(AA, 1, 63));
            flip(s, rot(BB, 1, 63) + 1);
          }
        }

        A = -1;
      }
    }
    dump(t);
    t = s;
    dump(t);
    dump(bitset<63>(*t.begin()));
  }
  dump(t);
  assert(t.size() == 2);
  cout << *t.begin() << endl;
  return 0;
}
0