답안 #341260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341260 2020-12-29T10:17:25 Z juggernaut 결혼 문제 (IZhO14_marriage) C++14
0 / 100
1 ms 396 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,qq,mt[30005],GL,GR,vis[2005],timer;
vector<int>g[2005];
queue<int>q;
bool kuhn(int v){
    if(vis[v]==timer)return false;
    vis[v]=timer;
    for(int to:g[v]){
        if(to<GL||to>GR)continue;
        if(!mt[to]||kuhn(mt[to])){
            mt[to]=v;
            return true;
        }
    }
    return false;
}
bool check(){
    while(!q.empty()){
        int v=q.front();
        q.pop();
        timer++;
        if(!kuhn(v)){
            q.push(v);
            return false;
        }
    }
    return true;
}
int main(){vector<int>v={1,2,3,4,5,6,7,8,9};
    srand(time(NULL));
    vector<int>v1=v;
    random_shuffle(v.begin(),v.end());
    for(int i=0;i<9;i++)if(v[i]!=v1[i]){
        puts("SHUFFLE WORKS");
        return 1;
    }
    scanf("%d%d%d",&n,&m,&qq);
    while(qq--){
        int x,y;
        scanf("%d%d",&x,&y);
        g[y].push_back(x);
    }
    for(int i=1;i<=m;i++)q.push(i);
    int ans=0;
    GR=1;
    for(GL=1;GL<=n;GL++){
        while(GR<=n&&!check())GR++;
        ans+=n-GR+1;
        if(mt[GL]){
            q.push(mt[GL]);
            mt[GL]=0;
        }
    }
    cout<<ans;
}

Compilation message

marriage.cpp: In function 'int main()':
marriage.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     scanf("%d%d%d",&n,&m,&qq);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
marriage.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 396 KB Execution failed because the return code was nonzero
2 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
3 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
4 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
6 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
7 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
8 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
9 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
10 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
15 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
16 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
17 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
18 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
19 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
20 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
21 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
22 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
23 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
24 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
25 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
26 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
27 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
28 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
29 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
30 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
31 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
32 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
33 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
34 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
35 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
36 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
37 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
38 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
39 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
40 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
41 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
42 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
43 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
44 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
45 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
46 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero
47 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
48 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
49 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
50 Runtime error 0 ms 364 KB Execution failed because the return code was nonzero