QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#400503 | #7514. Clique Challenge | flying | WA | 12ms | 4144kb | C++14 | 1.8kb | 2024-04-27 12:52:34 | 2024-04-27 12:52:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
const int Mod=1e9+7;
vector <int> g[N];
int du[N], id[N], point[N], pos[N], a[50][50];
bool del[N];
bool cmp(int x,int y)
{
return du[x]<du[y];
}
vector <int> getnew(vector <int> vec)
{
vector <int> newvec;
for(auto x:vec)
if(!del[x])
newvec.push_back(x);
return newvec;
}
long long dfs(vector <int> vec)
{
if(vec.size()==0)
return 0;
int n=vec.size();
for(int i=0;i<n;i++)
du[vec[i]]=del[vec[i]]=0;
for(int i=0;i<n;i++)
for(int j=0;j<i;j++)
if(a[vec[i]][vec[j]])
du[vec[i]]++, du[vec[j]]++;
long long ans=0, mul=1;
for(int i=0;i<n;i++)
if(du[vec[i]]==n-1)
ans += mul, mul *= 2, del[vec[i]]=true;
if(mul!=1)
return ans+mul*dfs(getnew(vec));
pair <int,int> Min=make_pair(0x3f3f3f3f,0);
for(auto x:vec)
Min=min(Min,make_pair(du[x],x));
int x=Min.second;
del[x]=true;
ans=dfs(getnew(vec));
for(int i=0;i<n;i++)
del[vec[i]]=false;
for(int i=0;i<n;i++)
if(a[x][vec[i]]==0)
del[vec[i]]=true;
return ans+dfs(getnew(vec))+1;
}
int calc(int n)
{
memset(pos,0,sizeof(pos));
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++)
pos[point[i]]=i;
for(int i=1;i<=n;i++)
for(auto x:g[point[i]])
if(pos[x])
a[i][pos[x]]=1;
vector <int> vec;
for(int i=1;i<=n;i++)
vec.push_back(i);
return dfs(vec)%Mod;
}
int main()
{
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d %d",&x,&y);
g[x].push_back(y);
g[y].push_back(x);
du[x]++, du[y]++;
}
for(int i=1;i<=n;i++)
id[i]=i;
sort(id+1,id+n+1,cmp);
int ans=n;
for(int i=1;i<=n;i++)
{
int x=id[i], cnt=0;
for(auto to:g[x])
if(!del[to])
point[++cnt]=to;
(ans += calc(cnt)) %= Mod;
del[x]=true;
}
printf("%d\n",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3852kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4144kb
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:
1373
result:
ok single line: '1373'
Test #4:
score: -100
Wrong Answer
time: 12ms
memory: 3864kb
input:
1000 1000 770 105 219 498 686 498 343 534 15 591 919 588 149 588 298 915 551 523 710 116 105 637 523 991 343 476 145 420 604 588 254 120 551 421 476 298 900 710 915 343 445 421 986 867 445 588 219 356 919 105 584 875 991 604 776 919 588 254 919 421 356 348 105 551 15 113 919 15 356 523 343 155 770 9...
output:
6433358
result:
wrong answer 1st lines differ - expected: '6621319', found: '6433358'