結果

問題 No.706 多眼生物の調査
コンテスト
ユーザー ugis_prog
提出日時 2018-07-07 20:37:37
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 962 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 561 ms
コンパイル使用メモリ 98,436 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-26 12:30:51
合計ジャッジ時間 1,154 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from main.cpp:1:
In function 'const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:46:48:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:263:7: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  263 |       if (__a < __b)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:39:9: note: 'ans' was declared here
   39 |     int ans;
      |         ^~~

ソースコード

diff #
raw source code

#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);
    
}
0