結果

問題 No.759 悪くない忘年会にしような!
ユーザー fumiphysfumiphys
提出日時 2019-03-17 20:40:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,646 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 133,656 KB
実行使用メモリ 138,032 KB
最終ジャッジ日時 2023-09-22 01:40:05
合計ジャッジ時間 6,419 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
13,392 KB
testcase_01 AC 5 ms
6,288 KB
testcase_02 AC 5 ms
6,220 KB
testcase_03 AC 6 ms
6,168 KB
testcase_04 AC 6 ms
6,208 KB
testcase_05 AC 6 ms
6,292 KB
testcase_06 AC 6 ms
6,172 KB
testcase_07 AC 6 ms
6,268 KB
testcase_08 AC 5 ms
6,156 KB
testcase_09 AC 6 ms
6,272 KB
testcase_10 AC 6 ms
6,288 KB
testcase_11 AC 6 ms
6,312 KB
testcase_12 AC 6 ms
6,284 KB
testcase_13 AC 6 ms
6,280 KB
testcase_14 AC 6 ms
6,224 KB
testcase_15 AC 5 ms
6,292 KB
testcase_16 AC 5 ms
6,156 KB
testcase_17 AC 6 ms
6,176 KB
testcase_18 AC 5 ms
6,336 KB
testcase_19 AC 5 ms
6,268 KB
testcase_20 AC 5 ms
6,156 KB
testcase_21 AC 6 ms
6,272 KB
testcase_22 AC 6 ms
6,268 KB
testcase_23 AC 6 ms
6,168 KB
testcase_24 AC 6 ms
6,288 KB
testcase_25 AC 6 ms
6,168 KB
testcase_26 AC 5 ms
6,324 KB
testcase_27 AC 5 ms
6,280 KB
testcase_28 AC 6 ms
6,160 KB
testcase_29 AC 6 ms
6,228 KB
testcase_30 AC 5 ms
6,160 KB
testcase_31 AC 6 ms
6,160 KB
testcase_32 AC 5 ms
6,292 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

template<typename T, typename E>
struct SegmentTree_ {
  function<T(T&, T&)> f;
  function<void(T&, E)> g;
  int n;
  T def;
  vector<T> vec;
  SegmentTree_(){}
  SegmentTree_(int n_, function<T(T&, T&)> f_, function<void(T&, E)> g_, T def_, vector<T> v=vector<T>()){
    f = f_;
    g = g_;
    def = def_;

    // initialize vector
    n = 1;
    while(n < n_){
      n *= 2;
    }
    vec = vector<T>(2*n -1, def);

    // initialize segment tree
    for(int i = 0; i < v.size(); i++){
      vec[i + n - 1] = v[i];
    }
    for(int i = n - 2; i >= 0; i--){
      vec[i] = f(vec[2*i+1], vec[2*i+2]);
    }
  }
  void update(int k, E val){
    k = k + n - 1;
    g(vec[k], val);
    while(k > 0){
      k = (k - 1) / 2;
      vec[k] = f(vec[2*k+1], vec[2*k+2]);
    }
  }
  // [l, r) -> [a, b) (at k)
  T query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l)return def;
    if(a <= l && r <= b)return vec[k];
    T ld = query(a, b, 2*k+1, l, (l+r)/2);
    T rd = query(a, b, 2*k+2, (l+r)/2, r);
    return f(ld, rd);
  }
  T query(int a, int b){
    return query(a, b, 0, 0, n);
  }
};

template<typename T, typename E>
using SegmentTree = struct SegmentTree_<T, E>;
using SegmentTreeI = SegmentTree<int, int>;

struct store{
  ll p, t, r;
  int i;
  store(ll p, ll t, ll r, int i): p(p), t(t), r(r), i(i){}
  store(): store(0, 0, 0, 0){}
  bool operator<(const store &right) const{
    if(p != right.p)return p > right.p;
    if(t != right.t)return t > right.t;
    return r > right.r;
  }
};

struct Set{
  set<int> st;
  Set(): st(set<int>{-1}){};
  void insert(int x){
    st.insert(x);
  }
  Set operator+(const Set &right) const{
    Set s = *this;
    for(auto itr = right.st.begin(); itr != right.st.end(); ++itr){
      s.insert(*itr);
    }
    return s;
  }
};

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<store> vec(n);
  rep(i, n){
    ll p, t, r;
    cin >> p >> t >> r;
    vec[i] = store(p, t, r, i);
  }
  sort(all(vec));
  int N = 10000;
  SegmentTree<Set, int> seg = SegmentTree<Set, int>(N, [](Set& a, Set& b){return a + b;},
      [](Set& a,int b){a.insert(b);}, Set(), vector<Set>());
  vector<int> ans;
  for(int i = 0; i < n; i++){
    Set tmp = seg.query(vec[i].t, N);
    if(*(tmp.st.rbegin()) < vec[i].r)ans.pb(vec[i].i);
    seg.update(vec[i].t, vec[i].r);
  }
  sort(all(ans));
  for(int i = 0; i < sz(ans); i++)cout << ans[i] + 1 << endl;
	return 0;
}
0