提交时间:2024-03-27 13:40:49

运行 ID: 139961

# include <bits/stdc++.h> # define fs fixed << setprecision # define wt while ( 1 ) # define ld long double # define ll long long # define ctn continue # define brk break # define rt return using namespace std ; int flg [7] , n , c , k ; bool flag ; int stt [9] [7] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 1 , 2 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 2 , 1 , 1 , 0 , 0 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , } ; int loc ( int x ) { rt ( x % 6 == 0 ? 6 : x % 6 ) ; } bool chk ( int s ) { if ( stt [s] [0] > c || ( c == 2 && s == 4 ) || ( c == 3 && ( s == 2 || s == 5 || s == 7 ) ) || ( c == 1 && s == 8 ) ) { rt 0 ; } for ( int i = 1 ; i <= 6 ; i ++ ) { if ( flg [i] == -1 ) { continue ; } if ( stt [s] [i] != flg [i] ) { rt 0 ; } } rt 1 ; } int main ( ) { memset ( flg , -1 , 6 ) ; cin >> n >> c ; wt { cin >> k ; if ( ! k ) { brk ; } flg [loc ( k )] = 1 ; } wt { cin >> k ; if ( ! k ) { brk ; } flg [loc ( k )] = 0 ; } for ( int i = 1 ; i <= 8 ; i ++ ) { if ( chk ( i ) ) { for ( int j = 1 ; j <= n ; j ++ ) { cout << stt [i] [loc ( j )] ; } cout << endl ; flag = 1 ; } } if ( ! flag ) { cout << "IMPOSSIBLE" << endl ; } rt 0 ; }