Codeforces Round #382 (Div. 1), problem: (E) Chess Championship Solution in C/C++

By | 2017-04-07T22:11:48+00:00 December 17th, 2016|Categories: C/C++, Programming|Tags: , , , , , , |

#include<iostream> #include<cstdio> #include<algorithm> #define N 3010 using namespace std; int n,m,f[N][N]; struct ma{int x,y;}a[N]; bool operator<(ma p,ma q){return p.x>q.x;} void get(int k) { sort(a+k,a+n+1); int w=a[k].x; for(int i=n;i>k;i--) { if(w>1) w-=2,f[a[k].y][a[i].y]=1; else if(!w) a[i].x-=2,f[a[i].y][a[k].y]=1; else w--,a[i].x--,f[a[k].y][a[i].y]=f[a[i].y][a[k].y]=2; } a[k].x=0; } int main() { cin>>n>>m; int [...]