# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
171030 | juggernaut | Marriage questions (IZhO14_marriage) | C++14 | 1582 ms | 5496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m,k,x,y,cnt,mt[100001];
vector<vector<int>>g(100001);
bool used[100001];
bool kuhn(int v){
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){
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;
}
main(){
scanf("%lld%lld%lld",&n,&m,&k);
while(k--){
scanf("%lld%lld",&x,&y);
g[x].push_back(y);
}
for(x=1;x<=n;x++)
for(y=x;y<=n;y++)cnt+=check(x,y);
printf("%lld",cnt);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |