結果

問題 No.2212 One XOR Matrix
ユーザー planesplanes
提出日時 2023-02-12 16:34:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 3,966 ms
コンパイル使用メモリ 170,948 KB
実行使用メモリ 11,204 KB
最終ジャッジ日時 2023-09-23 05:49:23
合計ジャッジ時間 4,817 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 29 ms
5,212 KB
testcase_09 AC 110 ms
11,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

int main() {
  ll N;cin>>N;
  if(N==1) {
    cout<<-1<<endl;
    return 0;
  }

  vector<vector<ll>> a((1LL<<N),vector<ll> (1LL<<N));
  for(ll i=0;i<(1LL<<(N-1));i++) {
    ll k=(1LL<<(N))*i;
    if(i%2==0) {
        for(ll j=0;j<(1LL<<N);j++) {
            a[j][i]=k+j;
            a[j][i]*=2;
            a[j][i]++;
            
        }
    }

    else {
        for(ll j=(1LL<<N)-1;j>=0;j--) {
            a[j][i]=k+(1LL<<N)-1-j;
            a[j][i]*=2;
            a[j][i]++;

        }
    }
  }

  for(ll i=(1LL<<N)-1;i>=(1LL<<(N-1));i--) {
    ll k=(1LL<<(N))*((1LL<<N)-1-i);
    if(i%2!=0) {
        for(ll j=(1LL<<N)-1;j>=0;j--) {
            a[j][i]=k+(1LL<<N)-1-j;
            a[j][i]*=2;

        }
    }

    else {
        for(ll j=0;j<(1LL<<N);j++) {
            a[j][i]=k+j;
          a[j][i]*=2;


        }
    }
  }



for(ll i=0;i<(1LL<<(N-1));i++) {
    a[(1LL<<(N-1))+i][i]--;
}

for(ll i=(1LL<<(N-1));i<(1LL<<N);i++) {
    a[i-(1LL<<N-1)][i]++;
}



for(ll i=0;i<(1LL<<N);i++) {
    for(ll j=0;j<(1LL<<N);j++) {
        cout<<a[i][j]<<" ";
    }
    cout<<endl;
}
}

  

0