제출 #341227

#제출 시각아이디문제언어결과실행 시간메모리
341227juggernautMarriage questions (IZhO14_marriage)C++14
56 / 100
1597 ms4136 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int>g[100005];
int mt[100005];
int n,m,q;
bool used[100001];
int X,Y;
bool kuhn(int v){
    if(used[v]||v<X||v>Y)return false;
    used[v]=true;
    for(int to:g[v]){
        if(mt[to]==0||kuhn(mt[to])){
            mt[to]=v;
            return true;
        }
    }
    return false;
}
bool check(int l,int r){
    X=l,Y=r;
    for(int i=1;i<=n;i++)mt[i]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)used[j]=false;
        kuhn(i);
    }
    int c=0;
    for(int i=1;i<=n;i++)if(mt[i])c++;
    return c==m;
}
int main(){
    scanf("%d%d%d",&n,&m,&q);
    while(q--){
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
    }
    int ans=0;
    for(int GL=1;GL<=n;GL++){
        int l=GL,r=n+1;
        while(l<r){
            int mid=(l+r)>>1;
            if(check(GL,mid))r=mid;
            else l=mid+1;
        }
        ans+=n-l+1;
    }
    cout<<ans;
}

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

marriage.cpp: In function 'int main()':
marriage.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     scanf("%d%d%d",&n,&m,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
marriage.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...