Graph theory + Thinking (2019 cattle off the National Day party training day2)

Meaning of the questions: https://ac.nowcoder.com/acm/contest/1107/J

FIG complete number n of points 0-n-1, the i-th point is weight 2 ^ i, originally select some upper hand side, then flip select some point, the upper hand to meet all edges corresponding to the selected at least two to have one, and the total weight and minimal, and now you have to flip the selected point and weights, seeking the upper hand side of the select number of programs ( that is, the upper hand finished selecting some of the side, flip the election required at some point so that all sides are and the right to be covered and the minimum value, FLAC tell you now ask you the upper hand weights and the number of emulated program )

Ideas:

Because the weights are given in binary form, so that a corresponding position, i.e. corresponding to this point is also selected, and for the selected point is, and must be greater than the weight of his point and the point is not selected phase connection, so at this point it must be chosen, and smaller than the weight he may even not even the point. https://blog.csdn.net/mmk27_word/article/details/90670209

  1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
  2 #include <cstdio>//sprintf islower isupper
  3 #include <cstdlib>//malloc  exit strcat itoa system("cls")
  4 #include <iostream>//pair
  5 #include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
  6 #include <bitset>
  7 //#include <map>
  8 //#include<unordered_map>
  9 #include <vector>
 10 #include <stack>
 11 #include <set>
 12 #include <string.h>//strstr substr
 13 #include <string>
 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
 15 #include <cmath>
 16 #include <deque>
 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
 18 #include <vector>//emplace_back
 19 //#include <math.h>
 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
 23 //******************
 24 int abss(int a);
 25 int lowbit(int n);
 26 int Del_bit_1(int n);
 27 int maxx(int a,int b);
 28 int minn(int a,int b);
 29 double fabss(double a);
 30 void swapp(int &a,int &b);
 31 clock_t __STRAT,__END;
 32 double __TOTALTIME;
 33 void _MS(){__STRAT=clock();}
 34 void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
 35 //***********************
 36 #define rint register int
 37 #define fo(a,b,c) for(rint a=b;a<=c;++a)
 38 #define fr(a,b,c) for(rint a=b;a>=c;--a)
 39 #define mem(a,b) memset(a,b,sizeof(a))
 40 #define pr printf
 41 #define sc scanf
 42 #define ls rt<<1
 43 #define rs rt<<1|1
 44 typedef long long ll;
 45 const double E=2.718281828;
 46 const double PI=acos(-1.0);
 47 //const ll INF=(1LL<<60);
 48 const int inf=(1<<30);
 49 const double ESP=1e-9;
 50 const int mod=(int)1e9+7;
 51 const int N=(int)1e6+10;
 52 
 53 char temp[N],k[N];
 54 ll dp[N],er[N];
 55 
 56 ll get(int pos,int n)
 57 {
 58      II ans = 1 ;
59      ans = ans * ((s [dp [pos]] - 1 + v)% v)% v * is [N-pos]% v;
60      return ans;
61  }
 62  
63  int main ()
 64  {
 65      int n;
66      is [ 0 ] = 1 ;
67      is [ 1 ] = 2 ;
68      for ( int i = 2 ; i <= N 3 ; ++ i)
 69          is [I] = the [i- 1]*2,er[i]%=mod;
 70     while(~sc("%d%s",&n,temp+1))
 71     {
 72         int l=strlen(temp+1);
 73         int cnt=n-l;
 74         for(int i=1;i<=cnt;++i)
 75             k[i]='0';
 76         for(int i=1;i<=l;++i)
 77             k[i+cnt]=temp[i];
 78         l=cnt+l;
 79         for(int i=1;i<=l;++i)
 80         {
 81             dp[i]=dp[i-1];
 82             if(k[i]=='0')
 83                 dp[i]++;
 84         }
 85         ll ans=1;
 86         for(int i=1;i<=l;++i)
 87         {
 88             if(k[i]=='0')continue;
 89             ans*=get(i,l);
 90             ans%=mod;
 91         }
 92         pr("%lld\n",ans);
 93     }
 94     return 0;
 95 }
 96 
 97 /**************************************************************************************/
 98 
 99 int maxx(int a,int b)
100 {
101     return a>b?a:b;
102 }
103 
104 void swapp(int &a,int &b)
105 {
106     a^=b^=a^=b;
107 }
108 
109 int lowbit(int n)
110 {
111     return n&(-n);
112 }
113 
114 int Del_bit_1(int n)
115 {
116     return n&(n-1);
117 }
118 
119 int abss(int a)
120 {
121     return a>0?a:-a;
122 }
123 
124 double fabss(double a)
125 {
126     return a>0?a:-a;
127 }
128 
129 int minn(int a,int b)
130 {
131     return a<b?a:b;
132 }

 

Guess you like

Origin www.cnblogs.com/--HPY-7m/p/11618268.html