답안 #171029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171029 2019-12-27T05:45:52 Z juggernaut 결혼 문제 (IZhO14_marriage) C++14
36 / 100
3 ms 888 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m,k,x,y,cnt,mt[51];
vector<vector<int>>g(51);
bool used[51];
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){
    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;
}
main(){
    scanf("%lld%lld%lld",&n,&m,&k);
    while(k--){
        scanf("%lld%lld",&x,&y);
        g[x].push_back(y);
    }
    for(x=1;x<=n;x++)
    for(y=x;y<=n;y++)cnt+=check(x,y);
    printf("%lld",cnt);
}

Compilation message

marriage.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
marriage.cpp: In function 'int main()':
marriage.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
marriage.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 368 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 2 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 2 ms 424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 2 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Incorrect 2 ms 376 KB Output isn't correct
34 Incorrect 2 ms 376 KB Output isn't correct
35 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
44 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)