hdu 5131 Song Jiang's rank list 2014ACM/ICPC亚洲区广州站-重现赛

又开始刷水题找自信了==,直接O(NM)暴力。

#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<ctype.h>
#include<map>
#include<time.h>
#include<bitset>
using namespace std;
//hdu 5131

const int maxn=210;
int N;
int M;
pair<string,int>s[maxn];
string q[maxn];
bool cmp(pair<string,int>a, pair<string,int>b)
{
    if(a.second==b.second)
    {
        return a.first<b.first;
    }
    else
    {
        return a.second>b.second;
    }
}
int main()
{
    freopen("input.txt","r",stdin);
    //freopen("data.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    while(true)
    {
        scanf("%d",&N);
        if(N==0)
        {
            break;
        }
        for(int i=0;i<N;i++)
        {
            cin>>s[i].first>>s[i].second;

        }
        scanf("%d",&M);
        for(int i=0;i<M;i++)
        {
            cin>>q[i];
        }
        sort(s,s+N,cmp);
        for(int i=0;i<N;i++)
        {
            cout<<s[i].first<<" "<<s[i].second<<endl;
        }
        for(int i=0;i<M;i++)
        {
            pair<string,int>tmp;
            for(int j=0;j<M;j++)
            {
                if(s[j].first==q[i])
                {
                    tmp=s[j];
                    break;
                }
            }
            int cntmaj=1;
            int cntmin=1;
            for(int j=0;j<N;j++)
            {
                if(tmp.second<s[j].second)
                {
                    cntmaj++;
                }
                if(tmp.second==s[j].second&&s[j].first<tmp.first)
                {
                    cntmin++;
                }
            }
            if(cntmin==1)
            {
                printf("%d\n",cntmaj);
            }
            else
            {
                printf("%d %d\n",cntmaj,cntmin);
            }
        }
    }
    return 0;
}






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值