제출 #208603

#제출 시각아이디문제언어결과실행 시간메모리
208603MKopchevUntitled (POI11_kon)C++14
90 / 100
3033 ms115384 KiB
#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;
}

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

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);
             ~~~~~^~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...