7-1 Fake News (20 分)

7-1 Fake News (20 分),第1张

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5690744.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存