QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#251738 | #7514. Clique Challenge | Urvuk3 | WA | 2ms | 3700kb | C++14 | 3.5kb | 2023-11-15 02:14:55 | 2023-11-15 02:14:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=1e9;
const ll LINF=1e18,MOD=1e9+7;
#define fi first
#define se second
#define pii pair<int,int>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back
void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}
template<typename T,typename V>
void PRINT(pair<T,V>& x){
cerr<<"{";
PRINT(x.fi);
cerr<<",";
PRINT(x.se);
cerr<<"}";
}
template<typename T>
void PRINT(T &x){
int id=0;
cerr<<"{";
for(auto _i:x){
cerr<<(id++ ? "," : "");
PRINT(_i);
}
cerr<<"}";
}
void _PRINT(){
cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
PRINT(h);
if(sizeof...(t)) cerr<<", ";
_PRINT(t...);
}
#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)
const int mxN=1000;
int N,M;
int deg[mxN+1];
bool edge[mxN+1][mxN+1];
void Md(ll& x){
if(x>=MOD) x%=MOD;
}
void Solve(){
cin>>N>>M;
for(int i=1;i<=M;i++){
int u,v; cin>>u>>v;
edge[u][v]=1; deg[v]++;
edge[v][u]=1; deg[u]++;
}
bool fin=false;
ll res=0;
while(!fin){
int mnid=-1,mn=INF;
for(int i=1;i<=N;i++){
if(deg[i]<mn){
mnid=i;
mn=deg[i];
}
}
deg[mnid]=INF;
vector<int> con;
for(int v=1;v<=N;v++){
if(edge[mnid][v]){
edge[mnid][v]=edge[v][mnid]=0;
con.pb(v);
}
}
int s=sz(con);
if(s==0){
res++; Md(res);
}
else if(s==1){
res+=2; Md(res);
}
else{
int emask[s/2]={0};
int sos[1<<((s+1)/2)][(s+1)/2];
sos[0][0]=1;
for(int i=0;i<s/2;i++){
for(int j=s/2;j<s;j++){
if(edge[con[i]][con[j]]) emask[i]+=(1<<(j-s/2));
}
}
for(int m=1;m<(1<<((s+1)/2));m++){
for(int i=s/2;i<s;i++){
if(m&(1<<(i-s/2))){
sos[m][0]=sos[m^(1<<(i-s/2))][0];
for(int j=s/2;j<s;j++){
if(j!=i && m&(1<<(j-s/2))){
sos[m][0]&=edge[i][j];
}
}
break;
}
}
for(int i=1;i<=(s+1)/2;i++){
if(m&(1<<(i-1))) sos[m][i]=sos[m][i-1]+sos[m^(1<<(i-1))][i-1];
else sos[m][i]=sos[m][i-1];
}
}
for(int m=0;m<(1<<(s/2));m++){
int m1=(1<<((s+1)/2))-1;
for(int i=0;i<s/2;i++){
if((1<<i)&m) m1&=emask[i];
}
res+=sos[m1][(s+1)/2];
}
}
fin=true;
for(int i=1;i<=N;i++){
if(deg[i]!=INF){
fin=false;
break;
}
}
}
cout<<res<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
t=1;
//cin>>t;
while(t--){
Solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3700kb
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:
1116
result:
wrong answer 1st lines differ - expected: '1373', found: '1116'