結果

問題 No.706 多眼生物の調査
ユーザー 理解した理解した
提出日時 2018-06-30 23:32:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 208,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 16:26:09
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {

    cout << "競技プログラミングとは" << endl;
    
    printf("その1、ACが正義である\n");
    
    cerr << "その2、ACすれば全て許される" << '\n';
    
    perror("プロ");
    
    puts("いいえ");
    
    return 0;
}

// Union Find Tree (Disjoint Set)
// 頂点と頂点が同じグラフ上にあるかを調べる
// unite(頂点、頂点) 頂点と頂点を繋げてグラフにする
// same(頂点、頂点) 2つの頂点が同じグラフかを返す
class UnionFind {
    vector<int> w, h;
    int p;
    int get(int x);
    int next(int a, int b);
    void set(int x, int a);
public:
    UnionFind();
    void unite(int x, int y);
    bool same(int x, int y);
} uf;

void UnionFind::unite(int x, int y) {
    int a = get(x);
    int b = get(y);
    int c = next(a, b);
    set(x, c);
    set(y, c);
}

bool UnionFind::same(int x, int y) {
    int a = get(x);
    int b = get(y);
    return a == b;
}

int UnionFind::get(int x) {
    int a = w[x];
    while (a != h[a]) a = h[a];
    return w[x] = a;
}

int UnionFind::next(int a, int b) {
    if (a && b) return a < b ? h[b] = a : h[a] = b;
    if (a || b) return a | b;
    ++p;
    return h[p] = p;
}

void UnionFind::set(int x, int a) {
    w[x] = a;
}

UnionFind::UnionFind() : w(1000), h(1000), p(0) {
    int n;
    map<int,int> m;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        m[s.size()-2]++;
    }
    int ans = 0;
    for (auto i : m) if (i.second >= m[ans]) ans = i.first;
    cout << ans << endl;
    exit(0);
}
0