Skip to content

E02092: Grandpa is Famous

implementation, http://cs101.openjudge.cn/practice/02092/

【黄宇曦 地球与空间科学学院】思路:比较简单,感觉乱搞也能过。

cpp
#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
using pii = pair<int, int>;
using vi = vector<int>;
using usi = unordered_set<int>;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m;
    while (cin >> n >> m) {
        if (!n && !m)
            return 0;
        vi cnt(10005, 0);
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                int t;
                cin >> t;
                cnt[t]++;
            }
        }
        auto tmp = cnt;
        sort(all(tmp), [](int a, int b) { return a > b; });

        for (int i = 1; i <= 10000; i++) {
            if (cnt[i] == tmp[1])
                cout << i << ' ';
        }
        cout << '\n';
    }
    return 0;
}