結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー rickythetarickytheta
提出日時 2016-10-14 22:53:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 178 ms / 4,000 ms
コード長 1,859 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 169,948 KB
実行使用メモリ 19,944 KB
最終ジャッジ日時 2023-08-14 11:40:10
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
19,112 KB
testcase_01 AC 163 ms
19,668 KB
testcase_02 AC 111 ms
15,020 KB
testcase_03 AC 86 ms
11,356 KB
testcase_04 AC 82 ms
11,232 KB
testcase_05 AC 122 ms
15,636 KB
testcase_06 AC 178 ms
19,944 KB
testcase_07 AC 155 ms
19,356 KB
testcase_08 AC 120 ms
16,556 KB
testcase_09 AC 70 ms
10,640 KB
testcase_10 AC 50 ms
9,120 KB
testcase_11 AC 50 ms
8,772 KB
testcase_12 AC 51 ms
9,172 KB
testcase_13 AC 44 ms
9,296 KB
testcase_14 AC 47 ms
9,104 KB
testcase_15 AC 41 ms
8,788 KB
testcase_16 AC 49 ms
9,036 KB
testcase_17 AC 53 ms
9,080 KB
testcase_18 AC 53 ms
9,348 KB
testcase_19 AC 45 ms
9,464 KB
testcase_20 AC 48 ms
9,300 KB
testcase_21 AC 47 ms
9,024 KB
testcase_22 AC 50 ms
9,028 KB
testcase_23 AC 48 ms
9,308 KB
testcase_24 AC 45 ms
9,056 KB
testcase_25 AC 49 ms
8,892 KB
testcase_26 AC 43 ms
9,072 KB
testcase_27 AC 46 ms
8,820 KB
testcase_28 AC 45 ms
9,388 KB
testcase_29 AC 47 ms
9,220 KB
testcase_30 AC 4 ms
7,044 KB
testcase_31 AC 3 ms
7,156 KB
testcase_32 AC 60 ms
9,636 KB
testcase_33 AC 59 ms
9,080 KB
testcase_34 AC 81 ms
11,604 KB
testcase_35 AC 3 ms
7,240 KB
testcase_36 AC 3 ms
7,092 KB
testcase_37 AC 4 ms
7,120 KB
testcase_38 AC 3 ms
7,116 KB
testcase_39 AC 4 ms
7,144 KB
testcase_40 AC 4 ms
7,208 KB
testcase_41 AC 7 ms
7,316 KB
testcase_42 AC 7 ms
7,356 KB
testcase_43 AC 7 ms
7,364 KB
testcase_44 AC 7 ms
7,300 KB
testcase_45 AC 4 ms
7,204 KB
testcase_46 AC 10 ms
7,264 KB
testcase_47 AC 10 ms
7,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
pair<pii,int> arr[125252];
vector<pair<pii,int>> brr[125252];
int cnt[125252];

int main(){
  scanf("%d%d",&n,&k);
  set<int> S;
  REP(i,n){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    arr[i] = make_pair(pii(a,b),c);
    S.insert(c);
  }
  map<int,int> M;
  int m=0;
  for(int x:S){
    M[x] = m++;
  }
  REP(i,n)arr[i].second = M[arr[i].second];
  REP(i,n){
    int o = arr[i].second;
    pii p = arr[i].first;
    p.first *= -1;
    brr[o].push_back(make_pair(p,i));
  }
  REP(i,m)sort(ALL(brr[i]));
  set< pair<pii,pii> > EK;
  REP(i,m){
    cnt[i] = 0;
    EK.insert(make_pair(pii(brr[i][0].first.first,cnt[i]),pii(brr[i][0].first.second,i)));
  }
  REP(i,k){
    auto P = *EK.begin();
    EK.erase(EK.begin());
    int zoku = P.second.second;
    printf("%d\n",brr[zoku][cnt[zoku]].second);
    cnt[zoku] += 1;
    if(cnt[zoku] < brr[zoku].size()){
      int id = cnt[zoku];
    EK.insert(make_pair(pii(brr[zoku][id].first.first,cnt[zoku]),pii(brr[zoku][id].first.second,zoku)));
    }
  }
  return 0;
}
0