QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305838 | #7514. Clique Challenge | ELDRVD | WA | 3ms | 43576kb | C++14 | 1.9kb | 2024-01-16 03:33:36 | 2024-01-16 03:33:36 |
Judging History
answer
//https://qoj.ac/problem/7514
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define INF 1e15
#define MOD 1000000007
#define endl "\n"
#define all(data) data.begin(),data.end()
#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()
#define MAXN 1007
#define MAXN2 5000007
#define MAXM 107
ll dp[MAXN2],edges[MAXM],dd,deg[MAXN],mm[MAXM],f[MAXN2],rez,lg[MAXN2];
bool vis[MAXN][MAXN];
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
lg[1]=0;
for(int i=1;i<MAXN2;i++) lg[i]=lg[i/2]+1;
ll n,m,u,v; cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>u>>v; deg[u]++; deg[v]++;
vis[u][v]=vis[v][u]=true;
}
for(int i=1;i<=n;i++)
{
m=0;
for(int j=1;j<=n;j++)
{
if (vis[i][j]&&(deg[j]>deg[i]||deg[i]==deg[j]&&j>=i)) mm[m++]=j;
}
dd=(1<<(m>>1))-1; f[0]=1;
for(int i=0;i<m;i++) edges[i]=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<m;j++)
{
if(!vis[mm[i]][mm[j]] && i^j) edges[i]|=(1LL<<j);
}
}
for(int s=1;s<=dd;s++)
{
dp[s]=dp[s^LSB(s)] | edges[__lg(LSB(s))];
f[s]=1-(s&dp[s]);
}
for(int i=1;i<=dd;i*=2)
{
for(int j=0;j<=dd;j++)
{
if(i&j) f[j]+=f[i^j];
}
}
rez=(rez+f[dd])%MOD;
for(int s=1;s<(1<<((m+1)>>1));s++)
{
dp[s]=dp[s^LSB(s)] | edges[__lg(LSB(s))+(m>>1)];
if(!(dp[s]>>(m>>1)&s)) rez=(rez+f[dd^(dd&dp[s])])%MOD;
}
}
cout<<rez<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 42716kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 3ms
memory: 43576kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 42988kb
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:
962
result:
wrong answer 1st lines differ - expected: '1373', found: '962'