---
# System prepended metadata

title: List of Conquests(UVA10420)
tags: [CPE一顆星必考題]

---

# List of Conquests(UVA10420)
## [程式繳交區](https://hackmd.io/@Renektonn/rypo9qcvJl/edit)
## 題目
[點我](https://onlinejudge.org/external/104/10420.pdf)

## 解題系統 
[UVA](https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1361)
[ZJ](https://zerojudge.tw/ShowProblem?problemid=a743)

## 演算法
```
1.宣告map<string,int>mp,輸入n
2.重複n次
2.1.輸入字串country,再輸入一行字串name
2.2.mp[country]++
3.根據字典序輸出mp->first mp->second
```

## 程式碼
```cpp=
#include <bits/stdc++.h>
#define int long long int
using namespace std;

signed main(){	
    map <string, int> mp;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string name, garbage;
        cin >> name;
        getline(cin, garbage);
        mp[name] = mp[name] + 1;
    }
    for (auto it = mp.begin(); it != mp.end(); it++) {
        cout << (*it).first << " " << (*it).second << endl;
    }

    return 0;
}
```


