제출 #985219

#제출 시각아이디문제언어결과실행 시간메모리
985219AdamGSTable Tennis (JOI24_tabletennis)C++17
100 / 100
608 ms16552 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() const int LIM=5e3+7; bitset<LIM>T[LIM]; vector<pair<ll,ll>>merge(vector<pair<ll,ll>>A, vector<pair<ll,ll>>B) { vector<pair<ll,ll>>P; ll l=0; for(auto i : A) { while(l<B.size() && B[l]<i) { P.pb(B[l]); ++l; } P.pb(i); } while(l<B.size()) { P.pb(B[l]); ++l; } return P; } void solve() { ll n, m; cin >> n >> m; rep(i, n) rep(j, n) T[i][j]=0; vector<pair<ll,ll>>P; rep(i, n) P.pb({i, i}); int a=0, b=n-1; while(m && P[0].st+1<P[n-1].st) { while(P[a+1].st==P[0].st) ++a; vector<pair<ll,ll>>A, B; if(P[n-1].st-P[0].st-1>m) { for(int i=1; i<n; ++i) if(P[i].st-P[a].st-1==m) { m-=P[i].st-P[a].st-1; --P[i].st; ++P[a].st; break; } } else { m-=P[b].st-P[a].st-1; ++P[a].st; --P[b].st; } while(P[a].st!=P[0].st) --a; while(P[b].st!=P[n-1].st) ++b; while(a<n-1 && P[a+1].st==P[0].st) ++a; while(b>0 && P[b-1].st==P[n-1].st) --b; } if(m) { cout << "No\n"; return; } cout << "Yes\n"; rep(i, n-1) { vector<pair<ll,ll>>A, B; 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; B.pb(P[j]); } else { T[P[0].nd][P[j].nd]=0; T[P[j].nd][P[0].nd]=1; A.pb(P[j]); } } P=merge(A, B); } 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(); }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'std::vector<std::pair<long long int, long long int> > merge(std::vector<std::pair<long long int, long long int> >, std::vector<std::pair<long long int, long long int> >)':
Main.cpp:16:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     while(l<B.size() && B[l]<i) {
      |           ~^~~~~~~~~
Main.cpp:22:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   while(l<B.size()) {
      |         ~^~~~~~~~~
Main.cpp: In function 'void solve()':
Main.cpp:62: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]
   62 |     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...