用户:
一缕余晖查看:33 回复:8 评论:33 创建时间:2021-11-27T11:38:34
当然这可不是kitten党的地方,我想找一个精通python游戏制作的,是pygame更好哦(前提有QQ,还不能像Albert、ph、竹林菌那么懒的。
蒟蒻OIer1048576#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <string>
#include <bitset>
using namespace std;
bitset<128> ans[16];
int n, m, on[128], off[128], top, top1, top2;
bool check(bitset<128> a) {
for (int i = 0; i < top1; ++i) if (!a[on[i]]) return false;
for (int i = 0; i < top2; ++i) if (a[off[i]]) return false;
return true;
}
bool cmp(bitset<128> a, bitset<128> b) {
for (int i = n - 1; i >= 0; --i) {
if (int(a[i]) > int(b[i])) return false;
if (int(a[i]) < int(b[i])) return true;
}
return false;
}
bool eql(bitset<128> a, bitset<128> b) {
for (int i = n - 1; i >= 0; --i) {
if (int(a[i]) != int(b[i])) return false;
}
return true;
}
int main() {
cin >> n >> m;
int p = 0; cin >> p; while (p != -1) {
on[top1++] = n - p;
cin >> p;
}
p = 0; cin >> p; while (p != -1) {
off[top2++] = n - p;
cin >> p;
}
for (int i = 0; i < 16; ++i) {
int k = 0; bitset<128> a;
a.flip();
if (i & 1) { a.flip(); }
if (i & 2) for (int i = 2; i <= n; i += 2) { a.flip(n - i); }
if (i & 4) for (int i = 1; i <= n; i += 2) { a.flip(n - i); }
if (i & 8) for (int i = 1; i <= n; i += 3) { a.flip(n - i); }
for (int j = 0 ; j < 4 ; ++ j) if (i & (1 << j)) k++;
if (check(a) && ((k & 1) == (m & 1)) && k <= m) {ans[top++] = a;/*cout << i << endl;*/}
}
sort(ans, ans + top, cmp);
top = unique(ans, ans + top , eql) - ans;
if (!top) {
cout << "IMPOSSIBLE";
return 0;
}
for (int i = 0; i < top; ++i) {
string str = ans[i].to_string();
str.erase(0, str.size() - n);
cout << str << endl;
}
}
看得懂?
点赞0
评论