QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196595 | #7514. Clique Challenge | Crysfly | WA | 20ms | 135960kb | C++17 | 4.1kb | 2023-10-01 20:01:23 | 2023-10-01 20:01:23 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 200005
#define inf 0x3f3f3f3f
bool mbe;
int n,m;
int e[1005][1005],deg[1005],vis[1005];
modint res;
int d1[44],d2[44],m1,m2,n1,n2;
int lg[1<<24|5],popc[1<<24|5];
int s2[1<<22|5];
bool s1[1<<24|5],sta[1<<24|5];
int to11[44],to12[44],to22[44];
bool med;
void work(int u)
{
// cout<<"u: "<<u<<" "<<deg[u]<<"\n";
m1=deg[u]/2;
m2=deg[u]-m1; n1=n2=0;
if(m2==22)--m2,++m1;
if(m2==21)--m2,++m1;
For(i,1,n)
if(i!=u && e[u][i]){
if(n1<m1)d1[n1++]=i;
else d2[n2++]=i;
}
For(i,0,max(n1,n2)) to11[i]=to12[i]=to22[i]=0;
For(i,0,n1-1){
For(j,0,n1-1) if(e[d1[i]][d1[j]]) to11[i]|=(1<<j);
For(j,0,n2-1) if(e[d1[i]][d2[j]]) to12[i]|=(1<<j);
}
For(i,0,n2-1){
For(j,0,n2-1) if(e[d2[i]][d2[j]]) to22[i]|=(1<<j);
}
s2[0]=1;
For(s,1,(1<<n2)-1){
int t=lg[s&-s];
s2[s]=s2[s^(1<<t)]&((to22[t]&s)==(s^(1<<t)));
}
For(i,0,n2-1)
For(s,0,(1<<n2)-1)
if(s>>i&1) s2[s]+=s2[s^(1<<i)];
// cout<<"D:\n";
// For(i,0,n1-1)cout<<d1[i]<<" ";cout<<"\n";
// For(i,0,n2-1)cout<<d2[i]<<" ";cout<<"\n";
// cout<<"s2 "<<s2[(1<<n2)-1]<<"\n";
sta[0]=(1<<n2)-1;
s1[0]=1;
res+=s2[sta[0]];
// cout<<"res "<<res.x<<"\n";
For(s,1,(1<<n1)-1){
int t=lg[s&-s];
s1[s]=s1[s^(1<<t)]&((to11[t]&s)==(s^(1<<t)));
// cout<<"to12 "<<s<<" "<<lg[s]<<" "<<to12[lg[s]]<<"\n";
sta[s]=sta[s^(1<<t)]&to12[t];
if(s1[s]) res+=s2[sta[s]];
}
// cout<<"Res "<<res.x<<"\n";
}
signed main()
{
// cout<<22*(1<<22)<<"\n";
// cerr<<(1.0*(&mbe-&med)/1024576.0)<<"\n";
For(i,0,(1<<24)){
if(i>=2) lg[i]=lg[i>>1]+1;
popc[i]=popc[i>>1]+(i&1);
}
n=read(),m=read();
For(i,1,m){
int u=read(),v=read();
++deg[u],++deg[v],e[u][v]=e[v][u]=1;
}
For(_,1,n){
int u=-1;
For(i,1,n)
if(!vis[i] && (u==-1||deg[i]<deg[u]))u=i;
assert(deg[u]<=44);
work(u);
vis[u]=1;
For(i,1,n)
if(e[u][i]) e[u][i]=e[i][u]=0,--deg[u],--deg[i];
}
cout<<res.x;
return 0;
}
/*
3 5
3 1 5 2
4 2 1 3
1 9 100 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 135716kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 15ms
memory: 135960kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 20ms
memory: 135256kb
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:
1141
result:
wrong answer 1st lines differ - expected: '1373', found: '1141'