Guest User

Untitled

a guest
Mar 16th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.   freopen("in.c","r", stdin);
  8.   freopen("out.c","w", stdout);
  9.   int TC, NC = 1;
  10.  
  11.   cin>>TC;
  12.  
  13.   int ans[55][55];
  14.   for(int i = 1 ; i<50 ;i++){
  15.     for(int j = 0 ; j<50 ;j++){
  16.       if(i<j) ans[i][j] = 1;
  17.       else ans[i][j] = 0;
  18.     }
  19.   }
  20.  
  21.   while(TC--){
  22.     long long B, M;
  23.  
  24.     cin>>B>>M;
  25.  
  26.  
  27.     for(int i = 0 ; i<B ;i++){
  28.       ans[0][i] = 0;
  29.     }
  30.  
  31.  
  32.     if(M > (1LL<<(B-2) ) ){
  33.       cout<<"Case #"<<NC++<<": IMPOSSIBLE"<<endl;
  34.       //break;
  35.     }else{
  36.       cout<<"Case #"<<NC++<<": POSSIBLE"<<endl;
  37.       M--;
  38.  
  39.       ans[0][B-1] = 1;
  40.       for(int i = 0 ; i<50 ;i++){
  41.         if( (1LL<<i)&M ){
  42.           ans[0][B-2-i] = 1;
  43.         }
  44.       }
  45.  
  46.       for(int i = 0 ; i<B ;i++){
  47.         for(int j = 0 ; j<B ;j++){
  48.           cout<<ans[i][j]<<" ";
  49.         }
  50.         cout<<endl;
  51.       }
  52.  
  53.     }
  54.  
  55.   }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment