結果

問題 No.759 悪くない忘年会にしような!
ユーザー parukiparuki
提出日時 2018-12-14 21:26:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 2,626 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 187,476 KB
実行使用メモリ 7,772 KB
最終ジャッジ日時 2023-10-25 10:13:38
合計ジャッジ時間 8,634 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 15 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 8 ms
4,348 KB
testcase_36 AC 14 ms
4,348 KB
testcase_37 AC 4 ms
4,348 KB
testcase_38 AC 16 ms
4,348 KB
testcase_39 AC 5 ms
4,348 KB
testcase_40 AC 12 ms
4,348 KB
testcase_41 AC 14 ms
4,348 KB
testcase_42 AC 17 ms
4,348 KB
testcase_43 AC 18 ms
4,348 KB
testcase_44 AC 166 ms
7,772 KB
testcase_45 AC 166 ms
7,772 KB
testcase_46 AC 165 ms
7,772 KB
testcase_47 AC 165 ms
7,772 KB
testcase_48 AC 165 ms
7,772 KB
testcase_49 AC 18 ms
4,348 KB
testcase_50 AC 18 ms
4,348 KB
testcase_51 AC 18 ms
4,348 KB
testcase_52 AC 18 ms
4,348 KB
testcase_53 AC 165 ms
7,772 KB
testcase_54 AC 165 ms
7,772 KB
testcase_55 AC 165 ms
7,772 KB
testcase_56 AC 166 ms
7,772 KB
testcase_57 AC 165 ms
7,772 KB
testcase_58 AC 166 ms
7,772 KB
testcase_59 AC 166 ms
7,772 KB
testcase_60 AC 165 ms
7,772 KB
testcase_61 AC 165 ms
7,772 KB
testcase_62 AC 165 ms
7,772 KB
testcase_63 AC 259 ms
7,772 KB
testcase_64 AC 258 ms
7,772 KB
testcase_65 AC 136 ms
7,772 KB
testcase_66 AC 248 ms
7,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val, class Cmp>
class DynamicRMQ {
    int n;
    Val init;
    vector<Val> dat;
    Cmp cmp;
    inline Val query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return dat[k];
        else {
            Val vl, vr;
            vl = query(a, b, k << 1, l, (l + r) >> 1);
            vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r);
            return cmp(vl, vr) ? vl : vr;
        }
    }
public:
    DynamicRMQ() {}
    DynamicRMQ(int n_, Val init_) :n(1), init(init_) {
        for (; n<n_; n <<= 1);
        dat = vector<Val>(n << 1, init);
    }
    void update(int k, Val a) {
        k += n;
        dat[k] = a;
        while (k > 1) {
            k >>= 1;
            dat[k] = cmp(dat[k << 1], dat[(k << 1) | 1]) ? dat[k << 1] : dat[(k << 1) | 1];
        }
    }
    Val query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

typedef DynamicRMQ<long long, less<long long> > RMinQ64;
typedef DynamicRMQ<long long, greater<long long> > RMaxQ64;
typedef DynamicRMQ<int, less<int> > RMinQ32;
typedef DynamicRMQ<int, greater<int> > RMaxQ32;

vector<bool> f(vi a, vi b, vi c) {
    static const int LIM = 10004;
    int n = sz(a);
    vector<bool> res(n);
    RMaxQ32 bma(LIM, -1);

    vector<tuple<int, int, int, int>> abc(n);
    rep(i, n)abc[i] = tie(a[i], b[i], c[i], i);
    sort(all(abc));
    reverse(all(abc));
    vi id(n);

    rep(i, n) {
        tie(a[i], b[i], c[i], id[i]) = abc[i];
        if (bma.query(c[i] + 1, LIM) >= b[i])
            res[id[i]] = true;
        bma.update(c[i], max(bma.query(c[i], c[i] + 1), b[i]));
    }

    return res;
}

void solve() {
    int N;
    cin >> N;
    vi P(N), T(N), R(N);
    rep(i, N) {
        cin >> P[i] >> T[i] >> R[i];
    }

    auto fr = f(P, T, R);
    auto ft = f(P, R, T);
    auto fp = f(T, R, P);

    rep(i, N) if (!fp[i] && !ft[i] && !fr[i]) cout << i + 1 << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0