# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341243 | 2020-12-29T09:36:05 Z | juggernaut | Marriage questions (IZhO14_marriage) | C++14 | 817 ms | 2156 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(){ 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 3 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 42 ms | 492 KB | Output is correct |
26 | Correct | 6 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 3 ms | 492 KB | Output is correct |
30 | Correct | 2 ms | 492 KB | Output is correct |
31 | Correct | 282 ms | 1132 KB | Output is correct |
32 | Correct | 11 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 364 KB | Output is correct |
34 | Correct | 3 ms | 364 KB | Output is correct |
35 | Correct | 110 ms | 1644 KB | Output is correct |
36 | Correct | 79 ms | 1516 KB | Output is correct |
37 | Correct | 817 ms | 1516 KB | Output is correct |
38 | Correct | 22 ms | 1644 KB | Output is correct |
39 | Correct | 70 ms | 748 KB | Output is correct |
40 | Correct | 4 ms | 620 KB | Output is correct |
41 | Correct | 7 ms | 748 KB | Output is correct |
42 | Correct | 8 ms | 876 KB | Output is correct |
43 | Correct | 12 ms | 1132 KB | Output is correct |
44 | Correct | 20 ms | 1772 KB | Output is correct |
45 | Correct | 10 ms | 1132 KB | Output is correct |
46 | Correct | 62 ms | 2028 KB | Output is correct |
47 | Correct | 23 ms | 2028 KB | Output is correct |
48 | Correct | 22 ms | 1900 KB | Output is correct |
49 | Correct | 88 ms | 2156 KB | Output is correct |
50 | Correct | 173 ms | 620 KB | Output is correct |