栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

7-1 Fake News (20 分)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

7-1 Fake News (20 分)

7-1 Fake News (20 分)

No news site is unbiased, but some do a better job of trying to balance facts and opinions. The term fake news means “news articles that are intentionally and verifiably false” designed to manipulate people’s perceptions of real facts, events, and statements. (Quoted from https://www.cits.ucsb.edu/fake-news/what-is-fake-news)

To tell if a news media is more or less likely to be fake, you can keep an eye on several different sites to see how they report on the same important events. The algorithm works as the following:

  • Select N news sites.
  • For each important event, scan every site and represent each different opinion by a distinct integer.
  • Define the likelihood of a site i being fake news by Fi=ni/N, where ni is the
    number of sites that have different opinions than site i.
  • Find the news site(s) which is(are) the most likely to report fake news.
  • Foreach news site, count the number of times it was the most likely to be fake, and find the one that is in most of the cases the most likely to be fake.

Input Specification:
Each input file contains one test case. For each case, the first line contains two positive numbers: N (≤104) which is the number of news sites, and M (≤100) which is the number of events. Then M lines follow, each describes the reports of the sites in the format:

R1 R2…RN
where Riis an integer in the range [−104,104], and reprensts the opinion of site i.

Output Specification:
For each test case, print in a line the index of the site which is in most of the cases the most likely to be fake. The answer is guaranteed to be unique.

Sample Input:

4 6
4 2 7 7
1 1 1 3
2 9 9 5
-1 -1 -1 -1
-2 2 -2 2
1 1 3 4

Sample Output:

4

Hint:

The Fi’s for each event are the following:
Event 1: 3/4 3/4 2/4 2/4 --> 1 and 2 are the most likely
Event 2: 1/4 1/4 1/4 3/4 --> 4 is the most likely
Event 3: 3/4 2/4 2/4 3/4 --> 1 and 4 are the most likely
Event 4: 0 0 0 0 --> all are the most likely
Event 5: 2/4 2/4 2/4 2/4 --> all are the most likely
Event 6: 2/4 2/4 3/4 3/4 --> 3 and 4 are the most likely
Hence site 4 is the one since it has the highest likelihood for 5 times, while other sites only have 3 or 4 times.

看懂题目就行,统计每组数据出现次数,按比例标记就行。

#include 
#include 
using namespace std;
int a[10010], vis[10010];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, x;
	cin >> n >> m;
	while(m--) {
		int maxn = 0;
		map b;
		for(int i = 0; i < n; ++i){
			cin >> a[i];
			b[a[i]]++;
		}
		for(int i = 0; i < n; ++i) {
			maxn = max(maxn, n - b[a[i]]);
		}
		for(int i = 0; i < n; ++i) {
			if(n - b[a[i]] == maxn)
				vis[i + 1]++;
		}
	}
	int ans = 1;
	for(int i = 2; i <= n; ++i){
		if(vis[i] > vis[ans])
			ans = i;
	}
	cout << ans;
} 
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/690241.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号