Submission #1039038

#TimeUsernameProblemLanguageResultExecution timeMemory
1039038UnforgettableplTable Tennis (JOI24_tabletennis)C++17
9 / 100
1070 ms16432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void strat1(int n,int m){ cout << "Yes\n"; vector<vector<bool>> win(n+1,vector<bool>(n+1,true)); win[n][n-1-m]=false; for(int i=2;i<=n;i++){ for(int j=1;j<i;j++){ if(win[i][j])cout<<'1'; else cout<<'0'; } cout << '\n'; } } void solve(){ int n,m; cin >> n >> m; if(m<=n-2){strat1(n,m);return;} 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...