結果

問題 No.759 悪くない忘年会にしような!
ユーザー tottoripapertottoripaper
提出日時 2018-12-22 20:44:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 2,736 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 178,992 KB
実行使用メモリ 6,048 KB
最終ジャッジ日時 2023-10-26 02:11:39
合計ジャッジ時間 7,903 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 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 13 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 7 ms
4,348 KB
testcase_36 AC 13 ms
4,348 KB
testcase_37 AC 4 ms
4,348 KB
testcase_38 AC 15 ms
4,348 KB
testcase_39 AC 4 ms
4,348 KB
testcase_40 AC 10 ms
4,348 KB
testcase_41 AC 12 ms
4,348 KB
testcase_42 AC 14 ms
4,348 KB
testcase_43 AC 16 ms
4,348 KB
testcase_44 AC 148 ms
5,876 KB
testcase_45 AC 151 ms
5,876 KB
testcase_46 AC 149 ms
5,876 KB
testcase_47 AC 149 ms
5,876 KB
testcase_48 AC 149 ms
5,876 KB
testcase_49 AC 16 ms
4,348 KB
testcase_50 AC 15 ms
4,348 KB
testcase_51 AC 15 ms
4,348 KB
testcase_52 AC 16 ms
4,348 KB
testcase_53 AC 150 ms
5,876 KB
testcase_54 AC 150 ms
5,876 KB
testcase_55 AC 149 ms
5,876 KB
testcase_56 AC 148 ms
5,876 KB
testcase_57 AC 150 ms
5,876 KB
testcase_58 AC 148 ms
5,876 KB
testcase_59 AC 151 ms
5,876 KB
testcase_60 AC 150 ms
5,876 KB
testcase_61 AC 150 ms
5,876 KB
testcase_62 AC 149 ms
5,876 KB
testcase_63 AC 245 ms
6,040 KB
testcase_64 AC 247 ms
6,040 KB
testcase_65 AC 122 ms
5,876 KB
testcase_66 AC 236 ms
6,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
std::vector<int> A[3];
bool checked[100100];

struct SegmentTree{
    int numLeaf;
    std::vector<int> data;
    
    SegmentTree(int n){
        numLeaf = 1;
        while(numLeaf < n){
            numLeaf *= 2;
        }

        data.resize(numLeaf * 2);
        std::fill(data.begin(), data.end(), -1);
    }

    void set(int k, int v){
        k += numLeaf;
        data[k] = v;

        while(k > 1){
            k /= 2;
            data[k] = std::max(data[k*2], data[k*2+1]);
        }
    }

    int max(int l, int r){
        l += numLeaf;
        r += numLeaf;

        int res = -1;
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                res = std::max(res, data[l]);
                l += 1;
            }
            if(r & 1){
                r -= 1;
                res = std::max(res, data[r]);
            }
        }

        return res;
    }

    int at(int i){
        return data[i + numLeaf];
    }
};
    
void f(int x, int y, int z){
    std::vector<int> indices(N);
    
    std::iota(indices.begin(), indices.end(), 0);
    std::sort(indices.begin(), indices.end(), [&](int i, int j){return A[x][i] < A[x][j];});
    std::reverse(indices.begin(), indices.end());

    SegmentTree seg(N);

    for(int i=0,j=0;i<N;i=j){
        while(j < N && A[x][indices[j]] == A[x][indices[i]]){
            j += 1;
        }

        for(int k=i;k<j;++k){
            int t = A[y][indices[k]], u = A[z][indices[k]];

            if(seg.max(t, N) >= u){
                checked[indices[k]] = 1;
            }
        }

        for(int k=i;k<j;++k){
            int t = A[y][indices[k]], u = A[z][indices[k]];

            seg.set(t, std::max(seg.at(t), u));
        }
    }
}

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

    std::cin >> N;

    for(int i=0;i<3;++i){
        A[i].resize(N);
    }

    for(int i=0;i<N;++i){
        std::cin >> A[0][i] >> A[1][i] >> A[2][i];
    }

    for(int i=0;i<3;++i){
        std::vector<int> v(A[i]);
        std::sort(v.begin(), v.end());
        v.erase(std::unique(v.begin(), v.end()), v.end());

        for(int j=0;j<N;++j){
            A[i][j] = std::lower_bound(v.begin(), v.end(), A[i][j]) - v.begin();
        }
    }

    f(0, 1, 2);
    f(1, 2, 0);
    f(2, 0, 1);

    for(int i=0;i<N;++i){
        if(!checked[i]){
            std::cout << (i + 1) << std::endl;
        }
    }
}
0