Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
125715 | 周歆童(初一23 | 派对灯 | C++ | 通过 | 100 | 0 MS | 248 KB | 1118 | 2024-01-23 21:44:52 |
#include<bits/stdc++.h> using namespace std; int n,c,on[105],off[105],cnton,cntoff; bool light[105]; set<string>ans; int main(){ cin>>n>>c; while(cin>>on[++cnton]&&on[cnton]!=-1); while(cin>>off[++cntoff]&&off[cntoff]!=-1); for(int i=0;i<16;i++){ memset(light,1,sizeof(light)); int cnt=0; bool flag=1; if(i&1){ cnt++; memset(light,0,sizeof(light)); } if((i>>1)&1){ cnt++; for(int j=1;j<=n;j++){ if(j%2)light[j]=!light[j]; } } if((i>>2)&1){ cnt++; for(int j=1;j<=n;j++){ if(j%2==0)light[j]=!light[j]; } } if((i>>3)&1){ cnt++; for(int j=1;j<=n;j++){ if(j%3==1)light[j]=!light[j]; } } if(c<cnt||c-cnt==1)continue; for(int j=1;j<cnton;j++){ if(!light[on[j]]){ flag=0; break; } } for(int j=1;j<cntoff;j++){ if(light[off[j]]){ flag=0; break; } } if(flag){ string s=""; for(int i=1;i<=n;i++){ s+=char(light[i]+'0'); } ans.insert(s); } } for(auto it:ans){ cout<<it<<endl; } if(ans.empty()){ cout<<"IMPOSSIBLE"; } return 0; }