1 solutions
-
0
#include<bits/stdc++.h> #include<time.h> using namespace std; #define ioio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl "\n" #define debug(x) cout<<#x<<":"<<x<<endl; #define P pair #define P1 first #define P2 second #define u_map unordered_map #define p_queue priority_queue typedef long long ll; const double eps = 1e-6; const int mod = 1e9 + 7; const int INF = 0x3f3f3f3f; const int N = 1e3 + 30; int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; /*-------------------------------------------------*/ int n; void slove() { cin >> n; if (n % 2 == 0) { for (int i = 0; i < n; i ++ ) { for (int j = 0; j < n; j ++ ) { if (i == j && i % 2 == 1) cout << 0; else cout << 1; } cout << endl; } } else { for (int i = 0; i < n; i ++ ) { for (int j = 0; j < n; j ++ ) { if (i == j && i % 2 == 0) cout << 0; else cout << 1; } cout << endl; } } } int main() { ioio int t = 1; cin >> t; while (t--) { slove(); } return 0; }
- 1
Information
- ID
- 6644
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 79
- Accepted
- 21
- Uploaded By