[构造] Codeforces 736E #382 (Div. 1) E. Chess Championship
2017-04-07 06:46
399 查看
有m个人参加比赛,每两个人都恰好比了一场
两个人比赛如果一方赢了,那么得到2分,平局得到1分,输了得到0分。
告诉你排行榜前n个人的得分,构造比赛满足条件
n<=m<=3000
充要条件就是分数按从小到大排,前i小的分数总和不小于i(i-1),m个人的分数总和为m(m-1)
构造的时候是选择分数最高的人,让他在分数高的人比赛中失败,低的人比赛中获胜
我们只知道前m个人的分数,从上面的条件观察后面的人分数越高越好,所以剩下的分数均匀分配
两个人比赛如果一方赢了,那么得到2分,平局得到1分,输了得到0分。
告诉你排行榜前n个人的得分,构造比赛满足条件
n<=m<=3000
充要条件就是分数按从小到大排,前i小的分数总和不小于i(i-1),m个人的分数总和为m(m-1)
构造的时候是选择分数最高的人,让他在分数高的人比赛中失败,低的人比赛中获胜
我们只知道前m个人的分数,从上面的条件观察后面的人分数越高越好,所以剩下的分数均匀分配
#include<cstdio> #include<cstdlib> #include<algorithm> #include<functional> using namespace std; typedef pair<int,int> abcd; const int N=3005; int n,m; abcd a ; char d ; #define read(x) scanf("%d",&(x)) int main(){ freopen("t.in","r",stdin); freopen("t.out","w",stdout); read(m); read(n); int t=0,minv=1<<30; for (int i=m-n+1;i<=m;i++) read(a[i].first),a[i].second=i,t+=a[i].first,minv=min(minv,a[i].first); if (t>m*(m-1)) return printf("no\n"),0; t=m*(m-1)-t; for (int i=1;i<=m-n;i++) a[i]=abcd(t/(m-n)+(i<=t%(m-n)),i); if (m-n && a[1].first>minv) return printf("no\n"),0; sort(a+1,a+m+1); t=0; for (int i=1;i<=m;i++){ t+=a[i].first; if (t<i*(i-1)) return printf("no\n"),0; } for (int i=1;i<=m;i++) d[i][i]='X'; for (int i=m;i;i--){ sort(a+1,a+i+1); int t=a[i].first; for (int j=1;j<i;j++){ if (t>1) t-=2,d[a[i].second][a[j].second]='W',d[a[j].second][a[i].second]='L'; else if (t==1) t--,a[j].first--,d[a[i].second][a[j].second]=d[a[j].second][a[i].second]='D'; else a[j].first-=2,d[a[i].second][a[j].second]='L',d[a[j].second][a[i].second]='W'; } } printf("yes\n"); for (int i=1;i<=m;i++) printf("%s\n",d[i]+1); return 0; }
相关文章推荐
- [构造] Codeforces 226D #140 (Div. 1) D. The table
- [并查集 构造] Codeforces 723F#375 (Div. 2) F. st-Spanning Tree
- CodeForces-329C(div1):Graph Reconstruction(随机&构造)
- Codeforces Round #347 (Div. 2) B. Rebus (codeforces 664b) (构造)
- CodeForces 417C(RCC 2014 Warmup (Div. 2) C)(构造)
- [CodeForces] Round #313 Div 2 E / Div 1 C Gerald and Giant Chess 不用容斥的递推组合数学
- [构造] Codeforces 468C #268 (Div. 1) C. Hack it!
- 【Codeforces Round #313 (Div. 1) C】 CodeForces 559C Gerald and Giant Chess
- [构造] Codeforces 804E Round #411 (Div. 1) E. The same permutation
- [欧拉回路 构造 || 网络流] Codeforces 723E #375 (Div. 2) E. One-Way Reform
- Codeforces Round #209 (Div. 2) B && Codeforces 359 B(构造)
- [扫描线 二分图最大匹配 线段树优化网络流] Codeforces 793G Tinkoff Challenge - Elimination Round G. Oleg and chess
- codeforces 260 div2 B题
- codeforces div2 round#231 B
- dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess
- codeforces div2 round#230 D
- CodeForces 550D - Regular Bridge(构造)
- Codeforces 388B Fox and Minimal path(构造最短路条数为N的图)
- AIM Tech Round 3 (Div. 2) D. Recover the String (构造)
- [欧拉回路] Codeforces 528C #296 (Div. 1) C. Data Center Drama