# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38587 | 2018-01-04T21:00:41 Z | alenam0161 | 결혼 문제 (IZhO14_marriage) | C++14 | 1489 ms | 4504 KB |
#include <bits/stdc++.h> #define ad push_back using namespace std; const int Mx = 30007 , Mn = 2007; vector<int> g[Mx],g1[Mn]; bool used1[Mx],used2[Mn]; int m1[Mx],m2[Mn]; bool try_khun(int v){ if(used1[v])return false; used1[v]=true; for(auto to:g[v]){ if(m1[to]==0||try_khun(m1[to])){ m1[to]=v; m2[v]=to; return true; } } return false; } bool try_khun2(int l,int r,int v){ if(used2[v])return false; used2[v]=true; for(auto to:g1[v]){ if((to>l&&to<=r)&&(m2[to]==0||try_khun2(l,r,to))){ m2[to]=v; m1[v]=to; return true; } } return true; } int main() { int n,m,k; scanf("%d%d%d",&n,&m,&k); for(int i=1;i<=k;++i){ int u,v; scanf("%d%d",&u,&v); g[v].ad(u); g1[u].ad(v); } long long ans=0; int r=0; int how=0; for(int i=1;i<=n;++i){ while(how!=m&&r<n){ r++; memset(used1,0,sizeof(used1)); how+=try_khun(r); } if(how!=m&&r==n)break; if(how==m)ans+=n-r+1; cout<<i<<" "<<r<<endl; if(m2[i]==0)continue; int gag=m2[i]; m1[m2[i]]=0; m2[i]=0; how--; memset(used2,0,sizeof(used2)); ans+=try_khun2(i,r,gag); } cout<<ans<<"\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
2 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
3 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
4 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
5 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
6 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
7 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
8 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
9 | Correct | 0 ms | 2920 KB | Output is correct |
10 | Correct | 0 ms | 2920 KB | Output is correct |
11 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
12 | Correct | 0 ms | 2920 KB | Output is correct |
13 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
14 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
15 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
16 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
17 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
18 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
19 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
20 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
21 | Correct | 0 ms | 2920 KB | Output is correct |
22 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
23 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
24 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
25 | Incorrect | 0 ms | 3052 KB | Output isn't correct |
26 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
27 | Correct | 0 ms | 2920 KB | Output is correct |
28 | Incorrect | 0 ms | 2920 KB | Output isn't correct |
29 | Incorrect | 3 ms | 3052 KB | Output isn't correct |
30 | Incorrect | 3 ms | 3052 KB | Output isn't correct |
31 | Incorrect | 13 ms | 3448 KB | Output isn't correct |
32 | Incorrect | 3 ms | 3052 KB | Output isn't correct |
33 | Correct | 0 ms | 2920 KB | Output is correct |
34 | Incorrect | 3 ms | 2920 KB | Output isn't correct |
35 | Incorrect | 16 ms | 3976 KB | Output isn't correct |
36 | Incorrect | 16 ms | 3976 KB | Output isn't correct |
37 | Incorrect | 9 ms | 3712 KB | Output isn't correct |
38 | Incorrect | 26 ms | 4240 KB | Output isn't correct |
39 | Incorrect | 53 ms | 3052 KB | Output isn't correct |
40 | Incorrect | 36 ms | 3184 KB | Output isn't correct |
41 | Incorrect | 86 ms | 3316 KB | Output isn't correct |
42 | Incorrect | 103 ms | 3448 KB | Output isn't correct |
43 | Incorrect | 149 ms | 3580 KB | Output isn't correct |
44 | Incorrect | 299 ms | 3976 KB | Output isn't correct |
45 | Incorrect | 59 ms | 3712 KB | Output isn't correct |
46 | Runtime error | 1489 ms | 4372 KB | Execution timed out (wall clock limit exceeded) |
47 | Incorrect | 976 ms | 4372 KB | Output isn't correct |
48 | Incorrect | 869 ms | 4372 KB | Output isn't correct |
49 | Runtime error | 1266 ms | 4504 KB | Execution timed out (wall clock limit exceeded) |
50 | Incorrect | 143 ms | 3052 KB | Output isn't correct |