7-1 Fake News (20 分)

本文介绍了一种用于评估新闻网站发布假新闻可能性的算法。通过对比不同新闻网站对同一事件报道的观点差异,该算法能找出最可能发布假新闻的网站。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 <iostream>
#include <map>
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<int, int> 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;
} 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值