The main idea: a row of lights have N, there are 4 kinds of switches, each switch can change some of the lights are now the state (bright dim, dark brightness) now known to some of the lights of the light dark situation, asked so what may be the case
Idea: The same switch open two times obviously no effect, then enumerate each switch whether open is good, or violent dafa good
1 /*{2 id:a42984423 Prob:lamps4 lang:c++5 }6 */7#include <iostream>8#include <fstream>9#include <cstring>Ten#include <algorithm> One #defineMAXN 109 A using namespacestd; -Ifstream Fin ("lamps.in"); -Ofstream Fout ("Lamps.out"); the //#define FIN CIN - //#define Fout cout - intLAMP[MAXN],TEMP[MAXN],N1,N2,A[MAXN],B[MAXN]; - structT + { - CharCH[MAXN]; + }ANS[MAXN]; A voidBUT1 (intN) at { - for(intI=1; i<=n;i++) lamp[i]^=1; - } - voidBut2 (intN) - { - for(intI=1; i<=n;i+=2) lamp[i]^=1; in } - voidBUT3 (intN) to { + for(intI=2; i<=n;i+=2) lamp[i]^=1; - } the voidBUT4 (intN) * { $ for(intI=0; i*3+1<=n;i++) lamp[i*3+1]^=1;Panax Notoginseng } - intCheckintNintCintCount_now) the { + for(intI=1; i<n1;i++)if(lamp[a[i]]==0)return 0; A for(intI=1; i<n2;i++)if(lamp[b[i]]==1)return 0; the if(COUNT_NOW>C)return 0; + intu=c-Count_now; - if(u&1)return 0; $ return 1; $ } - intCMP (t x, t y) - { the returnstrcmp (x.ch+1, y.ch+1) >=0?false:true; - }Wuyi intMain () the { - intn,c; WuFin>>n>>C; - while(fin>>a[++n1]&&a[n1]!=-1); About while(fin>>b[++n2]&&b[n2]!=-1); $ for(intI=1; i<=n;i++) temp[i]=1; - intH=0; - for(intI=0; I<= (1ll<<4)-1; i++) - { A intcount_now=0; +memcpy (Lamp,temp,sizeof(lamp)); the for(intj=1, idx=1; j<=i;j<<=1, idx++)if((i&j)! =0 ) - { $count_now++; the if(idx==1) BUT1 (n); the if(idx==2) But2 (n); the if(idx==3) BUT3 (n); the if(idx==4) But4 (n); - } in if(check (n,c,count_now)) the { theh++; About for(intI=1; i<=n;i++) the { theans[h].ch[i]=lamp[i]+'0'; the } + } - } the if(h==0) fout<<"Impossible"<<endl;ElseBayi { theSort (ans+1, ans+1+h,cmp); the for(intI=1; i<=h;i++) fout<<ans[i].ch+1<<Endl; - } - return 0; the}
Usaco Party Lamps