結果

問題 No.759 悪くない忘年会にしような!
ユーザー はむこはむこ
提出日時 2018-12-03 11:49:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,034 bytes
コンパイル時間 2,392 ms
コンパイル使用メモリ 188,384 KB
実行使用メモリ 29,244 KB
最終ジャッジ日時 2023-10-11 13:15:26
合計ジャッジ時間 9,097 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,564 KB
testcase_01 AC 5 ms
6,560 KB
testcase_02 AC 4 ms
6,440 KB
testcase_03 AC 5 ms
6,444 KB
testcase_04 AC 4 ms
6,364 KB
testcase_05 AC 5 ms
6,548 KB
testcase_06 AC 4 ms
6,508 KB
testcase_07 AC 5 ms
6,732 KB
testcase_08 AC 5 ms
6,552 KB
testcase_09 AC 5 ms
6,560 KB
testcase_10 AC 4 ms
6,500 KB
testcase_11 AC 4 ms
6,436 KB
testcase_12 AC 4 ms
6,436 KB
testcase_13 AC 4 ms
6,668 KB
testcase_14 AC 4 ms
6,536 KB
testcase_15 AC 3 ms
6,428 KB
testcase_16 AC 4 ms
6,508 KB
testcase_17 AC 5 ms
6,560 KB
testcase_18 AC 5 ms
6,552 KB
testcase_19 AC 4 ms
6,484 KB
testcase_20 AC 4 ms
6,540 KB
testcase_21 AC 3 ms
6,424 KB
testcase_22 AC 4 ms
6,540 KB
testcase_23 AC 4 ms
6,508 KB
testcase_24 AC 4 ms
6,432 KB
testcase_25 AC 4 ms
6,552 KB
testcase_26 AC 3 ms
6,372 KB
testcase_27 AC 4 ms
6,440 KB
testcase_28 AC 4 ms
6,560 KB
testcase_29 AC 5 ms
6,560 KB
testcase_30 AC 4 ms
6,560 KB
testcase_31 AC 5 ms
6,560 KB
testcase_32 AC 4 ms
6,492 KB
testcase_33 AC 14 ms
7,544 KB
testcase_34 AC 6 ms
6,440 KB
testcase_35 AC 9 ms
6,976 KB
testcase_36 AC 14 ms
7,492 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 7 ms
6,824 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 16 ms
7,888 KB
testcase_43 AC 17 ms
7,756 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 376 ms
29,156 KB
testcase_64 AC 378 ms
29,124 KB
testcase_65 WA -
testcase_66 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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>;

template<class T>
struct SegmentTreeMax {
    int n;
    T inf;
    vector<T> dat;
    SegmentTreeMax(int n_ = 0) : n(n_){
        inf = numeric_limits<T>::min();
        for(n = 1; n < n_; n <<= 1);
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(r - l == w) return dat[v]; // assert(l == 0 && r == w);
        int m = w/2;
        return max(query(v*2, m, l, min(r,m)), query(v*2+1, m, max(0,l-m), r-m));
    }
    void update(int i, const T &x){
        dat[i+=n] = x;
        for(; i!=1; i/=2) dat[i/2] = max(dat[i], dat[i^1]);
    }
    T query(int l, int r){ return query(1,n,l,r); }
    size_t size() const { return n; }
    T operator [] (const int &idx) { return query(idx, idx + 1); }
};

int main(void) {
    ios::sync_with_stdio(false); cin.tie(0);
    SegmentTreeMax<int> s(1e5+10);
    ll n; cin >> n; 

    vector<vector<P>> g(1e5+10);
    map<vll, ll> memo;
    rep(i, n) {
        ll x, y, z; cin >> x >> y >> z;
        g[x].pb(P(y, z + 1));
        memo[{x, y, z + 1}] = i;
    }
    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, 1e5+10)) {
                next.pb(x);
                ret.pb({i, x.fi, x.se});
            }
            s.update(x.fi, x.se);
        }
    }

    set<ll> id;
    for (auto x : ret) id.insert(memo[x]);
    for (auto x : id) cout << x + 1 << endl;

    return 0;
}
0