记录编号 569798 评测结果 AAAAAAAA
题目名称 [USACO 2.2] 派对灯 最终得分 100
用户昵称 Gravatarlihaoze 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2022-03-16 23:25:03 内存使用 0.00 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
#define MAX(_a, _b) [&](int __a, int __b) { return __a < __b ? __b : __a; }((_a), (_b))
#define MIN(_a, _b) [&](int __a, int __b) { return __a > __b ? __b : __a; }((_a), (_b))
#define ABS(_x) [&](int __x) { return __x < 0 ? -__x : __x; }(_x)
#define fi first
#define se second 

using ll = long long;
using PII = std::pair<int, int>;

namespace IO {
    template <typename T> inline T read() {
        char ch = getchar();
        T ret = 0, sig = 1;
        while(ch < '0' || ch > '9') { if(ch == '-') sig = -1; ch = getchar(); }
        while(ch >= '0' && ch <= '9') ret *= 10, ret += ch - 48, ch = getchar();
        return ret * sig;
    }
    template <typename T> inline void write(T out) {
        if(!out) { putchar('0'), putchar(' '); return; }
        int stk[100], tt = 0;
        if(out < 0) out = -out, putchar('-');
        while(out) stk[tt++] = out % 10, out /= 10;
        for(register int i = --tt; i>=0; --i) putchar(stk[i] + 48);
        putchar(' ');
    }
    template <typename T> inline void read(T& ret) { ret = IO::read<T>(); }
    template <typename T, typename... Args> inline void read(T& x, Args&... args) { IO::read(x), IO::read(args...); }
    template <typename T, typename... Args> inline void write(T x, Args... args)  { IO::write(x), IO::write(args...); }
};


int n, c, a[10];
bool flag;

const int g[8][7] = {
    0, 0, 0, 0, 0, 0, 0, 
    1, 0, 0, 1, 1, 1, 0,
    2, 0, 1, 0, 1, 0, 1,
    3, 0, 1, 1, 0, 1, 1,
    4, 1, 0, 0, 1, 0, 0,
    5, 1, 0, 1, 0, 1, 0,
    6, 1, 1, 0, 0, 0, 1,
    7, 1, 1, 1, 1, 1, 1
};

inline void check(int x) {
    for(register int i = 1; i<=6; ++i) 
        if(a[i] != -1 && g[x][i] != a[i]) return;
    for(register int i = 1; i<=n; ++i) putchar(g[x][(i-1) % 6 + 1] + 48);
    puts("");
    flag = true;
}

int main() {
    #ifdef DEBUG
    OPEN(test);
    #endif
    OPEN(lamps);
    IO::read(n, c);
    memset(a, -1, sizeof a);
    int x;
    while(~scanf("%d", &x), x != -1) a[(x-1) % 6 + 1] = 1;
    while(~scanf("%d", &x), x != -1) a[(x-1) % 6 + 1] = 0;
    if(!c) check(7);
    else if(c == 1) check(0), check(2), check(3), check(5);
    else for(register int i = 0; i<8; ++i) if(c != 2 || i != 3) check(i);
    if(!flag) puts("IMPOSSIBLE");
    return 0;
}