Description Description applepi is imprisoned at only one door, which is called "The door of the black magician ". There is a picture of the undirected and untitled door, the password used to open this door is the number of subgraphs in the Figure [where the degree of each point is greater than zero and the number is an even number], and the modulo value is 1000000009. The subgraphs (V, E) are defined as: point set V and edge set E are all arbitrary subsets of the source image, where the edges in E are all in v.
However, Vani believes that such a password is too simple, so the diagram on the door is dynamic. At first, there are only n vertices without edges. The door control system built by Vani operates m times in total, adding an edge to the graph each time. You must enter the correct password after each operation to open the jail time of the hacker and save the great leader applepi. Question: The meaning of the question is clear, but it feels so powerful...
At the beginning, I was thinking about how to construct it and found it too complicated.
Then query the problem found that only the current two points in the same connected block, ANS * = 2, and finally output the ans-1
It means you don't understand it, so you don't have to write it.
I turned to the question of lyd yesterday.
He introduced something called a metaring and proved that the answer is the number of 2 ^ metarings.
I did not understand the concept of the metaring. Then I found that if I put the whole picture on a plane, the metaring is a region!
Then, why does the number of regions + 1 when two connected blocks are connected by an edge?
This reminds me of the Euler's formula:
V + F-E = 2
Number of vertices in Table V, number of areas in table F, and number of edges in Table E
After adding an edge, e ++ and V remain unchanged. Therefore, F must be ++.
The answer is 2 ^ area-1.
The speaker said:
There are two conditions for selecting or not selecting each region. If this option is selected, the number of edge selection times for the boundary of this region is + +, finally, select all edges with an odd number of selections to save the answer. It can prove that this is not repeated.
I have not thought about the result as to why it is not important.
Pit to be filled...
Code:
1 #include<cstdio> 2 3 #include<cstdlib> 4 5 #include<cmath> 6 7 #include<cstring> 8 9 #include<algorithm>10 11 #include<iostream>12 13 #include<vector>14 15 #include<map>16 17 #include<set>18 19 #include<queue>20 21 #include<string>22 23 #define inf 100000000024 25 #define maxn 25000026 27 #define maxm 500+10028 29 #define eps 1e-1030 31 #define ll long long32 33 #define pa pair<int,int>34 35 #define for0(i,n) for(int i=0;i<=(n);i++)36 37 #define for1(i,n) for(int i=1;i<=(n);i++)38 39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)40 41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)42 43 #define mod 100000000944 45 using namespace std;46 47 inline int read()48 49 {50 51 int x=0,f=1;char ch=getchar();52 53 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}54 55 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}56 57 return x*f;58 59 }60 int n,m,fa[maxn];61 inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}62 63 int main()64 65 {66 67 freopen("input.txt","r",stdin);68 69 freopen("output.txt","w",stdout);70 71 n=read();m=read();72 for1(i,n)fa[i]=i;73 int ans=1;74 for1(i,m)75 {76 int x=find(read()),y=find(read());77 if(x!=y)fa[x]=y;else ans<<=1,ans%=mod;78 printf("%d\n",(ans-1+mod)%mod);79 }80 81 return 0;82 83 }
View code
[Poetize I] the door to the black magician