結果

問題 No.2680 研究室配属
ユーザー bortikbortik
提出日時 2024-03-20 21:25:10
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 2,364 bytes
コンパイル時間 4,396 ms
コンパイル使用メモリ 273,912 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-03-20 21:25:18
合計ジャッジ時間 6,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 13 ms
6,676 KB
testcase_11 AC 12 ms
6,676 KB
testcase_12 AC 16 ms
6,676 KB
testcase_13 AC 13 ms
6,676 KB
testcase_14 AC 18 ms
6,676 KB
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 37 ms
6,676 KB
testcase_17 AC 9 ms
6,676 KB
testcase_18 AC 25 ms
6,676 KB
testcase_19 AC 48 ms
6,676 KB
testcase_20 AC 40 ms
6,676 KB
testcase_21 AC 5 ms
6,676 KB
testcase_22 AC 30 ms
6,676 KB
testcase_23 AC 81 ms
7,552 KB
testcase_24 AC 79 ms
7,552 KB
testcase_25 AC 85 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template<typename T>
bool chmax(T& a, const T& b) {
    bool res = a < b;
    a = max(a, b);
    return res;
}
template<typename T>
bool chmin(T& a, const T& b){
    bool res = a > b;
    a = min(a, b);
    return res;
}

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

const int inf = 1000000009;
const ll linf = 4000000000000000009;


// https://trap.jp/post/1224/
template<class... T>
void input(T&... a){
    (cin >> ... >> a);
}

void print(){
    cout << '\n';
}
template<class T, class... Ts>
void print(const T& a, const Ts&... b){
    cout << a;
    (cout << ... << (cout << ' ', b));
    cout << '\n';
}

#define rep1(a)          for(int i = 0; i < a; i++)
#define rep2(i, a)       for(int i = 0; i < a; i++)
#define rep3(i, a, b)    for(int i = a; i < b; i++)
#define rep4(i, a, b, c) for(int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)


#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
//---------------------------------


void solve(){
    int n,m; input(n, m);
    vi a(m, 0); rep(i,m) input(a[i]);
    vector<vi> t(n, vi(m));
    rep(i,n) rep(j,m) input(t[i][j]);
    vector<vector<int>> lab(n);
    vector<bool> over(n, false);
    rep(j,0,m){
        rep(i, n){
            if(!over[i]){
                lab[t[i][j]].push_back(i);
                over[i] = true;
            }
        }
        rep(i, m){
            while(lab[i].size() > a[i]){
                over[lab[i].back()] = false;
                lab[i].pop_back();
            }
        }
    }
    vi ans(n);
    rep(j, m){
        for(int student: lab[j]){
            ans[student] = j;
        }
    }
    rep(i, n) cout << ans[i] << ' ';
}


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

    int t = 1;
    //cin >> t;
    rep(i,0,t) solve();
}
0