結果
問題 | No.706 多眼生物の調査 |
ユーザー | ugis_prog |
提出日時 | 2018-07-07 20:37:37 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 76,632 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-18 14:49:26 |
合計ジャッジ時間 | 1,481 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 4 ms
4,380 KB |
testcase_05 | AC | 11 ms
4,380 KB |
testcase_06 | AC | 28 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:27: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] #define put(n) cout<<(n)<<"\n" ^~~~ main.cpp:39:9: note: ‘ans’ was declared here int ans; ^~~
ソースコード
#include<algorithm> #include<iostream> #include<vector> #include<string> #include<map> #include<stack> #include<queue> using namespace std; typedef long long i64; #define put(n) cout<<(n)<<"\n" #define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++) #define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--) #define all(v) (v).begin() , (v).end() #define rall(v) (v).rbegin() , (v).rend() int main(){ int N; cin>>N; vector<string> monster(N); FOR(i,0,N) cin>>monster[i]; map<int,int> mp; FOR(i,0,1001) mp[i] = 0; FOR(i,0,N){ int count = 0; FOR(j,0,monster[i].size()){ string s = monster[i]; if(s[j] == '^') count++; } mp[count]++; } int ans; int max = -1e9; for(auto v : mp){ if(max < v.second){ max = v.second; ans = v.first; } else if(max == v.second) ans = std::max(ans,v.first); } put(ans); }