就是模拟。同一个开关按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. Maven3版本的超级POM位置及中央仓库位置

    背景 之所以想到这个问题,是因为在配置Nexus-Maven 私服的时候,需要在Maven的settings.xml中对<mirror>进行配置,在配置中央仓库的镜像时,<mirro ...

  2. CentOS 安装 Gitlab

    源地址 https://mirror.tuna.tsinghua.edu.cn/gitlab-ce/ # 清华源 https://mirrors.tuna.tsinghua.edu.cn/help/g ...

  3. nohup 让进程在后台可靠运行的几种方法

    1. nohup nohup 无疑是我们首先想到的办法.顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号. nohup 的使用是十分方便的,只需在要处理的命令前加上 nohup 即 ...

  4. PredNet --- Deep Predictive coding networks for video prediction and unsupervised learning --- 论文笔记

    PredNet --- Deep Predictive coding networks for video prediction and unsupervised learning   ICLR 20 ...

  5. [CodeForce 801A] Vicious Keyboard

    题目链接:http://codeforces.com/problemset/problem/801/A 思路:题目中字符串的长度最长100个字符,所以,可以考虑用暴力,先遍历一遍匹配"VK& ...

  6. Rime输入法的配色方案

    致青春 so_young: name: "致青春/So Young" author: "五磅兔 zcunlin@foxmail.com" text_color: ...

  7. (转载)http和socket之长连接和短连接区别

    TCP/IPTCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议.在传输层中有TCP协议与UDP协议.在应用层有: ...

  8. Dependency Injection2

    IoC容器和Dependency Injection 模式   使用 Service Locator 依赖注入的最大好处在于:它消除了MovieLister类对具体 MovieFinder实现类的依赖 ...

  9. NLog汇总

    相关文章 NLog文章系列——系列文章目录以及简要介绍 Elasticsearch,Kibana,Logstash,NLog实现ASP.NET Core 分布式日志系统 ElasticSearch+N ...

  10. CSS sprites

    CSS Sprites在国内很多人叫css精灵,是一种网页图片应用处理方式. 优点: 它允许你将一个页面涉及到的所有零星图片都包含到一张大图中去,这样一来,当访问该页面时,载入的图片就不会像以前那样一 ...