# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38483 | 2018-01-04T09:58:11 Z | alenam0161 | 결혼 문제 (IZhO14_marriage) | C++14 | 1500 ms | 8908 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5+7; vector<int> g[N],g1[N]; int n,m,k; bool used[N]; int ma[N]; bool try_khun(int v){ if(used[v]==true)return false; used[v]=true; for(auto to:g[v]){ if(ma[to]==-1||try_khun(ma[to])){ ma[to]=v; return true; } } return false; } int main(){ memset(ma,-1,sizeof(ma)); scanf("%d%d%d",&n,&m,&k); for(int i=1;i<=k;++i){ int u,v; scanf("%d%d",&v,&u); g[v].push_back(u); g1[u].push_back(v); } int l=1; int how=0; long long ans=0; for(int i=1;i<=n;++i){ if(try_khun(i))how++; bool ok=false; while(how>=m){ l++; ok=true; how=0; memset(ma,-1,sizeof(ma)); for(int j=l;j<=i;++j){ memset(used,0,sizeof(used)); how+=try_khun(j); } } if(ok){ l--; how=0; memset(ma,-1,sizeof(ma)); for(int j=l;j<=i;++j){ memset(used,0,sizeof(used)); how+=try_khun(j); } } if(how==m)ans+=l; // cout<<how<<" "<<i<<" "<<l<<endl; } cout<<ans<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7192 KB | Output is correct |
2 | Correct | 0 ms | 7192 KB | Output is correct |
3 | Incorrect | 0 ms | 7192 KB | Output isn't correct |
4 | Incorrect | 0 ms | 7192 KB | Output isn't correct |
5 | Correct | 0 ms | 7192 KB | Output is correct |
6 | Correct | 0 ms | 7192 KB | Output is correct |
7 | Incorrect | 3 ms | 7192 KB | Output isn't correct |
8 | Correct | 0 ms | 7192 KB | Output is correct |
9 | Correct | 0 ms | 7192 KB | Output is correct |
10 | Correct | 0 ms | 7192 KB | Output is correct |
11 | Incorrect | 0 ms | 7192 KB | Output isn't correct |
12 | Correct | 0 ms | 7192 KB | Output is correct |
13 | Correct | 3 ms | 7192 KB | Output is correct |
14 | Correct | 6 ms | 7192 KB | Output is correct |
15 | Incorrect | 3 ms | 7192 KB | Output isn't correct |
16 | Incorrect | 0 ms | 7192 KB | Output isn't correct |
17 | Correct | 6 ms | 7192 KB | Output is correct |
18 | Correct | 0 ms | 7192 KB | Output is correct |
19 | Incorrect | 39 ms | 7192 KB | Output isn't correct |
20 | Incorrect | 43 ms | 7192 KB | Output isn't correct |
21 | Correct | 0 ms | 7192 KB | Output is correct |
22 | Incorrect | 3 ms | 7192 KB | Output isn't correct |
23 | Correct | 43 ms | 7192 KB | Output is correct |
24 | Correct | 43 ms | 7192 KB | Output is correct |
25 | Incorrect | 669 ms | 7324 KB | Output isn't correct |
26 | Incorrect | 696 ms | 7192 KB | Output isn't correct |
27 | Correct | 0 ms | 7192 KB | Output is correct |
28 | Incorrect | 0 ms | 7192 KB | Output isn't correct |
29 | Correct | 1269 ms | 7324 KB | Output is correct |
30 | Correct | 1163 ms | 7324 KB | Output is correct |
31 | Execution timed out | 1500 ms | 7720 KB | Execution timed out |
32 | Incorrect | 0 ms | 7324 KB | Output isn't correct |
33 | Correct | 0 ms | 7192 KB | Output is correct |
34 | Incorrect | 3 ms | 7192 KB | Output isn't correct |
35 | Execution timed out | 1500 ms | 8248 KB | Execution timed out |
36 | Execution timed out | 1500 ms | 8248 KB | Execution timed out |
37 | Execution timed out | 1500 ms | 7852 KB | Execution timed out |
38 | Execution timed out | 1500 ms | 8512 KB | Execution timed out |
39 | Incorrect | 9 ms | 7324 KB | Output isn't correct |
40 | Correct | 9 ms | 7456 KB | Output is correct |
41 | Execution timed out | 1500 ms | 7588 KB | Execution timed out |
42 | Execution timed out | 1500 ms | 7720 KB | Execution timed out |
43 | Execution timed out | 1500 ms | 7984 KB | Execution timed out |
44 | Execution timed out | 1500 ms | 8380 KB | Execution timed out |
45 | Execution timed out | 1500 ms | 7984 KB | Execution timed out |
46 | Execution timed out | 1500 ms | 8776 KB | Execution timed out |
47 | Execution timed out | 1500 ms | 8644 KB | Execution timed out |
48 | Execution timed out | 1500 ms | 8644 KB | Execution timed out |
49 | Execution timed out | 1500 ms | 8908 KB | Execution timed out |
50 | Incorrect | 0 ms | 7324 KB | Output isn't correct |