就是模拟。同一个开关按2下相当于没按,那么,如果一共按0下,就是没按,按1下就是4个开关的1个,按2下可能相当于实际按了0下或按2下,按3下实际按了1下或3下,之后如果是奇数,相当于按1或3下,偶数相当于按0,2,4下。再看一下是否符合。数据太小根本不会超时。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF; int getdgt(int x)
{
int res=;
for(;x;)
{
if(x&)++res;
x/=;
}
return res;
} void func(int x,bitset<> &y)
{
if(x&)y.flip();
if(x&)
{
for(int i=;i<=;i+=)y[i]=!y[i];
}
if(x&)
{
for(int i=;i<=;i+=)y[i]=!y[i];
}
if(x&)
{
for(int i=;i<=;i+=)y[i]=!y[i];
}
} bool chk(bitset<> bt,vector<int> &x,int sta)
{
for(int i=;i<x.size();++i)
{
if(bt[x[i]]!=sta)return ;
}
return ;
} void work(int n,set<int> time,vector<int> lg,vector<int> dk)
{
bool ok=;
vector<string> vct;
for(int i=;i<(<<);++i)
{
if(time.find(getdgt(i))!=time.end())
{
bitset<> bt;
bt.set();
func(i,bt);
if(chk(bt,lg,)&&chk(bt,dk,))
{
ok=;
string tmp="";
for(int j=;j<=n;++j)
{
tmp+=bt[j]+'';
}
vct.push_back(tmp);
}
}
}
sort(vct.begin(),vct.end());
if(ok==)cout<<"IMPOSSIBLE"<<endl;
else
{
for(int i=;i<vct.size();++i)
{
cout<<vct[i]<<endl;
}
}
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int n,cnt;
cin>>n>>cnt;
vector<int> lg,dk;
for(;;)
{
int tmp;
cin>>tmp;
if(tmp==-)break;
else lg.push_back(tmp);
}
for(;;)
{
int tmp;
cin>>tmp;
if(tmp==-)break;
else dk.push_back(tmp);
}
//sort(lg.begin(),lg.end());
//sort(dk.begin(),dk.end());
set<int> st;
if(cnt==)
{
st.insert();
work(n,st,lg,dk);
}
else if(cnt==)
{
st.insert();
work(n,st,lg,dk);
}
else if(cnt==)
{
st.insert();
st.insert();
work(n,st,lg,dk);
}
else if(cnt&)
{
st.insert();
st.insert();
work(n,st,lg,dk);
}
else
{
st.insert();
st.insert();
st.insert();
work(n,st,lg,dk);
}
}
return ;
}

p1468 Party Lamps的更多相关文章

  1. 【搜索】P1468 派对灯 Party Lamps

    P1468 派对灯 Party Lamps 我们来分析一下对灯的操作 1.对所有灯的,这时吧所有灯看成一个整体 2.奇偶数的操作,这时可以把每两个数看成一个循环节 3.对3X+ 1的操作,这时可以把每 ...

  2. luogu P1468 派对灯 Party Lamps

    题目描述 在IOI98的节日宴会上,我们有N(10<=N<=100)盏彩色灯,他们分别从1到N被标上号码. 这些灯都连接到四个按钮: 按钮1:当按下此按钮,将改变所有的灯:本来亮着的灯就熄 ...

  3. P1468 派对灯 Party Lamps(BIG 模拟)

    题目描述 在IOI98的节日宴会上,我们有N(10<=N<=100)盏彩色灯,他们分别从1到N被标上号码. 这些灯都连接到四个按钮: 按钮1:当按下此按钮,将改变所有的灯:本来亮着的灯就熄 ...

  4. luoguP1468 派对灯 Party Lamps x

    P1468 派对灯 Party Lamps 题目描述 在IOI98的节日宴会上,我们有N(10<=N<=100)盏彩色灯,他们分别从1到N被标上号码. 这些灯都连接到四个按钮: 按钮1:当 ...

  5. 【USACO 2.2】Party Lamps

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

  6. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  7. poj 1176 Party Lamps

    http://poj.org/problem?id=1176 Party Lamps Time Limit: 1000MS   Memory Limit: 10000K Total Submissio ...

  8. USACO Section 2.2: Party Lamps

    这题有个小技巧, 按一个键两次等于没按,所以如果depsum > 16的话其实不用做深搜到depsum次,而只要16次就可以了. /* ID: yingzho1 LANG: C++ TASK: ...

  9. UVA 12382 Grid of Lamps 贪心

    题目链接: C - Grid of Lamps Time Limit:1000MSMemory Limit: 0KB 问题描述 We have a grid of lamps. Some of the ...

随机推荐

  1. Delphi XE5 for Android (十)

    我觉得Delphi最强大的的功能之一就是开发数据库三层应用的DataSnap,在Android上的实现,首先是完成服务器的设计: (1)利用向导完成DataSnap服务器的框架,如下图: 由于是实验, ...

  2. error和exception有什么区别?

    Error(错误)表示系统级的错误和程序不必处理的异常,是java运行环境中的内部错误或者硬件问题.比如:内存资源不足等.对于这种错误,程序基本无能为力,除了退出运行外别无选择,它是由Java虚拟机抛 ...

  3. word2010使用记录

    安装时提示: installer无法更新被保护的一个或多个文件, 解决方法是: 将三个dll文件,放在 c:\program files\common files\ms shared\web serv ...

  4. s2-045漏洞批量检测工具

    今天晚上看老铁们在群里就这个st2-045漏洞讨论得火热,个人不太喜欢日站,本来想直接写个批量挂马的东西,但是想想还是算了,如果你有兴趣,改改也很容易,反正不关我的事 测试图 2017-3-8更新 增 ...

  5. 使用digitalocean进行项目开发

    使用digitalocean进行项目开发 命令记录 搭建SS 1 apt-get update 2 apt-get install python-pip 3 pip install --upgrade ...

  6. C# 里调用vb的inputbox弹出窗

    https://blog.csdn.net/hutao1101175783/article/details/16800871 先对项目添加对Microsoft.VisualBasic的引用 Inter ...

  7. 题解——牛客网Wannafly挑战赛23 B-游戏 (SG函数)

    前言 比赛的时候没学过SG函数的蒟蒻以为是道结论题,但是不是QwQ 和dummyummy巨佬一起推了快三个小时的规律 最后去问了真正的巨佬__stdcall __stdcall面带微笑的告诉我们,这是 ...

  8. (转载)西门子PLC学习笔记十五-(数据块及数据访问方式)

    一.数据块 数据块是在S7 CPU的存储器中定义的,用户可以定义多了数据块,但是CPU对数据块数量及数据总量是有限制的. 数据块与临时数据不同,当逻辑块执行结束或数据块关闭,数据块中的数据是会保留住的 ...

  9. ZOJ 3987 Numbers(Java枚举)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3987 题意:给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n ...

  10. SPOJ 839 Optimal Marks(最小割的应用)

    https://vjudge.net/problem/SPOJ-OPTM 题意: 给出一个无向图G,每个点 v 以一个有界非负整数 lv 作为标号,每条边e=(u,v)的权w定义为该边的两个端点的标号 ...