http://www.codeforces.com/contest/75/problem/B
************************************************************************************************
就是一个简单的模拟题,人名按分数从大到小排,如果分数相同就按字典序排,输出不包括自己,所以每次读入处理时都忽略自己。可是我的code怎么都wa???求解!
当初没注意到题目是问跟自己有关系的,没关系的优先级为0!
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <time.h>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <cstdlib>
#include <limits.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
#define LL long long
#define MIN INT_MIN
#define MAX INT_MAX
#define PI acos(-1.0)
#define FRE freopen("input.txt","r",stdin)
#define FF freopen("output.txt","w",stdout)
#define N 205
map<string,int> mp;
string me;
struct node{
string str;
int v;
}p[N];
void gao (string st) {
int len = st.length();
int i,j;
string a,b;
a.clear();b.clear();
for (i = 0; i < len; i++) {
if (st[i] == ' ')break;
a += st[i];
}//
i++;
int v;
if (st[i] == 'p') {
v = 15;
for (i = i + 10; i < len; i++) {
if (st[i] == '\'') break;
b += st[i];
}
}
if (st[i] == 'c') {
v = 10;
for (i = i + 13; i < len; i++) {
if (st[i] == '\'') break;
b += st[i];
}
}
if (st[i] == 'l') {
v = 5;
for (i = i + 6; i < len; i++) {
if (st[i] == '\'') break;
b += st[i];
}
}//cout<<b<<endl;
if (a == me || b == me) {
if (b == me)
mp[a] += v;
if (a == me)
mp[b] += v;
}
if (a != me && b != me) {
if (mp.find(a) == mp.end())
mp[a] = 0;
if (mp.find(b) == mp.end())
mp[b] = 0;
}
}
bool cmp (node a, node b) {
if (a.v == b.v) return a.str < b.str;
return a.v > b.v;
}
int main () {
int i,j;
int n;
cin>>me>>n;
string str;
getchar();
for (i = 0; i < n; i++) {
getline(cin,str);//cout<<str<<"!"<<endl;
gao(str);
}
map<string,int> ::iterator it;
int cnt = 0;
for (it = mp.begin(); it != mp.end(); it++) {
p[cnt].str = it->first;
p[cnt].v = it->second;
cnt++;
}
sort(p,p+cnt,cmp);
for (i = 0; i < cnt; i++) {
cout<<p[i].str<<endl;
}
return 0;
}