結果
問題 | No.706 多眼生物の調査 |
ユーザー |
![]() |
提出日時 | 2018-06-30 23:32:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,613 bytes |
コンパイル時間 | 1,765 ms |
コンパイル使用メモリ | 203,656 KB |
最終ジャッジ日時 | 2025-01-06 11:48:16 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 |
ソースコード
#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);}