Submission #985209

#TimeUsernameProblemLanguageResultExecution timeMemory
985209AdamGSTable Tennis (JOI24_tabletennis)C++17
77 / 100
1020 ms209204 KiB
#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)

Main.cpp: In function 'void solve()':
Main.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int j=1; j<P.size(); ++j) {
      |                  ~^~~~~~~~~
#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...