• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            superman

            聚精會神搞建設 一心一意謀發展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Section 2.2 - Party Lamps

            Posted on 2009-03-30 19:00 superman 閱讀(129) 評論(0)  編輯 收藏 引用 所屬分類: USACO
              1 #include <iostream>
              2 
              3 using namespace std;
              4 
              5 const int ON = 1, OFF = -1;
              6 
              7 int n, c;
              8 int FinalStatus[100];
              9 
             10 string ans[16];
             11 int ans_cnt;
             12 
             13 bool x[100];
             14 
             15 string x2string(bool x[], int n)
             16 {
             17     string ts;
             18     for (int i = 0; i < n; i++)
             19         ts += (x[i] + '0');
             20     return ts;
             21 }
             22 
             23 void addAns()
             24 {
             25     string ts = x2string(x, n);
             26 
             27     int i;
             28     for (i = 0; i < ans_cnt; i++)
             29         if (ans[i] == ts)
             30             break;
             31     if (i == ans_cnt)
             32         ans[ans_cnt++= ts;
             33 }
             34 
             35 bool check(int k)
             36 {
             37     if (k == 0)
             38     {
             39         if (c % 2 != 0)
             40             return false;
             41     }
             42     else
             43         if(c % k)
             44             return false;
             45     for (int i = 0; i < n; i++)
             46     {
             47         if (FinalStatus[i] == OFF && x[i] == true)
             48             return false;
             49         if (FinalStatus[i] == ON && x[i] == false)
             50             return false;
             51     }
             52     return true;
             53 }
             54 
             55 void Button_4(int k)
             56 {
             57     if (check(k))
             58         addAns();
             59 
             60     for (int i = 0; i < n; i += 3) x[i] ^= 1;
             61     if (check(k + 1))
             62         addAns();
             63     for (int i = 0; i < n; i += 3) x[i] ^= 1;
             64 }
             65 
             66 void Button_3(int k)
             67 {
             68     Button_4(k);
             69 
             70     for (int i = 0; i < n; i += 2) x[i] ^= 1;
             71     Button_4(k + 1);
             72     for (int i = 0; i < n; i += 2) x[i] ^= 1;
             73 }
             74 
             75 void Button_2(int k)
             76 {
             77     Button_3(k);
             78 
             79     for (int i = 1; i < n; i += 2) x[i] ^= 1;
             80     Button_3(k + 1);
             81     for (int i = 1; i < n; i += 2) x[i] ^= 1;
             82 }
             83 
             84 void Button_1(int k)
             85 {
             86     Button_2(k);
             87 
             88     for (int i = 0; i < n; i++) x[i] ^= 1;
             89     Button_2(k + 1);
             90     for (int i = 0; i < n; i++) x[i] ^= 1;
             91 }
             92 
             93 int main()
             94 {
             95     freopen("lamps.in""r", stdin);
             96     freopen("lamps.out""w", stdout);
             97 
             98     cin >> n >> c;
             99 
            100     int t;
            101     while (true)
            102     {
            103         cin >> t;
            104         if (t == -1break;
            105         FinalStatus[t - 1= ON;
            106     }
            107     while (true)
            108     {
            109         cin >> t;
            110         if (t == -1break;
            111         FinalStatus[t - 1= OFF;
            112     }
            113 
            114     if (c == 0)
            115     {
            116         int i;
            117         for (i = 0; i < n; i++)
            118             if (FinalStatus[i])
            119                 break;
            120         if (i == n)
            121         {
            122             for (int i = 0; i < n; i++)
            123                 cout << 1;
            124             cout << endl;
            125         }
            126         else
            127             cout << "IMPOSSIBLE" << endl;
            128         exit(0);
            129     }
            130 
            131     //=========================
            132     for (int i = 0; i < n; i++)
            133         x[i] = true;
            134 
            135     Button_1(0);
            136 
            137     sort(ans, ans + ans_cnt);
            138     for (int i = 0; i < ans_cnt; i++)
            139         cout << ans[i] << endl;
            140 
            141     if (ans_cnt == 0)
            142         cout << "IMPOSSIBLE" << endl;
            143 
            144     return 0;
            145 }
            146 
            人人狠狠综合久久亚洲高清| 久久成人小视频| 欧美噜噜久久久XXX| 久久99精品久久只有精品| 久久夜色精品国产网站| 亚洲国产精品久久久久婷婷软件| 7国产欧美日韩综合天堂中文久久久久 | 久久夜色精品国产亚洲| 色偷偷88888欧美精品久久久| 国内精品久久久久影院免费| 亚洲v国产v天堂a无码久久| 久久影院综合精品| 亚洲精品成人网久久久久久| 国产精品视频久久久| 亚洲午夜久久久影院| 久久久久久久综合综合狠狠| 国产69精品久久久久777| 97久久婷婷五月综合色d啪蜜芽| 99久久国产综合精品五月天喷水| 热久久视久久精品18| 国产午夜精品久久久久九九电影| 午夜天堂精品久久久久| 亚洲精品99久久久久中文字幕| 国产一区二区三区久久| 久久精品国产99久久久| 老男人久久青草av高清| 青春久久| 久久亚洲2019中文字幕| 久久婷婷人人澡人人| 久久av免费天堂小草播放| 99久久www免费人成精品| 狠狠干狠狠久久| 久久免费视频观看| 婷婷久久综合九色综合98| 精品久久久噜噜噜久久久| 久久久久高潮毛片免费全部播放| 精品综合久久久久久97| 久久精品国产2020| 韩国免费A级毛片久久| 99久久99久久精品免费看蜜桃| 99re久久精品国产首页2020|