# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341234 | 2020-12-29T09:15:33 Z | juggernaut | Marriage questions (IZhO14_marriage) | C++14 | 33 ms | 3948 KB |
#include<bits/stdc++.h> using namespace std; vector<int>g[100005]; int mt[100005]; int n,m,q; bool used[100001]; int X,Y; int ans=0; bool kuhn(int v){ if(clock()>10000){ cout<<ans; exit(0); } 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){ X=l,Y=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; } int main(){ scanf("%d%d%d",&n,&m,&q); if(n<m||q<m)return puts("0"),0; while(q--){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); } for(int GL=1;GL<=n;GL++){ int l=GL,r=n+1; while(l<r){ int mid=(l+r)>>1; if(check(GL,mid))r=mid; else l=mid+1; } ans+=n-l+1; } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 4 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Correct | 2 ms | 2668 KB | Output is correct |
12 | Correct | 2 ms | 2668 KB | Output is correct |
13 | Correct | 2 ms | 2668 KB | Output is correct |
14 | Correct | 3 ms | 2668 KB | Output is correct |
15 | Correct | 3 ms | 2668 KB | Output is correct |
16 | Correct | 3 ms | 2668 KB | Output is correct |
17 | Correct | 3 ms | 2668 KB | Output is correct |
18 | Correct | 3 ms | 2668 KB | Output is correct |
19 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
20 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
21 | Correct | 10 ms | 2668 KB | Output is correct |
22 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
23 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
24 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
25 | Incorrect | 10 ms | 2816 KB | Output isn't correct |
26 | Incorrect | 10 ms | 2796 KB | Output isn't correct |
27 | Correct | 10 ms | 2668 KB | Output is correct |
28 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
29 | Incorrect | 10 ms | 2796 KB | Output isn't correct |
30 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
31 | Incorrect | 13 ms | 2924 KB | Output isn't correct |
32 | Incorrect | 10 ms | 2796 KB | Output isn't correct |
33 | Correct | 10 ms | 2744 KB | Output is correct |
34 | Incorrect | 10 ms | 2668 KB | Output isn't correct |
35 | Incorrect | 22 ms | 3180 KB | Output isn't correct |
36 | Incorrect | 19 ms | 3180 KB | Output isn't correct |
37 | Incorrect | 14 ms | 3052 KB | Output isn't correct |
38 | Incorrect | 23 ms | 3436 KB | Output isn't correct |
39 | Incorrect | 10 ms | 2796 KB | Output isn't correct |
40 | Correct | 10 ms | 2924 KB | Output is correct |
41 | Incorrect | 10 ms | 3052 KB | Output isn't correct |
42 | Incorrect | 10 ms | 3180 KB | Output isn't correct |
43 | Incorrect | 13 ms | 3180 KB | Output isn't correct |
44 | Incorrect | 25 ms | 3308 KB | Output isn't correct |
45 | Incorrect | 12 ms | 3436 KB | Output isn't correct |
46 | Incorrect | 29 ms | 3820 KB | Output isn't correct |
47 | Incorrect | 26 ms | 3692 KB | Output isn't correct |
48 | Incorrect | 24 ms | 3692 KB | Output isn't correct |
49 | Incorrect | 33 ms | 3948 KB | Output isn't correct |
50 | Incorrect | 10 ms | 2924 KB | Output isn't correct |