# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
5029 | 2014-01-28T13:27:02 Z | cki86201 | 결혼 문제 (IZhO14_marriage) | C++ | 1500 ms | 3052 KB |
#include<stdio.h> #include<vector> using namespace std; //for 72point, O(N(K+M)); vector <int> E[30030]; int n, m, mat, ans, prev; int yx[2020]; int vis[30030],in; bool dfs(int x) { vis[x] = in; for(size_t i=0;i<E[x].size();i++){ if(!yx[E[x][i]] || (yx[E[x][i]] > prev && vis[yx[E[x][i]]] != in && dfs(yx[E[x][i]]))){ yx[E[x][i]] = x; return true; } } return false; } int main() { int k, i; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=k;i++){ int x,y; scanf("%d%d",&x,&y); E[x].push_back(y); } for(i=1;i<=n;i++){ if(dfs(in=i))mat++; if(mat == m){ int mn = 1; for(int j=2;j<=m;j++)if(yx[j] < yx[mn])mn = j; ans += (yx[mn] - prev) * (n-i+1); prev = yx[mn]; yx[mn] = 0; mat--; } } printf("%d",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 1996 KB | Output isn't correct |
2 | Incorrect | 0 ms | 1996 KB | Output isn't correct |
3 | Correct | 0 ms | 1996 KB | Output is correct |
4 | Correct | 0 ms | 1996 KB | Output is correct |
5 | Correct | 0 ms | 1996 KB | Output is correct |
6 | Correct | 0 ms | 1996 KB | Output is correct |
7 | Correct | 0 ms | 1996 KB | Output is correct |
8 | Correct | 0 ms | 1996 KB | Output is correct |
9 | Correct | 0 ms | 1996 KB | Output is correct |
10 | Correct | 0 ms | 1996 KB | Output is correct |
11 | Correct | 0 ms | 1996 KB | Output is correct |
12 | Correct | 0 ms | 1996 KB | Output is correct |
13 | Correct | 0 ms | 1996 KB | Output is correct |
14 | Correct | 0 ms | 1996 KB | Output is correct |
15 | Incorrect | 0 ms | 1996 KB | Output isn't correct |
16 | Correct | 0 ms | 1996 KB | Output is correct |
17 | Correct | 0 ms | 1996 KB | Output is correct |
18 | Correct | 0 ms | 1996 KB | Output is correct |
19 | Correct | 0 ms | 1996 KB | Output is correct |
20 | Correct | 0 ms | 1996 KB | Output is correct |
21 | Correct | 0 ms | 1996 KB | Output is correct |
22 | Correct | 0 ms | 1996 KB | Output is correct |
23 | Correct | 0 ms | 1996 KB | Output is correct |
24 | Correct | 0 ms | 1996 KB | Output is correct |
25 | Correct | 6 ms | 2128 KB | Output is correct |
26 | Incorrect | 3 ms | 1996 KB | Output isn't correct |
27 | Correct | 0 ms | 1996 KB | Output is correct |
28 | Correct | 0 ms | 1996 KB | Output is correct |
29 | Incorrect | 3 ms | 2128 KB | Output isn't correct |
30 | Incorrect | 3 ms | 2128 KB | Output isn't correct |
31 | Correct | 13 ms | 2260 KB | Output is correct |
32 | Incorrect | 13 ms | 2128 KB | Output isn't correct |
33 | Correct | 0 ms | 1996 KB | Output is correct |
34 | Correct | 0 ms | 1996 KB | Output is correct |
35 | Correct | 66 ms | 2524 KB | Output is correct |
36 | Correct | 63 ms | 2524 KB | Output is correct |
37 | Correct | 49 ms | 2392 KB | Output is correct |
38 | Incorrect | 143 ms | 2788 KB | Output isn't correct |
39 | Correct | 29 ms | 2128 KB | Output is correct |
40 | Correct | 6 ms | 2260 KB | Output is correct |
41 | Incorrect | 23 ms | 2260 KB | Output isn't correct |
42 | Incorrect | 199 ms | 2392 KB | Output isn't correct |
43 | Incorrect | 293 ms | 2392 KB | Output isn't correct |
44 | Incorrect | 663 ms | 2656 KB | Output isn't correct |
45 | Incorrect | 16 ms | 2656 KB | Output isn't correct |
46 | Execution timed out | 1500 ms | 3052 KB | Execution timed out |
47 | Incorrect | 1286 ms | 2920 KB | Output isn't correct |
48 | Incorrect | 1283 ms | 2920 KB | Output isn't correct |
49 | Execution timed out | 1500 ms | 3052 KB | Execution timed out |
50 | Correct | 29 ms | 2128 KB | Output is correct |