uva-10420-排序

根据国家名字统计人数,然后排序

#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include<time.h>
#include <stdlib.h>
using namespace std;

struct Node
{
    string key;
    int total;
};
int main()
{
    freopen("d:\\1.txt","r",stdin);
    int n;
    cin>>n;
    map<string,int>maps;
    string str;
    for(int i = 0; i< n;i++)
    {
        cin>>str;
        int j  = maps[str];
        j++;
        maps[str] = j;
        getline(cin,str);
    }
    map<string,int>::iterator iter;
    for(iter = maps.begin(); iter != maps.end(); ++iter)
    {
        cout<<iter->first<<" "<<iter->second<<endl;
    }

    return 0;
}
时间: 2024-08-24 08:14:42

uva-10420-排序的相关文章

[算法练习] UVA 10420 - List of Conquests?

UVA Online Judge 题目10420 - List of Conquests 问题描述: 题目很简单,给出一个出席宴会的人员列表,包括国籍和姓名(姓名完全没用).统计每个国家有多少人参加,按国家名字典排序输出. 输入格式: 第一行是一个整数n,表示参加人数的个数.接下来是n行,每行第一个单词为国家名称,后面为姓名. 输出格式: 每行包括国家名称和出席人数,将国家名称按字典排序输出. 示例输入: 3Spain Donna ElviraEngland Jane DoeSpain Donn

UVa 10420 List of Conquests

题意就是有N个pl妹子,然后每行第一个单词是妹子的国籍,后面是妹子的名字. 你的任务就是统计相同国籍妹子的个数,然后按字母表顺序输出. 我首先把所有的国籍都读入,然后用qsort()按字母表顺序排序. List of ConquestsInput: standard inputOutput: standard outputTime Limit: 2 seconds In Act I, Leporello is telling Donna Elviraabout his master's long

[2016-01-19][UVA][10420]

时间:2016-01-19  15:16:22  星期二 题目编号:UVA 10420 题目大意:题目 给出 某人, 某个地方 某个爱人,         输出每个地方有几个爱人... 方法:直接对输入数据中的地方进行计数即可, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 #inclu

UVa 11039 (排序+贪心) Building designing

白书上的例题比较难,认真理解样例代码有助于提高自己 后面的练习题相对简单,独立思考解决问题,增强信心 题意:n个绝对值各不相同的非0整数,选出尽量多的数排成序列,使得该序列正负交错且绝对值递增. 解法:先按绝对值从小到大排序,然后第一个数先入队,然后依次比较后面的数,如果和队尾的数符号相反则入队,直到所有的数遍历完为止 这里用了异或运算,因为这里面没有0,所谓符号相同的两个数异或值为正,不同符号的数异或值为负 1 //#define LOCAL 2 #include <algorithm> 3

UVa 1611 (排序 模拟) Crane

假设数字1~i-1已经全部归位,则第i到第n个数为无序区间. 如果i在无序区间的前半段,那么直接将i换到第i个位置上. 否则先将i换到无序区间的前半段,再将i归位.这样每个数最多操作两次即可归位. 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxn = 10000 + 10; 5 int a[maxn]; 6 vector<pair<int, int> > ans; 7 8 void

小白书练习题5.5.3 排序检索类、

UVA 340 Master-Mind Hints 题意:猜数字游戏,给n个数的序列给你.接下来一行是答案序列.剩下的都是猜测序列.对于每一个猜测序列,统计有多少个数字相同并且位置相同.有多少数字相同位置不同.每一个数字只能用一次. 思路:直接统计可以求出数字相同并且位置相同的哪一些数.在此过程中我加了一个标记数组.标记那些用过的数的位置为1,没用过为0:然后枚举猜测中哪些没用过的数字.去答案序列中找.当数字相等并且答案行中那个数也没用过时.计数加1: 1 #include<cstdio> 2

Volume 1. Elementary Problem Solving :: Sorting/SearchingUva 340,10420,10474,152,299,120,156,400,755

刘汝佳 算法入门 第一版 Uva题目集合(四) Uva 340 #include<stdio.h> #include<string.h> int h[1001][2],g[1001]={0}; int n,m=0,i,j,k,a,b,o; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","

uva 10474 Where is the Marble?(排序)

uva 10474 Where is the Marble? Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the numbers written on them.

UVA - 10305 - Ordering Tasks (拓扑排序!)

UVA - 10305 Ordering Tasks Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Status Description Problem F Ordering Tasks Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB John has n task

UVa 10152 龟壳排序

思路:先读入的一列是原始串,后读入的一列是目标串.最少操作次数的方式是,从下到上,只对原始串进行删除而不放到最上面能得到的目标串的以最下元素开头的最长子串,然后将目标串剩余的那些按序放在最上方,即按由下到上的顺序输出即可. Code: //#define LOCAL #include<stdio.h> #include<stdlib.h> #include<string.h> char name[210][90]; char target[210][90]; //cha