Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- freopen("in.c","r", stdin);
- freopen("out.c","w", stdout);
- int TC, NC = 1;
- cin>>TC;
- int ans[55][55];
- for(int i = 1 ; i<50 ;i++){
- for(int j = 0 ; j<50 ;j++){
- if(i<j) ans[i][j] = 1;
- else ans[i][j] = 0;
- }
- }
- while(TC--){
- long long B, M;
- cin>>B>>M;
- for(int i = 0 ; i<B ;i++){
- ans[0][i] = 0;
- }
- if(M > (1LL<<(B-2) ) ){
- cout<<"Case #"<<NC++<<": IMPOSSIBLE"<<endl;
- //break;
- }else{
- cout<<"Case #"<<NC++<<": POSSIBLE"<<endl;
- M--;
- ans[0][B-1] = 1;
- for(int i = 0 ; i<50 ;i++){
- if( (1LL<<i)&M ){
- ans[0][B-2-i] = 1;
- }
- }
- for(int i = 0 ; i<B ;i++){
- for(int j = 0 ; j<B ;j++){
- cout<<ans[i][j]<<" ";
- }
- cout<<endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment