結果

問題 No.759 悪くない忘年会にしような!
ユーザー nebukuro09nebukuro09
提出日時 2018-12-07 07:54:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,162 ms / 2,000 ms
コード長 1,983 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 180,196 KB
実行使用メモリ 94,816 KB
最終ジャッジ日時 2023-10-12 03:34:26
合計ジャッジ時間 31,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
88,140 KB
testcase_01 AC 67 ms
88,372 KB
testcase_02 AC 67 ms
88,312 KB
testcase_03 AC 67 ms
88,308 KB
testcase_04 AC 68 ms
88,308 KB
testcase_05 AC 68 ms
88,356 KB
testcase_06 AC 67 ms
88,396 KB
testcase_07 AC 68 ms
88,312 KB
testcase_08 AC 64 ms
88,356 KB
testcase_09 AC 68 ms
88,324 KB
testcase_10 AC 68 ms
88,368 KB
testcase_11 AC 71 ms
88,308 KB
testcase_12 AC 69 ms
88,356 KB
testcase_13 AC 66 ms
88,152 KB
testcase_14 AC 67 ms
88,304 KB
testcase_15 AC 65 ms
88,500 KB
testcase_16 AC 69 ms
88,140 KB
testcase_17 AC 66 ms
88,144 KB
testcase_18 AC 69 ms
88,304 KB
testcase_19 AC 69 ms
88,448 KB
testcase_20 AC 69 ms
88,308 KB
testcase_21 AC 67 ms
88,140 KB
testcase_22 AC 67 ms
88,368 KB
testcase_23 AC 66 ms
88,136 KB
testcase_24 AC 67 ms
88,308 KB
testcase_25 AC 67 ms
88,448 KB
testcase_26 AC 67 ms
88,176 KB
testcase_27 AC 68 ms
88,296 KB
testcase_28 AC 68 ms
88,316 KB
testcase_29 AC 64 ms
88,396 KB
testcase_30 AC 63 ms
88,360 KB
testcase_31 AC 67 ms
88,292 KB
testcase_32 AC 69 ms
88,304 KB
testcase_33 AC 146 ms
88,828 KB
testcase_34 AC 81 ms
88,376 KB
testcase_35 AC 109 ms
88,584 KB
testcase_36 AC 143 ms
88,656 KB
testcase_37 AC 85 ms
88,184 KB
testcase_38 AC 151 ms
88,900 KB
testcase_39 AC 82 ms
88,356 KB
testcase_40 AC 127 ms
88,676 KB
testcase_41 AC 140 ms
88,620 KB
testcase_42 AC 156 ms
88,784 KB
testcase_43 AC 171 ms
88,840 KB
testcase_44 AC 1,081 ms
94,596 KB
testcase_45 AC 1,084 ms
94,560 KB
testcase_46 AC 1,098 ms
94,556 KB
testcase_47 AC 1,075 ms
94,816 KB
testcase_48 AC 1,016 ms
94,720 KB
testcase_49 AC 165 ms
88,944 KB
testcase_50 AC 166 ms
88,880 KB
testcase_51 AC 164 ms
88,792 KB
testcase_52 AC 160 ms
88,884 KB
testcase_53 AC 1,086 ms
94,644 KB
testcase_54 AC 1,114 ms
94,652 KB
testcase_55 AC 1,136 ms
94,596 KB
testcase_56 AC 1,130 ms
94,616 KB
testcase_57 AC 1,145 ms
94,556 KB
testcase_58 AC 1,162 ms
94,568 KB
testcase_59 AC 1,138 ms
94,700 KB
testcase_60 AC 1,153 ms
94,632 KB
testcase_61 AC 1,156 ms
94,556 KB
testcase_62 AC 1,090 ms
94,696 KB
testcase_63 AC 932 ms
94,456 KB
testcase_64 AC 919 ms
94,524 KB
testcase_65 AC 917 ms
94,644 KB
testcase_66 AC 926 ms
94,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;

const int M = 10001;
typedef bitset<M> bs;
const bs zero = bs(0);

int N;
vector<int> A[101010];
vector<int> B[101010];
bool ng[101010];


class SegmentTree {
public:
    vector<bs> table;
    int size;
    int offset;

    SegmentTree(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 2;
        table = vector<bs>(size);
        offset = size / 2;
    }

    void add(int pos, int num) {
        pos += offset;
        table[pos][num] = true;
        while (pos > 1) {
            pos /= 2;
            table[pos][num] = true;
        }
    }

    bs query(int l, int r) {
        vector<int> hoge;
        query(l, r, 1, 0, offset-1, hoge);
        bs ret = zero;
        for (auto i: hoge) ret |= table[i];
        return ret;
    }

    void query(int l, int r, int i, int a, int b, vector<int>& hoge) {
        if (b < l || r < a) {

        } else if (l <= a && b <= r)
            hoge.push_back(i);
        else {
            query(l, r, i*2, a, (a+b)/2, hoge);
            query(l, r, i*2+1, (a+b)/2+1, b, hoge);
        }
    }
};


void solve2(int x) {
    REP(i, N) B[i] = A[i];
    REP(i, N) swap(B[i][0], B[i][x]);
    sort(B, B+N);

    SegmentTree st = SegmentTree(M);

    for (int i = N - 1, j = N - 1; i >= 0; --i) {
        while (j >= 0 && B[j][0] > B[i][0]) {
            st.add(B[j][1], B[j][2]);
            --j;
        }

        bs b = st.query(B[i][1], M);
        b >>= B[i][2];
        if (b.count()) ng[B[i][3]] = true;
    }
}

void solve() {
    cin >> N;
    REP(i, N) {
        A[i] = vector<int>(4);
        REP(j, 3) cin >> A[i][j];
        A[i][3] = i;
    }

    solve2(0);
    solve2(1);
    solve2(2);

    REP(i, N) if (!ng[i]) cout << i+1 << "\n";
}

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

    solve();
}
0