codeforces 200 c Football Championship(枚举)

106 篇文章 0 订阅
51 篇文章 0 订阅

这题真的是有点毒,没说数据范围,我怕数太大分两次去二分,但是二元关系分两次二分还是错了。


然后看了qls代码发现,数据范围其实很小。。那直接枚举check就ok了啊


这一场题的顺序全是乱的,第一次打这样的cf,心累。。


代码:

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int point;
    string nam;
    int id;
    int x;
    int y; 
    bool operator < (const node & a)const{
        if(a.point==point)
        {
            if(a.x-a.y==x-y)
            {
                if(x!=a.x)return x>a.x;
                else return nam<a.nam;
            }
            else return x-y>a.x-a.y;
        }
        else return point>a.point;
    }
}t[5], tmp[5];
map<string, int>mp;
int book[6];
int f(int x, int y, int o, int e)
{
    int i;
    for(i=1; i<=4; i++)
    {
        tmp[i]=t[i];
    }
    tmp[o].point+=3;
    tmp[o].x+=x, tmp[e].y+=x;
    tmp[o].y+=y, tmp[e].x+=y;
    sort(tmp+1, tmp+5);
    if(tmp[1].id==o || tmp[2].id==o)return true;
    return false;
}

int main()
{
    string a, b;
    int x, y, t1, t2;
    int cnt=0;
    for(int i=1; i<=5; i++)
    {
        cin>>a>>b;
        scanf("%d:%d", &x, &y);
        if(!mp[a])
        {
            t1=mp[a]=++cnt;
        }
        else t1=mp[a];
        if(!mp[b])
        {
            t2=mp[b]=++cnt;
        }
        else t2=mp[b];
        t[t1].nam=a, t[t2].nam=b;
        t[t1].id=t1, t[t2].id=t2;
        t[t1].x+=x, t[t1].y+=y;
        t[t2].x+=y, t[t2].y+=x;
        if(x>y)t[t1].point+=3;
        else if(x==y)t[t1].point++, t[t2].point++;
        else t[t2].point+=3;
        if(a=="BERLAND" || b=="BERLAND")book[t1]=book[t2]=1;
    }
    /*
    for(int i=1; i<=4; i++)
    {
        printf("%d %d %d %d\n", t[i].id, t[i].point, t[i].x, t[i].y);
    }
    */
    int e, o;
    for(int i=1; i<=4; i++)if(!book[i])e=i;
    for(int i=1; i<=4; i++)if(i==mp["BERLAND"])o=i;

    int l=0, r=0;
    for(int i=0; i<=100; i++)
    {
        for(int j=0; j<i; j++)
        {
            if(f(i, j, o, e) && ((l==r && l==0) ||( (i-j)<(l-r) ||(i-j==(l-r) && j<r))))
            {
                l=i, r=j;
            }
        }
    }
    if(l!=0)printf("%d:%d\n", l, r);
    else printf("IMPOSSIBLE\n");



}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值