結果
| 問題 | 
                            No.349 干支の置き物
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-02-03 00:17:58 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 935 bytes | 
| コンパイル時間 | 1,635 ms | 
| コンパイル使用メモリ | 175,636 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 01:46:59 | 
| 合計ジャッジ時間 | 2,600 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 15 WA * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(mp[s] == 0) mp[s] = 1;
        else mp[s]++;
    }
    string used;
    for(auto& p: mp){
        if(p.second != 0) used = p.first;
        for(auto& q: mp){
            if(q.first != used && q.second > 0){
                q.second--;
                used = q.first;
            }
        }
    }
    for(int i=0; i<n; i++){
        for(auto& p: mp){
            if(p.second != 0) used = p.first;
            for(auto& q: mp){
                if(q.first != used && q.second > 0){
                    q.second--;
                    used = q.first;
                }
            }
        }
    }
    bool allzero = true;
    for(auto p: mp) if(p.second != 0) allzero = false;
    if(allzero) printf("YES\n");
    else printf("NO\n");
    return 0;
}