# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
634230 | Mahdi | Subtree (INOI20_subtree) | C++17 | 318 ms | 1312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
const int N=25, M=2e6;
int n, m;
bool g[N][N], a[M];
int main(){
cin>>n>>m;
int ans=0;
for(int i=0;i<m;++i){
int u, v;
cin>>u>>v;
g[--u][--v]=1;
g[v][u]=1;
}
a[0]=1;
for(int i=1;i<(1<<n);++i){
int x=i;
vector<int>w;
for(int j=0;x;++j){
if(x&1)
w.push_back(j);
x>>=1;
}
int t=0;
for(int u: w){
for(int v: w){
if(g[u][v])
++t;
}
}
t/=2;
if(t!=w.size()-1){
continue;
}
for(int u: w){
if(a[i-(1<<u)]){
a[i]=1;
break;
}
}
if(a[i])
++ans;
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |