IOI 98称号。然后,它似乎没有很困难。即使我能做到这一点微弱的残留物。所有的button按两次不按,高达因此实际上总的等效按4二级,首先C往下<=4,则搜索将能直接照射,总共只有16状态(事实上,没有),需要注意的是重判和订购,我们会处理的话非常快的二进制。= =不幸的是,我不会,转字符串。假设数据大点直接就挂了= =

/*
ID:kevin_s1
PROG:lamps
LANG:C++
*/ #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <list>
#include <cmath>
#include <bitset>
#include <strstream> using namespace std; //gobal variable====
int N;
int C;
int state[101];
int on, off;
int ons[101], offs[101];
int _count;
vector<long long> hash;
vector<string> result;
//================== //function==========
void print(){
for(int i = 1; i <= N; i++){
cout<<state[i];
}
cout<<endl;
} void init(){
for(int i = 1; i <= N; i++)
state[i] = 1;
} bool check(){
for(int i = 0; i < on; i++){
if(state[ons[i]] != 1){
return false;
}
}
for(int i = 0; i < off; i++){
if(state[offs[i]] != 0){
return false;
}
}
return true;
} void change(int i){
if(state[i] == 0)
state[i] = 1;
else if(state[i] == 1)
state[i] = 0;
} void Button1(){
for(int i = 1; i <= N; i++){
change(i);
}
} void Button2(){
for(int i = 1; i <= N; i+=2){
change(i);
}
} void Button3(){
for(int i = 2; i <= N; i+=2){
change(i);
}
} void Button4(){
for(int i = 0; (3*i + 1) <= N; i++){
int k = 3 * i + 1;
change(k);
}
} void Button(int i){
if(i == 1)
Button1();
if(i == 2)
Button2();
if(i == 3)
Button3();
if(i == 4)
Button4();
} void DFS(int i){
if(i > C)
return;
if(check()){
long long sum = 0;
for(int i = 1; i <= N; i++){
sum = sum * 10;
sum = sum + state[i];
}
vector<long long>::iterator iter = find(hash.begin(), hash.end(), sum);
if(iter == hash.end()){
_count++;
hash.push_back(sum);
string str;
for(int i = 1; i <= N; i++){
char ch = state[i] + 48;
str = str + ch;
}
result.push_back(str);
}
}
for(int j = 1; j <= 4; j++){
Button(j);
DFS(i + 1);
Button(j);
}
return;
} //================== int main(){
freopen("lamps.in","r",stdin);
freopen("lamps.out","w",stdout);
cin>>N;
cin>>C;
on = 0, off = 0;
_count = 0;
int _on, _off;
while(cin>>_on && _on != -1){
ons[on++] = _on;
}
while(cin>>_off && _off != -1){
offs[off++] = _off;
}
init();
while(C > 4){
C = C - 2;
}
DFS(0);
sort(result.begin(), result.end(), less<string>());
vector<string>::iterator iter = result.begin();
for(;iter != result.end(); iter++){
cout<<*iter<<endl;
}
if(_count == 0){
cout<<"IMPOSSIBLE"<<endl;
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

最新文章

  1. POJ1229 域名匹配
  2. MDI窗体 的再度思考
  3. 算法之插入排序(inertionSort)
  4. image控件读取数据库二进制图片
  5. license文件生成原理
  6. JQ兼容性问题
  7. last期末作业
  8. 在C#中winform程序中应用nlog日志工具
  9. windows update error 0x8024401c
  10. ACM练习中关于LCS的题目
  11. 第一章 Java入门
  12. Codeforces1099F. Cookies(线段树+dp+贪心+博弈)
  13. SQL SERVER 查看数据库安装时间
  14. python学习之条件语句(if循环)
  15. VMware&#160;Linux虚拟机与WIN7操作系统共享无线网络上网配置
  16. Atitit Loading 动画效果
  17. Highcharts 多个Y轴动态刷新数据
  18. AngularJs表单自动验证
  19. 用java数组模拟购物商城功能与实现
  20. redis集群搭建+lua脚本的使用

热门文章

  1. Android onConfigurationChanged(Configuration cfg) 无法触发问题
  2. Android开发手记(23) Notification
  3. Cacti添加threshold、monitor和setting
  4. Cisco CatOS系统交换机的SPAN配置
  5. Adb shell 常用命令
  6. Java学习----Java数据类型
  7. HTML5手机开发——滚动和惯性缓动
  8. 在linux下将当前目录文件全部小写含目录名
  9. JS中break continue和return的用法?
  10. CodeForces 569A 第六周比赛C踢