結果
| 問題 |
No.759 悪くない忘年会にしような!
|
| コンテスト | |
| ユーザー |
はむこ
|
| 提出日時 | 2018-12-03 11:04:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 4,723 bytes |
| コンパイル時間 | 2,275 ms |
| コンパイル使用メモリ | 195,760 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2024-09-13 11:59:26 |
| 合計ジャッジ時間 | 11,792 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 RE * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
struct Pool {
int pos;
char mem[(ll)2e8]; // 200MB
Pool(){ free(); }
template<class T>
T *fetch(size_t n = 1) {
T *res = (T*)(mem + pos);
pos += sizeof(T)*n;
return res;
}
void free(){ pos = 0; }
}; Pool pool;
template<class T>
class AssosiativeOperator {
public:
AssosiativeOperator(void) { }
T T0;
virtual T op(T a, T b) = 0;
T L0;
virtual T op_lazy(T a, T b) = 0;
virtual T resolve_lazy(T d, T l, int nl, int nr) = 0;
};
template<class T>
class AssosiativeOperatorMax : public AssosiativeOperator<T> {
public:
AssosiativeOperatorMax(void) { AssosiativeOperator<T>::T0 = -100; AssosiativeOperator<T>::L0 = 0; }
virtual T op(T a, T b) { return max(a, b); } // Range Max
virtual T op_lazy(T a, T b) { return max(a, b); } // Range Add
virtual T resolve_lazy(T d, T l, int nl, int nr) { return max(d, l); } // 全部上がってるので、子によらず増える
};
template<class T>
class SegmentTree {
public:
T *dat, *lazy;
AssosiativeOperator<T>* op;
int n = 1;
int bits = 0;
const size_t size_;
int ql, qr;
bool enable_range_update_flag = true;
bool enable_point_update_with_op_flag = false;
SegmentTree(int n_, AssosiativeOperator<T>* op) : size_(n_) {
this->op = op;
while(n < n_) { n <<= 1; bits++; }
dat = pool.fetch<T>(n+n);
lazy = pool.fetch<T>(n+n);
fill_n(dat, n*4, this->op->T0);
}
void inline pushdown(int v, int nl, int nr){
assert(enable_range_update_flag);
dat[v] = op->resolve_lazy(dat[v], lazy[v], nl, nr);
if(v < n){ // 子がいれば
lazy[v<<1] = op->op_lazy(lazy[v<<1], lazy[v]);
lazy[v<<1|1] = op->op_lazy(lazy[v<<1|1], lazy[v]);
}
lazy[v] = op->L0;
}
void inline pullup(int v){
assert(enable_range_update_flag);
dat[v] = op->op(dat[v<<1], dat[v<<1|1]);
}
void update(int v, const T &x){
v += n;
if (enable_point_update_with_op_flag)
dat[v] = op->op(dat[v], x);
else
dat[v] = x;
while (v){
v = v >> 1;
dat[v] = op->op(dat[v<<1], dat[v<<1|1]);
}
}
void update(int n, int nl, int nr, const T &x){
assert(enable_range_update_flag);
pushdown(n, nl, nr);
if(nr <= ql || qr <= nl) return;
if(ql <= nl && nr <= qr) {
lazy[n] = op->op_lazy(lazy[n], x);
pushdown(n, nl, nr);
return;
}
int m = (nl + nr) / 2;
update(n<<1, nl, m, x);
update(n<<1|1, m, nr, x);
pullup(n);
}
void update(int l, int r, const T &x){
ql = l; qr = r;
return update(1, 0, n, x);
}
T query(int n, int nl, int nr){
if (enable_range_update_flag) pushdown(n, nl, nr);
if(nr <= ql || qr <= nl) return op->T0;
if(ql <= nl && nr <= qr) return dat[n];
if (enable_range_update_flag) pullup(n);
int m = (nl + nr) / 2;
return op->op(query(n<<1, nl, m), query(n<<1|1, m, nr));
}
T query(int l, int r){
ql = l; qr = r;
return query(1, 0, n);
}
};
int main(void) {
ios::sync_with_stdio(false); cin.tie(0);
SegmentTree<int> s(2e5, new AssosiativeOperatorMax<int>());
ll n; cin >> n; assert(0 <= n && n <= 1e4);
vector<vector<P>> g(2e5);
map<vll, ll> memo;
rep(i, n) {
ll x, y, z; cin >> x >> y >> z;
assert(0 <= x && x <= 1e4);
assert(0 <= y && y <= 1e4);
assert(0 <= z && z <= 1e4);
g[x].pb(P(y, z + 1));
memo[{x, y, z + 1}] = i;
}
assert(memo.size() == n);
vector<vll> ret;
for (ll i = g.size() - 1; i >= 0; i--) {
sort(all(g[i]));
reverse(all(g[i]));
vector<P> next;
for (auto x : g[i]) {
if (x.se > s.query(x.fi, x.fi+1)) {
next.pb(x);
ret.pb({i, x.fi, x.se});
}
s.update(0, x.fi+1, x.se);
}
}
set<ll> id;
for (auto x : ret) {
id.insert(memo[x]);
}
for (auto x : id) {
cout << x + 1 << endl;
}
return 0;
}
はむこ