A1141 PAT Ranking of Institutions [stl]

在这里插入图片描述
注意最后一个测试点用unordered_map

#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_map>
using namespace std;
const int maxn = 100001;
struct node
{
	string name;
	int endscore;
	double score;
	int count;
};
vector<node>v;
unordered_map<string, int>m;
unordered_map<string, int>Rank;
bool cmp(node a, node b)
{
	if (a.endscore != b.endscore)
		return a.endscore > b.endscore;
	else if (a.count != b.count)
		return a.count < b.count;
	else
		return a.name < b.name;
}
string dazhuanxiao(string s)
{
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] <= 'Z' && s[i]>='A')
		{
			s[i] = s[i] + 32;
		}
	}
	return s;
}
int main()
{
	int n; cin >> n; int cnt = 1;
	string id, name; double score;
	for (int i = 0; i < n; i++)
	{
		cin >> id >> score >> name;
		name = dazhuanxiao(name);
		if (m[name] != 0)
		{
			if (id[0] == 'T')
			{
				v[m[name] - 1].score += score*1.5;
				v[m[name] - 1].count++;
			}
			else if (id[0] == 'A')
			{
				v[m[name] - 1].score += score;
				v[m[name] - 1].count++;
			}
			else
			{
				v[m[name] - 1].score += score/(1.5);
				v[m[name] - 1].count++;
			}
		}
		else {
			if (id[0] == 'T')
			{
				v.push_back(node{ name, 0,score*1.5,1});
			}
			else if (id[0] == 'A')
			{
				v.push_back(node{ name, 0,score,1});
			}
			else
			{
				v.push_back(node{ name, 0,score/(1.5),1});
			}
			m[name] = cnt++;
		}
	}
	for (int i = 0; i < v.size(); i++)
	{
		v[i].endscore = int(v[i].score);
	}
	sort(v.begin(), v.end(), cmp);
	Rank[v[0].name] = 1;
	for (int i = 1; i < v.size(); i++)
	{
		if (v[i].endscore == v[i - 1].endscore)
			Rank[v[i].name] = Rank[v[i - 1].name];
		else
			Rank[v[i].name] = i + 1;
	}
	cout << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{
	
		cout << Rank[v[i].name] << " " << v[i].name << " " << v[i].endscore << " " << v[i].count << endl;
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Interconnected multilayer networks are complex systems that consist of multiple layers of interconnected networks. These networks can represent various social, technological, and biological systems, and their analysis is essential for understanding the dynamics of these systems. Ranking the nodes in interconnected multilayer networks can reveal the most important nodes, which play a crucial role in the functioning of the system. The ranking of nodes in interconnected multilayer networks is a challenging problem because the nodes' importance in one layer may not necessarily correspond to their importance in another layer. Therefore, a comprehensive ranking method should consider the nodes' importance across all layers of the network. Recent research has proposed several ranking methods for interconnected multilayer networks. One of the most promising approaches is the multilayer PageRank algorithm, which extends the classic PageRank algorithm to multilayer networks. This algorithm considers the importance of nodes in all layers of the network and assigns a score to each node based on its influence on the entire system. The ranking of nodes in interconnected multilayer networks has various applications, such as identifying critical nodes in transportation networks, predicting the spread of diseases in social networks, and detecting influential users in online social networks. Furthermore, the ranking of nodes can reveal versatile nodes that play a crucial role in multiple layers of the network, indicating their importance in maintaining the system's functionality. In conclusion, ranking nodes in interconnected multilayer networks is a crucial task that can reveal the most important and versatile nodes in the system. This information can be used to optimize the network's performance, identify critical nodes, and predict the system's behavior under different conditions.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值