#include <bits/stdc++.h>
#define fo(i,a,b) for(ll i=a;i<b;i++)
#define vc vector
#define us unordered_set
#define pb push_back
#define in(x) ll x;cin>>x;
//#define DEBUG
#ifdef DEBUG
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#else
#define dbg(x)
#endif
using namespace std;
using ll = long long;
const ll M = 1e9+7;
int main(){
in(n);in(m);
vc<us<ll>> g(n);
fo(i,0,m){
in(a);in(b);a--;b--;
#define ad(x,y) g[x].insert(y);
ad(a,b);ad(b,a);
}
vc<ll> t(n);
vc<us<ll>> q(3);
fo(i,0,n){q[0].insert(i);}
#define set(v,tp) if(t[v]==0){dbg(v);dbg(tp);q[0].erase(v);ch=true;t[v] = tp;q[tp].insert(v);}
bool ch = false;
while(!q[0].empty()){
fo(i,0,3){dbg(i);dbg(q[i].size());}
ll x = *q[0].begin();
set(x,1);
while(ch){
ch = false;
for(ll v:q[1]){ for(ll u:g[v]){ set(u,2);}}
q[1].clear();
for(ll v:q[2]){ fo(u,0,n){ if(!g[v].count(u)){ set(u,1);}}}
q[2].clear();
}
}
fo(i,0,n){q[t[i]].insert(i);}//;cerr<<t[i]<<" ";}
//cerr<<endl;
//fo(i,0,n){cerr<<"i: "<<g[i].size()<<endl;}
vc<ll> c(4,0);
for(ll v:q[1]){ if(g[v].size() == q[2].size()){ c[1]++;}}
for(ll v:q[2]){ if(g[v].size() == q[2].size()-1){ c[2]++;}}
for(ll v:q[2]){ if(g[v].size() == q[2].size()){ c[3]++;}}
//cerr<<c[1]<<endl;cerr<<c[2]<<endl;cerr<<c[3]<<endl;
ll ans = (1*1+c[1]+c[2]+c[1]*c[3])%M;
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |