# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985209 | AdamGS | Table Tennis (JOI24_tabletennis) | C++17 | 1020 ms | 209204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void solve() {
ll n, m;
cin >> n >> m;
ll T[n][n];
rep(i, n) rep(j, n) T[i][j]=0;
vector<pair<ll,ll>>P;
rep(i, n) P.pb({i, i});
while(m && P[0].st+1<P[n-1].st) {
if(P[n-1].st-P[0].st-1>m) {
for(int i=1; i<n; ++i) if(P[i].st-P[0].st-1==m) {
m-=P[i].st-P[0].st-1;
--P[i].st;
++P[0].st;
break;
}
} else {
m-=P[n-1].st-P[0].st-1;
++P[0].st;
--P[n-1].st;
}
sort(all(P));
}
if(m) {
cout << "No\n";
return;
}
cout << "Yes\n";
rep(i, n-1) {
vector<pair<ll,ll>>S;
for(int j=1; j<P.size(); ++j) {
if(j>P[0].st) {
--P[j].st;
T[P[0].nd][P[j].nd]=1;
T[P[j].nd][P[0].nd]=0;
} else {
T[P[0].nd][P[j].nd]=0;
T[P[j].nd][P[0].nd]=1;
}
S.pb(P[j]);
}
P=S;
sort(all(P));
}
for(int i=1; i<n; ++i) {
rep(j, i) cout << T[i][j];
cout << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int _=1;
cin >> _;
while(_--) solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |