Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long int edges,d,q,i,type,x,top,leaf;
- cin >> d >> q;
- edges = pow(2,d+1)-2;
- top=1;
- leaf = pow(2,d);
- for(i=0;i<q;i++)
- {
- cin >> type;
- if(type==1)
- {
- cin >> x;
- if( x==1 || x==2)
- {
- edges = 2*edges%1000000007 + d+1;
- top = 2*top;
- leaf = 2*leaf;
- }
- else if ( x == 3)
- {
- edges = 2*edges%1000000007 + top;
- d = 2*d+1;
- top = leaf;
- }
- else if (x==4)
- {
- edges = 2*edges%1000000007 + leaf;
- d = 2*d+1;
- leaf = top;
- }
- edges = edges%1000000007;
- }
- else
- cout << edges << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment