結果
| 問題 |
No.706 多眼生物の調査
|
| コンテスト | |
| ユーザー |
ugis_prog
|
| 提出日時 | 2018-07-07 20:37:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 962 bytes |
| コンパイル時間 | 522 ms |
| コンパイル使用メモリ | 76,084 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 05:34:42 |
| 合計ジャッジ時間 | 1,146 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:27: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
12 | #define put(n) cout<<(n)<<"\n"
| ^~~~
main.cpp:39:9: note: ‘ans’ was declared here
39 | 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);
}
ugis_prog