답안 #208603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208603 2020-03-11T19:15:57 Z MKopchev Conspiracy (POI11_kon) C++14
90 / 100
3000 ms 115384 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=5000+42;
int n;
int deg[nmax];

bool cmp(int a,int b)
{
    return a>b;
}

long long comb(int s,int t)
{
    t=min(t,s-t);

    long long ret=1;
    for(int i=1;i<=t;i++)
        ret=ret*(s+1-i)/i;

    return ret;
}
int main()
{
    scanf("%i",&n);

    for(int i=1;i<=n;i++)
    {
        int SZ,to;
        scanf("%i",&deg[i]);
        for(int j=1;j<=deg[i];j++)
        {
            scanf("%i",&to);
        }
    }
    sort(deg+1,deg+n+1,cmp);

    long long output=0;
    for(int k=1;k<n;k++)
    {
        int sum_left=0,sum_right=k*(k-1);
        for(int j=1;j<=k;j++)sum_left+=deg[j];
        for(int j=k+1;j<=n;j++)sum_right+=deg[j];

        if(sum_left==sum_right)
        {
            int eq=0,eq_taken=0;
            for(int j=1;j<=k;j++)
                if(deg[j]==deg[k])eq_taken++;
            for(int j=1;j<=n;j++)
                if(deg[j]==deg[k])eq++;

            output=output+comb(eq,eq_taken);
        }
    }

    printf("%lld\n",output);
    return 0;
}

Compilation message

kon.cpp: In function 'int main()':
kon.cpp:28:13: warning: unused variable 'SZ' [-Wunused-variable]
         int SZ,to;
             ^~
kon.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
kon.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&deg[i]);
         ~~~~~^~~~~~~~~~~~~~
kon.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%i",&to);
             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 7 ms 408 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 504 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 632 KB Output is correct
2 Correct 77 ms 2936 KB Output is correct
3 Correct 378 ms 13608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 760 KB Output is correct
2 Correct 108 ms 4088 KB Output is correct
3 Correct 479 ms 18040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 3060 KB Output is correct
2 Correct 240 ms 9196 KB Output is correct
3 Correct 776 ms 29568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 146 ms 5088 KB Output is correct
2 Correct 557 ms 20984 KB Output is correct
3 Correct 1781 ms 69616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1249 ms 48088 KB Output is correct
2 Correct 828 ms 31148 KB Output is correct
3 Correct 2906 ms 107536 KB Output is correct
4 Execution timed out 3033 ms 115384 KB Time limit exceeded
5 Halted 0 ms 0 KB -