这题有个小技巧, 按一个键两次等于没按,所以如果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. 用 Android-X86 和 VirtualBox 玩安卓游戏

    目前的系统是 Ubuntu 14.04,近日玩了玩 flash 版的<皇家禁卫军:前线>塔防游戏,还是想试试原生安卓游戏的表现.发现大概有两个选择: 各类安卓模拟器:官方SDK模拟器,bl ...

  2. 阿里云无线&前端团队是如何基于webpack实现前端工程化的

    背景 前端经历了初期的野蛮生长(切图,写简单的特效)——为了兼容浏览器兼容性而出现的各种类库(JQUERY,YUI等——mv*(饱暖思淫欲,代码多了,也就想到怎样组织代码结构,backbone,ang ...

  3. Visual Studio 2013 各版本注册码

    Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visual Studio Premium 2013 KEY(密钥) ...

  4. sourceInsight使用技巧,持续更新中~~~

    作为测试人员,读各种平台的工程代码时,根本不想安装各种vs或者eclipse等,于是,就找了一款代码阅读工具. sourceInsight,下载地址为官网:http://www.sourceinsig ...

  5. JS 学习笔记--7---正则表达式

    正则表达式中的内容很多,也很深,下面只是一些基本的知识点,练习中使用的浏览器是IE10,若有不当处请各位朋友指正,我会在第一时间修改错误之处. 匹配的概念:是包含的意思,不是相等的意思 1.正则表达式 ...

  6. 引擎设计跟踪(九.14.2h) 开发计划

    以后的开发计划: 完善game runtime code, 跑简单的demo目前只有编辑器的运行流程, 没有游戏/demo流程, 图形的测试主要在编辑器上测试, 现在需要测试android系统的图形, ...

  7. 快速、直接的XSS漏洞检测爬虫 – XSScrapy

    XSScrapy是一个快速.直接的XSS漏洞检测爬虫,你只需要一个URL,它便可以帮助你发现XSS跨站脚本漏洞. XSScrapy的XSS漏洞攻击测试向量将会覆盖 Http头中的Referer字段 U ...

  8. 常用的CSSreset整理

    说道CSSreset,大家又爱又恨,cssreset好处是,覆盖了浏览器的默认样式,使前端攻城狮能更加精确的添加样式,各个浏览器中的界面效果都相同.可是大量的.固定的CSSreset也给网页加载带来一 ...

  9. lagstash + elasticsearch + kibana 3 + kafka 日志管理系统部署 02

    因公司数据安全和分析的需要,故调研了一下 GlusterFS + lagstash + elasticsearch + kibana 3 + redis 整合在一起的日志管理应用: 安装,配置过程,使 ...

  10. 了解Javascript 变量

    javascript语言变量的作用域可以分为局部变量和全局变量 函数内部定义的变量为局部变量,作用范围在整个函数体内,函数外定义的变量为全局变量,如果在函数内部定义变量时没有使用关键字var,那么该变 ...