【已解決】codeforces#67 B – Facetook Priority Wall

來源:互聯網
上載者:User

 

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 205map<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;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.