QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#295407#7514. Clique Challengesofija6WA 17ms3656kbC++231.7kb2023-12-31 05:46:102023-12-31 05:46:10

Judging History

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

  • [2023-12-31 05:46:10]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3656kb
  • [2023-12-31 05:46:10]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define MAXN 1010
using namespace std;
set<ll> G[MAXN];
bool act[MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,m,u,v;
    cin >> n >> m;
    for (ll i=1;i<=m;i++)
    {
        cin >> u >> v;
        G[u].insert(v);
        G[v].insert(u);
    }
    for (ll i=1;i<=n;i++)
        act[i]=true;
    ll cnt=n,ans=0;
    while (cnt)
    {
        vector<pair<ll,ll> > deg;
        for (ll i=1;i<=n;i++)
        {
            if (act[i])
            {
                ll c=0;
                for (ll next : G[i])
                    c+=act[next];
                deg.push_back({c,i});
            }
        }
        sort(deg.begin(),deg.end());
        u=deg[0].second;
        act[u]=false;
        cnt--;
        vector<ll> w,l,r;
        for (ll next : G[u])
        {
            if (act[next])
                w.push_back(next);
        }
        for (ll i=0;i<w.size()/2;i++)
            l.push_back(w[i]);
        for (ll i=w.size()/2;i<w.size();i++)
            r.push_back(w[i]);
        for (ll i=0;i<(1<<l.size());i++)
        {
            ll mask=(1<<r.size())-1;
            for (ll j=0;j<l.size();j++)
            {
                if ((1<<j)&i)
                {
                    for (ll k=0;k<r.size();k++)
                    {
                        if ((1<<k)&mask && !G[l[j]].count(r[k]))
                            mask^=(1<<k);
                    }
                }
            }
            ll cnt=0;
            for (ll j=0;j<r.size();j++)
                cnt+=(((1<<j)&mask)!=0);
            ans+=(1<<cnt);
        }
    }
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: -100
Wrong Answer
time: 17ms
memory: 3580kb

input:

1000 100
446 789
167 547
254 777
777 185
33 446
777 847
185 877
757 167
72 383
847 446
254 478
959 185
757 446
847 959
959 167
757 847
747 757
446 167
989 757
547 777
33 747
33 254
254 843
33 547
446 980
877 205
185 72
980 959
33 205
877 757
33 847
478 843
757 478
167 877
72 789
877 959
980 478
167 ...

output:

1512

result:

wrong answer 1st lines differ - expected: '1373', found: '1512'