結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー tottoripapertottoripaper
提出日時 2016-10-14 22:59:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 4,000 ms
コード長 1,921 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 177,880 KB
実行使用メモリ 10,380 KB
最終ジャッジ日時 2023-08-14 11:55:16
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
9,408 KB
testcase_01 AC 41 ms
8,984 KB
testcase_02 AC 34 ms
8,068 KB
testcase_03 AC 43 ms
8,600 KB
testcase_04 AC 41 ms
8,476 KB
testcase_05 AC 36 ms
8,268 KB
testcase_06 AC 52 ms
10,380 KB
testcase_07 AC 35 ms
8,736 KB
testcase_08 AC 43 ms
9,312 KB
testcase_09 AC 40 ms
8,784 KB
testcase_10 AC 34 ms
8,412 KB
testcase_11 AC 36 ms
8,268 KB
testcase_12 AC 36 ms
8,132 KB
testcase_13 AC 33 ms
8,524 KB
testcase_14 AC 33 ms
7,892 KB
testcase_15 AC 30 ms
8,368 KB
testcase_16 AC 36 ms
8,260 KB
testcase_17 AC 37 ms
8,484 KB
testcase_18 AC 37 ms
8,688 KB
testcase_19 AC 35 ms
8,364 KB
testcase_20 AC 33 ms
8,032 KB
testcase_21 AC 34 ms
8,280 KB
testcase_22 AC 38 ms
8,380 KB
testcase_23 AC 35 ms
8,384 KB
testcase_24 AC 33 ms
8,340 KB
testcase_25 AC 36 ms
8,276 KB
testcase_26 AC 32 ms
8,392 KB
testcase_27 AC 34 ms
8,460 KB
testcase_28 AC 32 ms
8,740 KB
testcase_29 AC 34 ms
8,688 KB
testcase_30 AC 2 ms
7,556 KB
testcase_31 AC 3 ms
7,776 KB
testcase_32 AC 39 ms
8,376 KB
testcase_33 AC 39 ms
8,536 KB
testcase_34 AC 39 ms
8,908 KB
testcase_35 AC 3 ms
7,636 KB
testcase_36 AC 3 ms
7,624 KB
testcase_37 AC 2 ms
7,656 KB
testcase_38 AC 3 ms
7,636 KB
testcase_39 AC 3 ms
7,596 KB
testcase_40 AC 3 ms
7,652 KB
testcase_41 AC 6 ms
7,840 KB
testcase_42 AC 6 ms
7,680 KB
testcase_43 AC 5 ms
7,708 KB
testcase_44 AC 5 ms
7,872 KB
testcase_45 AC 4 ms
7,604 KB
testcase_46 AC 7 ms
7,924 KB
testcase_47 AC 7 ms
7,900 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 fth(t) std::get<3>(t)

using ll = long long;
using P = std::tuple<int,int,int,int>;
using P3 = std::tuple<int,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, K, nxt[100000], prv[100000];
P ps[100000];
std::vector<P3> us[100000];
std::priority_queue<P, vector<P>, greater<P>> pq;

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

    std::cin >> N >> K;

    for(int i=0;i<N;++i){
        std::cin >> fst(ps[i]) >> snd(ps[i]) >> thd(ps[i]);
        fst(ps[i]) = -fst(ps[i]);
        fth(ps[i]) = i;
    }

    sort(ps, ps+N);

    int n = 0;
    for(int i=0,j=0;i<N;){
        vector<int> is;
        
        while(j < N && fst(ps[j]) == fst(ps[i])){
            int p, u, index;
            tie(ignore, p, u, index) = ps[j];

            us[u].emplace_back(p, u, index);
            is.emplace_back(u);
            
            ++j;
        }

        sort(is.begin(), is.end());
        is.erase(unique(is.begin(), is.end()), is.end());
        
        for(int u : is){
            sort(us[u].begin() + prv[u], us[u].end());
            pq.push(std::make_tuple(nxt[u], fst(us[u][nxt[u]]), snd(us[u][nxt[u]]), thd(us[u][nxt[u]])));
            ++nxt[u];
            prv[u] = us[u].size();
        }

        int _n = 0;
        while(_n < j - i){
            int u, index;
            tie(ignore, ignore, u, index) = pq.top();
            pq.pop();

            printf("%d\n", index);
            if(++n == K){return 0;}

            if(nxt[u] < us[u].size()){
                pq.push(std::make_tuple(nxt[u], fst(us[u][nxt[u]]), snd(us[u][nxt[u]]), thd(us[u][nxt[u]])));
                ++nxt[u];
            }
            ++_n;
        }

        i = j;
    }
}
0