这题有个小技巧, 按一个键两次等于没按,所以如果depsum > 16的话其实不用做深搜到depsum次,而只要16次就可以了。

 /*
 ID: yingzho1
 LANG: C++
 TASK: lamps
 */
 #include <iostream>
 #include <fstream>
 #include <string>
 #include <map>
 #include <vector>
 #include <set>
 #include <algorithm>
 #include <stdio.h>
 #include <queue>
 #include <cstring>

 using namespace std;

 ifstream fin("lamps.in");
 ofstream fout("lamps.out");

 int N, depsum;

 bool check(string s, vector<int> &on, vector<int> &off) {
     ; i < on.size(); i++) {
         ') return false;
     }
     ; i < off.size(); i++) {
         ') return false;
     }
     return s.size();
 }

 void dfs(set<string> &res, int c1, int c2, int c3, int c4, string s, vector<int> &on, vector<int> &off, int dep) {
     if (check(s, on, off)) {
          == ) {
             res.insert(s);
             //return;
         }
     }
      || dep > depsum) return;
     string pre = s;
     ) {
         dfs(res, c1+, c2, c3, c4, s, on, off, dep+);
         ; i < s.size(); i++) {
             ';
             ';
         }
         dfs(res, c1+, c2, c3, c4, s, on, off, dep+);
     }

     s = pre;

     ) {
         dfs(res, c1, c2+, c3, c4, s, on, off, dep+);
         ; i < s.size(); i++) {
              == ) {
                 ';
                 ';
             }
         }
         dfs(res, c1, c2+, c3, c4, s, on, off, dep+);
     }

     s = pre;
     ) {
         dfs(res, c1, c2, c3+, c4, s, on, off, dep+);
         ; i < s.size(); i++) {
              == ) {
                 ';
                 ';
             }
         }
         dfs(res, c1, c2, c3+, c4, s, on, off, dep+);
     }

     s = pre;
     ) {
         dfs(res, c1, c2, c3, c4+, s, on, off, dep+);
         ; i < s.size(); i++) {
              == ) {
                 ';
                 ';
             }
         }
         dfs(res, c1, c2, c3, c4+, s, on, off, dep+);
     }

     s = pre;
 }

 int main()
 {
     fin >> N >> depsum;
     ');
     int n;
     vector<int> on, off;
     //cout << N << " " << depsum << endl;
     ) on.push_back(n-);
     ) off.push_back(n-);
     //for (int i = 0; i < on.size(); i++) cout << on[i] << endl;
     //for (int i = 0; i < off.size(); i++) cout << off[i] << endl;
     set<string> res;
     dfs(res, , , , , s, on, off, );
     vector<string> ret;
     for (set<string>::iterator it = res.begin(); it != res.end(); it++) ret.push_back(*it);
     sort(ret.begin(), ret.end());
     ) {
         fout << "IMPOSSIBLE" << endl;
         ;
     }
     ; i < ret.size(); i++) {
         fout << ret[i] << endl;
     }

     ;
 }

USACO Section 2.2: Party Lamps的更多相关文章

  1. USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)

    usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...

  2. 【USACO 2.2】Party Lamps

    四种开关,n盏灯,1:改变所有灯状态,2:改变奇数灯状态,3:改变偶数灯状态,4:改变3k+1灯状态 给你按开关的总次数c和部分灯限制条件(开或关),一开始都是开着的.($c \leq 10000,n ...

  3. USACO Section 3.3: Riding the Fences

    典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...

  4. USACO Section 3.3 Camlot(BFS)

    BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...

  5. [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)

    nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...

  6. USACO Section 5.3 Big Barn(dp)

    USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1  (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...

  7. USACO Section 1.3 Prime Cryptarithm 解题报告

    题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...

  8. USACO Section 1.1 Your Ride Is Here 解题报告

    题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...

  9. USACO Section 1.1-1 Your Ride Is Here

    USACO 1.1-1 Your Ride Is Here 你的飞碟在这儿 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都只能带上一组支 ...

随机推荐

  1. Netsharp快速入门(之13) 销售管理(单据流转 销售订单生成发货单)

    作者:秋时 杨昶   转载须说明出处 4.5     单据流转 4.5.1  单据流转的目的 单据流转主要为了实现业务关系的流转,并记录相互之间的关系.例如从销售订单生成销货单,两张单据之间有对应的关 ...

  2. Google Guava学习笔记——基础工具类Preconditions类的使用

    Preconditions类是一组静态方法用来验证我们代码的状态.Preconditons类很重要,它能保证我们的代码按照我们期望的执行,如果不是我们期望的,我们会立即得到反馈是哪里出来问题,现在我们 ...

  3. js读取屏幕长宽

    网页可见区域宽 document.body.clientWidth 网页可见区域高 document.body.clientHeight 网页可见区域宽(包括边线的宽) document.body.o ...

  4. .NET Framework 4.5、4.5.1 和 4.5.2 中的新增功能

    .NET Framework 4.5.4.5.1 和 4.5.2 中的新增功能 https://msdn.microsoft.com/zh-cn/library/ms171868.aspx

  5. Oracle系列教程

    推荐博客:http://blog.csdn.net/leshami 具体知识点总结: 1.oracle安装:http://www.cnblogs.com/bluepoint2009/p/oracle- ...

  6. 【转载】Oracle 11g R2 for Win7旗舰版(64位)- 安装

    免责声明:     本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除.     原文作者:bluepoint2009      原文地址:http://www.cnbl ...

  7. 【CentOS】设置静态IP

      问题描述:         CentOS配置静态IP   问题解决:         (1)修改IP--修改配置文件/etc/sysconfig/network-scripts/ifcfg-eth ...

  8. C#做音乐播放器时在自动下一曲中报异常的解决办法

    ---------------------- ASP.Net+Unity开发..Net培训.期待与您交流! ---------------------- 在利用Media Player做音乐播放器的时 ...

  9. 【BZOJ】【1015】 【JSOI2008】星球大战starwar

    并查集/时光倒流 删点维护连通块个数比较难处理,所以我们就逆序来做,先处理最后状态下有多少连通块,再依次加入被删的点,这样就变删点为加点,利用并查集即可维护连通块个数. /************** ...

  10. CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT

    这个error的全称是这样的 D3D11 ERROR: ID3D11Device::CreateInputLayout: Element[1]'s format (UNKNOW) cannot be ...