sgu 405. Totalizator 简单模拟

本文介绍了一个基于预测足球比赛结果来计算参与者积分的程序。该程序读取比赛实际结果和参与者预测的数据,通过一系列匹配规则计算每个参与者的得分。参与者可以通过准确预测比分、胜者等获得不同分数。

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

405. Totalizator
Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

Some time ago Vasya was cleaning up the garret. After the hours of hard work he suddenly found the notes of the totalizator, which his grandfather had organised during the XII Berland football championship. It followed from the notes that each participant of the totalizator made his prediction about the result of every match (the result of the match is an ordered pair of numbers  — number of goals scored by the first team and number of goals scored by the second team). Each prediction is such pair of numbers too. Every participant got score for the every prediction he made by the following rules:
  • if he guesses the winner (or a tie), his score is inscreased by 2.
  • if he guesses the difference between the number of goals scored by the first and the second team, his score is inscreased by 3.
  • if he guesses the number of goals scored by the first team, his score is increased by 1.
  • if he guesses the number of goals scored by the second team, his score is increased by 1.
So, if the participant guesses the exact result of the match, he gets 7 points. Or, for example, if he guesses only the winner and the difference, he scores 5 points. Unfortunately, the list with the results of the totalizator was lost. But Vasya wants to know how many scores each totalizator participant got. Help him to find the scores. 
Input
The first line contains two integer numbers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of participants and the number of games. After it m blocks of n+1 lines follow. Each block corresponds to one match. The first line of each block contains two integer numbers a,b (0 ≤ a,b ≤ 10) — numbers of goals scored by the first and the second team. Other n lines of each block contain predictions of all participants in the same format, the i-th line is a prediction of the i-th participant. 
Output
Output n numbers separated by spaces — scores of participants. The i-th number should be the score of the i-th participant. Participants are numbered from 1 to n as their predictions are given in the input. 
Example(s)
sample input
sample output
1 2
3 2
2 1
0 2
0 0
6

sample input
sample output
2 3
4 3
2 2
2 0
0 0
1 1
1 0
5 0
3 0
2 0
8 6


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int ans[110];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        for(int j=1;j<=n;j++){
            int a,b;
            scanf("%d%d",&a,&b);
            if(x==a)ans[j]++;
            if(y==b)ans[j]++;
            if(x-y==a-b)ans[j]+=3;
            if(x==y&&a==b)ans[j]+=2;
            if((x-y)*(a-b)>0)ans[j]+=2;
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d ",ans[i]);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值