QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506387 | #8474. Matrices and Sums | zhoukangyang# | AC ✓ | 36ms | 24260kb | C++14 | 1.6kb | 2024-08-05 17:05:47 | 2024-08-05 17:05:47 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
#define pb emplace_back
#define i128 __int128
using namespace std;
const int N = 5007;
int n;
int ans[N][N];
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
if(n & 1) {
cout << "No\n";
return 0;
}
int l = 1, r = n;
L(t, 1, n / 2) {
L(i, l, r) ans[l][i] = 1;
L(i, l + 1, r - 1) ans[i][l] = 1;
L(i, l + 1, r) ans[r][i] = -1;
L(i, l + 1, r - 1) ans[i][r] = -1;
++l, --r;
}
cout << "Yes\n";
L(i, 1, n) {
L(j, 1, n) {
cout << ans[i][j] << " \n"[j == n];
}
}
set<int>st;
L(i, 1, n) {
int s1 = 0, s2 = 0;
L(j, 1, n) {
s1 += ans[i][j];
s2 += ans[j][i];
}
st.insert(s1);
st.insert(s2);
}
assert(sz(st) == n * 2);
// n = 3;
// int pw = pow(3, n * n);
// L(i, 0, pw - 1) {
// int mat[4][4];
// me(mat, 0);
// int val = i;
// L(i, 1, n) {
// L(j, 1, n) {
// mat[i][j] = val % 3 - 1;
// val /= 3;
// }
// }
// set<int>st;
// L(i, 1, n) {
// int s1 = 0, s2 = 0;
// L(j, 1, n) {
// s1 += mat[i][j];
// s2 += mat[j][i];
// }
// st.insert(s1);
// st.insert(s2);
// }
// if(sz(st) == n * 2) {
// L(i, 1, n) {
// L(j, 1, n) {
// cout << mat[i][j] << " \n"[j == n];
// }
// }
// return 0;
// }
// }
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2
output:
Yes 1 1 0 -1
result:
ok OK, Accepted.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1
output:
No
result:
ok OK, Accepted.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
3
output:
No
result:
ok OK, Accepted.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
4
output:
Yes 1 1 1 1 1 1 1 -1 1 0 -1 -1 0 -1 -1 -1
result:
ok OK, Accepted.
Test #5:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
5
output:
No
result:
ok OK, Accepted.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
6
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 0 -1 -1 -1 1 0 -1 -1 -1 -1 0 -1 -1 -1 -1 -1
result:
ok OK, Accepted.
Test #7:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
7
output:
No
result:
ok OK, Accepted.
Test #8:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
8
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 1 1 1 0 -1 -1 -1 -1 1 1 0 -1 -1 -1 -1 -1 1 0 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1
result:
ok OK, Accepted.
Test #9:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
9
output:
No
result:
ok OK, Accepted.
Test #10:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
10
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 0 -1 -1 -1 -1 -1 1 1 1 0 -1 -1 -1 -1 -1 -1 1 1 0 -1 -1 -1 -1 -1 -1 -1 1 0 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok OK, Accepted.
Test #11:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
21
output:
No
result:
ok OK, Accepted.
Test #12:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
37
output:
No
result:
ok OK, Accepted.
Test #13:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
73
output:
No
result:
ok OK, Accepted.
Test #14:
score: 0
Accepted
time: 1ms
memory: 6292kb
input:
100
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok OK, Accepted.
Test #15:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
233
output:
No
result:
ok OK, Accepted.
Test #16:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
555
output:
No
result:
ok OK, Accepted.
Test #17:
score: 0
Accepted
time: 13ms
memory: 16812kb
input:
666
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok OK, Accepted.
Test #18:
score: 0
Accepted
time: 25ms
memory: 20680kb
input:
888
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok OK, Accepted.
Test #19:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
999
output:
No
result:
ok OK, Accepted.
Test #20:
score: 0
Accepted
time: 36ms
memory: 24260kb
input:
1000
output:
Yes 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok OK, Accepted.