結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー sekiya9311sekiya9311
提出日時 2016-10-14 23:45:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 4,706 bytes
コンパイル時間 1,423 ms
コンパイル使用メモリ 143,268 KB
実行使用メモリ 83,156 KB
最終ジャッジ日時 2024-05-01 23:16:07
合計ジャッジ時間 12,276 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:98:23: warning: 'n' is used uninitialized [-Wuninitialized]
   98 |             int s,p,u,n;
      |                       ^
main.cpp:98:21: warning: 'u' is used uninitialized [-Wuninitialized]
   98 |             int s,p,u,n;
      |                     ^
main.cpp:98:19: warning: 'p' is used uninitialized [-Wuninitialized]
   98 |             int s,p,u,n;
      |                   ^
main.cpp:98:17: warning: 's' is used uninitialized [-Wuninitialized]
   98 |             int s,p,u,n;
      |                 ^

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <random>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for (int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cerr << C << endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EB emplace_back
#define FORE(a, b) for (auto &&a : b)
#define FIND(s, n) (s.find(n) != s.end())

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, K;
vector<tuple<int, int, int, int>> SPU;   //解いた問題で云々
//map<int, set<tuple<int, int, int, int>>> ac;  //(正答数, SPU)
//map<int, set<tuple<int, int, int, int>>> school;    //(学校, SPU)
//map<int, set<tuple<int, int, int, int>>> pena;    //(ペナ数, SPU)
vector<set<tuple<int, int, int, int>>> ac, school, pena;
vector<int> sccnt;
set<int> used;

int main(void) {
    cin >> N >> K;
    SPU.resize(N);
    ac.resize(12);
    school.resize((int)1e5 + 10);
    pena.resize((int)1e6 + 10);
    sccnt.resize(N, 0);
    REP(i, N) {
        int s, p, u;
        //cin >> s >> p >> u;
        scanf("%d%d%d", &s, &p, &u);
        auto tt = make_tuple(s, p, u, i);
        SPU[i] = tt;
        ac[s].emplace(tt);
        school[u].emplace(tt);
        pena[p].emplace(tt);
    }
    while(ac.back().size() == 0) ac.pop_back();
    SORT(SPU);REVERSE(SPU);
    REP(_, K) {
        auto itr = ac.end();
        itr--;
        if ((*itr).size() == 0) {
            ac.erase(itr);
            itr = ac.end();
            itr--;
        }
        if ((*itr).size() == 1) {
            int s,p,u,n;
            FORE(el, (*itr)) {
                //cout << get<3>(el) << endl;
                printf("%d\n", get<3>(el));
                //DEBUG("AC数")
                tie(s, p, u, n) = el;
            }
            sccnt[u]++;
            ac[s].erase(make_tuple(s, p, u, n));
            school[u].erase(make_tuple(s, p, u, n));
            pena[p].erase(make_tuple(s, p, u, n));
        } else {
            //学校からの突破数で比較
            int s, p, u, n;
            int mokuhyonum = INF;
            set<tuple<int, int, int, int>> se;
            FORE(el, (*itr)) {
                tie(s, p, u, n) = el;
                if (mokuhyonum > sccnt[u]) {
                    se.clear(); se.insert(el);
                    mokuhyonum = sccnt[u];
                } else if (mokuhyonum == sccnt[u]) {
                    se.insert(el);
                }
            }
            if (se.size() == 1) {
                FORE(el, se) {
                    //cout << get<3>(el) << endl;
                    printf("%d\n", get<3>(el));
                    //DEBUG("school数")
                    tie(s, p, u, n) = el;
                    sccnt[u]++;
                    ac[s].erase(make_tuple(s, p, u, n));
                    school[u].erase(make_tuple(s, p, u, n));
                    pena[p].erase(make_tuple(s, p, u, n));
                }
            } else {
                //ペナ数で比較
                int s, p, u, n;
                int minpena = INF;
                tuple<int, int, int, int> ans;
                FORE(el, se) {
                    tie(s, p, u, n) = el;
                    if (minpena > p) {
                        minpena = p;
                        ans = el;
                    }
                }
                //cout << get<3>(ans) << endl;
                printf("%d\n", get<3>(ans));
                //DEBUG("pena数")
                tie(s, p, u, n) = ans;
                sccnt[u]++;
                ac[s].erase(make_tuple(s, p, u, n));
                school[u].erase(make_tuple(s, p, u, n));
                pena[p].erase(make_tuple(s, p, u, n));
            }
        }
    }
}
0