考试后半段舍友来收拾屋子,不知道满没满 后补的代码…
#include <cstring>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#define ll long long
#define PII pair<int, int>
#define PSI pair<string, int>
#define MSI map<string,int>
#define TLE ios::sync_with_stdio(0),cin.tie(0)
#define mod 1000000007
const int INF = 0x3f3f3f3f;
using namespace std;
struct student {
string name;
int num;
}stu[1005];
bool cmp(student a, student b) {
return a.num > b.num;
}
int main() {
TLE;
MSI mp;
string name, tt;
cin >> name;
int n;
cin >> n; getline(cin, tt);
while (n--) {
string str, name1, name2;
getline(cin, str);
int flag = 1, t2, t1 = str.find_first_of(' ');
int w;
if (str[t1 + 1] == 'r') w = 15;
else if (str[t1 + 1] == 'c') w = 10;
else if (str[t1 + 1] == 'l') w = 5;
// cout << str[t1 + 1] << " t1: " << t1 << endl;
name1 = str.substr(0, t1);
t2 = str.find_last_of("'");
for (int i = t2;; i--) if (str[i] == ' ') {
name2 = str.substr(i+1, t2 - 1 - i);
break;
}
if (name1 == name) {
mp[name2] += w;
// cout << "1" << endl;
}
else if (name2 == name) {
mp[name1] += w;
// cout << "2" << " w: "<<w<<" "<<mp[name1]<<endl;
}
else {
if (mp[name1] == 0) mp[name1] = 0;
if (mp[name2] == 0) mp[name2] = 0;
}
// cout << name1 << " " << name2 << endl;
}
MSI::iterator iter = mp.begin();
int i = 0;
while (iter != mp.end()) {
stu[i].name = iter->first;
stu[i++].num = iter->second;
iter++;
}
sort(stu,stu+i-1,cmp);
for (int j = 0; j < i; j++) {
cout<<stu[j].name<<endl;
}
//for (int j = 0; j < i; j++) {
// cout << stu[j].num << endl;
//}
}
/*
yuan
3
cong reply to yuan's message
yuan comment on jack's circle
cong like yuan's circle
*/
/*
circle
3
comment comment on circle's circle
comment comment on circles's circle
nan reply to nang's message
*/
/*
jiangnan
1
comment comment on jiangnan's circle
*/