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;
#define int long long
void solve(){
int n,m;
cin >> n >> m;
int edges = (n*(n-1))/2;
auto test = [&](int x){
vector<vector<bool>> wins(n+1,vector<bool>(n+1));
int idx = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<i;j++){
wins[i][j]=x&(1<<(idx++));
}
}
int curr = 0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(wins[j][i]==wins[k][j] and wins[k][j]!=wins[k][i])curr++;
}
}
}
if(curr==m){
cout << "Yes\n";
for(int i=2;i<=n;i++){
for(int j=1;j<i;j++){
if(wins[i][j])cout<<'1';
else cout<<'0';
}
cout << '\n';
}
return true;
}
return false;
};
for(int mask=0;mask<(1<<edges);mask++){
if(test(mask))return;
}
cout << "No\n";
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int q;
cin >> q;
while(q--)solve();
}
# | 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... |