結果

問題 No.759 悪くない忘年会にしような!
ユーザー nebukuro09nebukuro09
提出日時 2018-12-07 07:49:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,872 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 179,876 KB
実行使用メモリ 94,864 KB
最終ジャッジ日時 2023-10-12 03:33:44
合計ジャッジ時間 51,115 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
88,272 KB
testcase_01 AC 101 ms
88,328 KB
testcase_02 AC 85 ms
88,220 KB
testcase_03 AC 87 ms
88,348 KB
testcase_04 AC 87 ms
88,356 KB
testcase_05 AC 85 ms
88,528 KB
testcase_06 AC 86 ms
88,360 KB
testcase_07 AC 84 ms
88,352 KB
testcase_08 AC 84 ms
88,368 KB
testcase_09 AC 84 ms
88,220 KB
testcase_10 AC 85 ms
88,400 KB
testcase_11 AC 85 ms
88,276 KB
testcase_12 AC 84 ms
88,368 KB
testcase_13 AC 85 ms
88,152 KB
testcase_14 AC 86 ms
88,296 KB
testcase_15 AC 85 ms
88,324 KB
testcase_16 AC 84 ms
88,308 KB
testcase_17 AC 85 ms
88,232 KB
testcase_18 AC 85 ms
88,232 KB
testcase_19 AC 85 ms
88,156 KB
testcase_20 AC 85 ms
88,308 KB
testcase_21 AC 83 ms
88,420 KB
testcase_22 AC 83 ms
88,304 KB
testcase_23 AC 83 ms
88,316 KB
testcase_24 AC 86 ms
88,312 KB
testcase_25 AC 85 ms
88,224 KB
testcase_26 AC 87 ms
88,300 KB
testcase_27 AC 85 ms
88,160 KB
testcase_28 AC 86 ms
88,204 KB
testcase_29 AC 85 ms
88,328 KB
testcase_30 AC 84 ms
88,216 KB
testcase_31 AC 83 ms
88,152 KB
testcase_32 AC 87 ms
88,212 KB
testcase_33 AC 248 ms
88,800 KB
testcase_34 AC 113 ms
88,252 KB
testcase_35 AC 170 ms
88,544 KB
testcase_36 AC 246 ms
88,848 KB
testcase_37 AC 120 ms
88,444 KB
testcase_38 AC 268 ms
88,848 KB
testcase_39 AC 124 ms
88,460 KB
testcase_40 AC 217 ms
88,812 KB
testcase_41 AC 236 ms
88,808 KB
testcase_42 AC 269 ms
88,808 KB
testcase_43 AC 288 ms
89,056 KB
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 AC 286 ms
88,960 KB
testcase_50 AC 285 ms
88,960 KB
testcase_51 AC 286 ms
88,968 KB
testcase_52 AC 285 ms
88,804 KB
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
testcase_61 TLE -
testcase_62 TLE -
testcase_63 AC 1,904 ms
94,596 KB
testcase_64 AC 1,896 ms
94,488 KB
testcase_65 AC 1,902 ms
94,560 KB
testcase_66 AC 1,883 ms
94,676 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) {
        return query(l, r, 1, 0, offset-1);
    }

    bs query(int l, int r, int i, int a, int b) {
        if (b < l || r < a)
            return zero;
        else if (l <= a && b <= r)
            return table[i];
        else
            return
                query(l, r, i*2, a, (a+b)/2) |
                query(l, r, i*2+1, (a+b)/2+1, b);
    }
};


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