結果

問題 No.706 多眼生物の調査
ユーザー MayimgMayimg
提出日時 2019-01-02 13:46:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 173,200 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 21:15:05
合計ジャッジ時間 2,387 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:17: warning: 'mode' may be used uninitialized [-Wmaybe-uninitialized]
   27 |         cout << mode << endl;
      |                 ^~~~
main.cpp:20:22: note: 'mode' was declared here
   20 |         int num = 0, mode;
      |                      ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	map<int, int> mp;
	int n;
	cin >> n;
	while(n--) {
		string s;
		cin >> s;
		int cnt = 0;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == '^') cnt++;
		}
		mp[cnt]++;
	}
	int num = 0, mode;
	for(auto i : mp) {
		if(i.second >= num) {
			num = i.second;
			mode = i.first;
		}
	}
	cout << mode << endl;
	return 0;
}
0