Submission #7105174


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long N, long long M, std::vector<std::vector<long long>> A){
    unordered_set<LL> masked_sports;
    VI pos(N, 0);
    LL min_max_count = N;
    while (SZ(masked_sports) < M) {
        unordered_map<LL, LL> counts;
        REP(i, N) {
            while (masked_sports.count(A[i][pos[i]]) > 0) {
                pos[i]++;
            }
            counts[A[i][pos[i]]]++;
        }
        LL max_count = 0, max_count_sport;
        EACH(c, counts) {
            if (max_count < c.second) {
                max_count_sport = c.first;
                max_count = c.second;
            }
        }
        min_max_count = min(min_max_count, max_count);
        masked_sports.insert(max_count_sport);
    }
    cout << min_max_count << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, std::move(A));
    return 0;
}

Submission Info

Submission Time
Task B - Sports Festival
User yetnone
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1814 Byte
Status AC
Exec Time 16 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:46:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&N);
                     ^
./Main.cpp:48:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&M);
                     ^
./Main.cpp:52:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld",&A[i][j]);
                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 2 ms 256 KB
subtask_1_04.txt AC 2 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 5 ms 512 KB
subtask_1_07.txt AC 5 ms 512 KB
subtask_1_08.txt AC 3 ms 384 KB
subtask_1_09.txt AC 1 ms 256 KB
subtask_1_10.txt AC 3 ms 384 KB
subtask_1_11.txt AC 4 ms 384 KB
subtask_1_12.txt AC 2 ms 256 KB
subtask_1_13.txt AC 6 ms 512 KB
subtask_1_14.txt AC 15 ms 1024 KB
subtask_1_15.txt AC 13 ms 1024 KB
subtask_1_16.txt AC 16 ms 1024 KB
subtask_1_17.txt AC 15 ms 1024 KB
subtask_1_18.txt AC 13 ms 1024 KB