Minimum Ties—CF1487C
C o d e Code Code
#include
#define int long long
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
using namespace std;
using PII = pair<int, int>;
using i128 = __int128;
const int N = 2e5 + 10;
int n;
void solve() {
cin >> n;
if (n & 1) { // 一半win, 一半fail
for (int i = 1; i <= n; i ++) {
for (int j = i + 1; j <= n; j ++) {
if (j - i <= (n - 1) / 2) {
cout << "1 ";
} else {
cout << "-1 ";
}
}
}
} else { // 多一个平局(每个点的正对面位置)
for (int i = 1; i <= n; i ++) {
for (int j = i + 1; j <= n; j ++) {
if (j - i <= (n - 1) / 2) {
cout << "1 ";
} else if (j - i == (n - 1) / 2 + 1) {
cout << "0 ";
} else {
cout << "-1 ";
}
}
}
}
cout << "\n";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
cin >> T; cin.get();
while (T --) solve();
return 0;
}