QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613787#9347. Competition in Swiss-systemYour-SunWA 377ms4024kbC++203.5kb2024-10-05 14:45:122024-10-05 14:45:22

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 14:45:22]
  • 评测
  • 测评结果:WA
  • 用时:377ms
  • 内存:4024kb
  • [2024-10-05 14:45:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define endl '\n'

struct node
{
    ll mp, gp;
    ll num_game;
    pll mw, gw;
    vector<int> oppenent;
    node()
    {
        mp=gp=num_game=0;
        mw=gw=make_pair(0,0);
    }
};

void reduction(pll &u)
{
    auto &[x,y]=u;
    ll t=__gcd(x,y);
    x/=t, y/=t;
}

pll operator+=(pll &a, const pll &b)
{
    pll res;
    auto [x1,y1]=a;
    auto[x2,y2]=b;
    res.second=lcm(y1,y2);
    res.first=x1*res.second/y1 + x2*res.second/y2;
    reduction(res);
    a=res;
    return a;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<node> a(n+1);
    int i,j,k;
    vector<int> b(m+1);
    for(i=1;i<=m;i++)
        cin>>b[i];
    
    auto check=[](pll u)
    {
        auto [x,y]=u;
        if(3*x<=y)
            x=1, y=3;
        return make_pair(x,y);
    };
    
    auto fun_omw=[&](node u)->pll
    {
        if(!u.oppenent.size())
            return make_pair(1,3);
        int f=0;
        pll res;
        for(auto idx:u.oppenent)
        {
            if(!f)
            {
                f=1;
                res=check(a[idx].mw);
                continue;
            }
            res+=check(a[idx].mw);
        }
        res.second*=u.oppenent.size();
        reduction(res);
        return res;
    };
    auto fun_gw=[&](pll u)
    {
        auto [x,y]=u;
        ll t=__gcd(x,y);
        x/=t, y/=t;
        pll res=make_pair(x,y);
        return check(res);
    };
    auto fun_ogw=[&](node u)->pll
    {
        if(!u.oppenent.size())
            return make_pair(1,3);
        int f=0;
        pll res;
        for(auto idx:u.oppenent)
        {
            if(!f)
            {
                f=1;
                res=check(a[idx].gw);
                continue;
            }
            res+=check(a[idx].gw);
        }
        res.second*=u.oppenent.size();
        reduction(res);
        return res;
    };

    for(int round=1;round<=m;round++)
    {
        cout<<"Round "<<round<<endl;

        vector<int> vis(n+1);
        for(i=0;i<b[round];i++)
        {
            int p1,p2,w1,w2,d;
            cin>>p1>>p2>>w1>>w2>>d;
            if(w1>w2)   a[p1].mp+=3;
            if(w1<w2)   a[p2].mp+=3;
            if(w1==w2)  a[p1].mp++, a[p2].mp++;
            a[p1].gp+=w1*3+d, a[p2].gp+=w2*3+d;
            a[p1].oppenent.push_back(p2);
            a[p2].oppenent.push_back(p1);
            a[p1].num_game+=w1+w2+d;
            a[p2].num_game+=w1+w2+d;
            vis[p1]=vis[p2]=1;
        }
        for(i=1;i<=n;i++)
        {
            if(!vis[i])
                a[i].mp+=3, a[i].gp+=6, a[i].num_game+=2;
            a[i].mw=make_pair(a[i].mp, round*3);
            a[i].gw=make_pair(a[i].gp, a[i].num_game*3);
        }
        
        for(i=1;i<=n;i++)
        {
            cout<<a[i].mp<<' ';                                 // mp

            pll res_omw=fun_omw(a[i]);
            cout<<res_omw.first<<'/'<<res_omw.second<<' ';      // omw
            
            pll res_gw=fun_gw(a[i].gw);
            cout<<res_gw.first<<'/'<<res_gw.second<<' ';      // gw
            
            pll res_ogw=fun_ogw(a[i]);
            cout<<res_ogw.first<<'/'<<res_ogw.second;      // ogw
            cout<<endl;
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)
        solve();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3556kb

input:

2
2 3
0 1 1
1 2 2 0 1
1 2 1 1 1
3 2
1 1
1 2 0 2 0
2 3 2 0 0

output:

Round 1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
Round 2
6 1/2 13/15 7/15
3 1/1 7/15 13/15
Round 3
7 4/9 17/24 11/24
4 7/9 11/24 17/24
Round 1
0 1/1 1/3 1/1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
Round 2
3 1/1 1/2 1/1
6 1/2 1/1 1/2
3 1/1 1/2 1/1

result:

ok 17 lines

Test #2:

score: 0
Accepted
time: 177ms
memory: 3644kb

input:

3215
26 4
13 13 11 13
19 9 2 1 0
17 1 0 2 0
25 15 2 0 0
14 5 1 2 0
20 2 0 2 0
10 21 2 1 0
3 16 0 2 0
8 6 2 1 0
26 24 1 2 0
22 18 0 1 2
7 11 2 0 0
13 4 1 2 0
23 12 0 2 0
18 20 1 2 0
3 5 2 1 0
25 24 1 2 0
7 9 1 2 0
11 14 2 0 0
8 17 1 1 1
23 12 2 0 0
19 26 1 2 0
2 15 0 2 0
4 13 2 1 0
16 10 0 2 0
6 21 0...

output:

Round 1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 2/3 1/3
3 1/3 2/3 1/3
0 1/1 1/3 2/3
3 1/3 1/1 1/3
3 1/3 2/3 1/3
0 1/1 1/3 2/3
3 1/3 2/3 1/3
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 2/3
0 1/1 1/3 2/3
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 5/9 1/3
3 1/3 2/3 1/3
0 1/1 1/3 1/1
0 1/1 1/3 2/...

result:

ok 312175 lines

Test #3:

score: 0
Accepted
time: 145ms
memory: 3868kb

input:

602
67 7
7 9 4 9 10 6 10
18 36 2 0 0
14 63 1 2 0
20 2 2 1 0
45 17 1 1 1
16 24 0 2 0
15 12 1 1 1
59 38 1 2 0
25 3 1 2 0
19 6 0 2 0
26 51 0 2 0
50 66 1 1 1
4 27 1 2 0
12 5 0 1 2
41 2 1 1 1
54 1 1 1 1
28 29 0 2 0
38 64 1 1 1
46 63 1 1 1
25 44 2 1 0
30 11 0 2 0
60 38 2 0 0
11 39 1 1 1
23 8 1 1 1
2 29 0 ...

output:

Round 1
3 1/3 1/1 1/3
0 1/1 1/3 2/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 1/1 1/3
1 1/3 4/9 4/9
3 1/3 1/1 1/3
0 1/1 1/3 2/3
1 1/3 4/9 4/9
0 1/1 1/3 1/1
1 1/3 4/9 4/9
3 1/3 1/1 1/3
3 1/3 1/1 1/3
3 1/3 2/3 1/3
3 1/3 1/1 1/...

result:

ok 303032 lines

Test #4:

score: -100
Wrong Answer
time: 377ms
memory: 4024kb

input:

36
818 12
399 400 403 401 400 400 399 402 402 403 399 402
484 426 2 1 0
304 580 0 2 0
261 281 2 0 0
739 204 2 0 0
53 297 1 2 0
430 258 2 1 0
521 763 1 2 0
718 526 2 0 0
611 247 1 2 0
644 453 0 2 0
283 91 2 1 0
695 223 1 2 0
583 679 2 1 0
538 396 1 1 1
582 766 1 2 0
146 136 1 2 0
799 77 1 2 0
530 787...

output:

Round 1
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 2/3 1/3
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 2/3 1/3
3 1/3 2/3 1/3
3 1/3 2/3 1/3
0 1/1 1/3 7/9
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 1/1
0 1/1 1/3 1/1
3 1/3 2/3 1/3
0 1/1 1/3 2/3
0 1/1 1/3 2/3
3 1/3 2/3 1/3
0 1/1 1/3 2/3
0 1/1 1/3 1/1
3 1/3 1/1 1/...

result:

wrong answer 9044th lines differ - expected: '15 25/48 12/29 3952849055/7552980864', found: '15 25/48 12/29 -954351187/3776490432'