• <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 閱讀(130) 評論(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 
            久久伊人亚洲AV无码网站| 国产精品视频久久久| 久久精品国产精品亚洲人人| 久久精品国产99久久香蕉| 思思久久精品在热线热| 久久99国产精一区二区三区| 久久精品国产99久久久香蕉| 久久国产色av免费看| 久久精品成人一区二区三区| 香蕉久久夜色精品升级完成| 狠狠人妻久久久久久综合| 亚洲成色WWW久久网站| 国产综合成人久久大片91| 熟妇人妻久久中文字幕| 久久免费香蕉视频| 精品久久久久久亚洲| 久久狠狠爱亚洲综合影院| 色综合合久久天天给综看| 精品久久香蕉国产线看观看亚洲| 婷婷久久综合| 国产精品九九久久免费视频 | 97精品国产97久久久久久免费| 亚洲国产精品无码久久久久久曰 | 久久天天躁狠狠躁夜夜96流白浆| 精品久久久久久无码人妻热 | 久久久久久久久久久久中文字幕| 久久精品国产国产精品四凭| 91精品国产91久久| 久久久精品午夜免费不卡| 欧美丰满熟妇BBB久久久| 精品综合久久久久久97| 久久午夜夜伦鲁鲁片免费无码影视| 久久国产免费直播| 国产免费久久精品99久久| 国产一区二区精品久久岳| 国产精品激情综合久久| 久久男人中文字幕资源站| 亚洲精品美女久久久久99小说| 亚洲国产成人久久一区WWW| 欧美精品九九99久久在观看| 久久久久久国产精品美女|