比赛 20120612 评测结果 AAAAA
题目名称 灯光 最终得分 100
用户昵称 feng 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2012-06-12 18:57:32
显示代码纯文本
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main()
  5. {
  6. ifstream fin("partya.in");
  7. ofstream fout("partya.out");
  8. int n,c,kai[101],guan[101],lk=0,lg=0,now[101],count=0,res[17][101];
  9. fin>>n>>c;
  10. int x;
  11. fin>>x;
  12. for (;x!=-1;)
  13. {
  14. lk++;
  15. kai[lk]=x;
  16. fin>>x;
  17. }
  18. fin>>x;
  19. for (;x!=-1;)
  20. {
  21. lg++;
  22. guan[lg]=x;
  23. fin>>x;
  24. }
  25. for (int i=1;i<=n;i++)
  26. now[i]=1;
  27. for (int i=1;i>=0;i--)
  28. {
  29. for (int s=1;s<=n;s++)
  30. now[s]=1-now[s];
  31. for (int j=1;j>=0;j--)
  32. {
  33. for (int s=1;s<=n;s+=2)
  34. now[s]=1-now[s];
  35. for (int k=1;k>=0;k--)
  36. {
  37. for (int s=2;s<=n;s+=2)
  38. now[s]=1-now[s];
  39. for (int t=1;t>=0;t--)
  40. {
  41. for (int s=1;s<=n;s+=3)
  42. now[s]=1-now[s];
  43. bool okay=true;
  44. int ss=i+j+k+t;
  45. if ((ss>c)||((ss%2)!=(c%2))) continue;
  46. for (int s=1;s<=lk;s++)
  47. if (now[kai[s]]==0)
  48. {
  49. okay=false;
  50. break;
  51. }
  52. for (int s=1;s<=lg;s++)
  53. if (now[guan[s]]==1)
  54. {
  55. okay=false;
  56. break;
  57. }
  58. if (okay)
  59. {
  60. count++;
  61. for (int s=1;s<=n;s++)
  62. res[count][s]=now[s];
  63. }
  64. }
  65. }
  66. }
  67. }
  68. for (int i=1;i<=count;i++)
  69. {
  70. for (int j=i+1;j<=count;j++)
  71. {
  72. bool big=false;
  73. for (int k=1;k<=n;k++)
  74. {
  75. if (res[i][k]!=res[j][k])
  76. {
  77. big=(res[i][k]>res[j][k])?true:false;
  78. break;
  79. }
  80. }
  81. if (big)
  82. {
  83. int tmp;
  84. for (int k=1;k<=n;k++)
  85. {
  86. tmp=res[i][k];
  87. res[i][k]=res[j][k];
  88. res[j][k]=tmp;
  89. }
  90. }
  91. }
  92. }
  93. for (int i=1;i<=count;i++)
  94. {
  95. for (int j=1;j<=n;j++)
  96. fout<<res[i][j];
  97. fout<<endl;
  98. }
  99. if (count==0) fout<<"IMPOSSIBLE"<<endl;
  100. return 0;
  101. }