結果
| 問題 |
No.483 マッチ並べ
|
| コンテスト | |
| ユーザー |
DAyamaCTF
|
| 提出日時 | 2017-02-11 13:02:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,594 bytes |
| コンパイル時間 | 1,556 ms |
| コンパイル使用メモリ | 162,596 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-29 12:09:39 |
| 合計ジャッジ時間 | 3,267 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
#define INF INT_MAX/3
#define MAX_V 12321
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];
void init(int v){
V=v;
for(int i=0;i<V;i++)G[i].clear();
}
void add_edge(int u,int v){
G[u].push_back(v);
G[v].push_back(u);
}
bool dfs(int v){
used[v]=true;
for(int i=0; i<G[v].size();i++){
int u=G[v][i],w=match[u];
if(w<0||(!used[w]&&dfs(w))){
match[v]=u;
match[u]=v;
return true;
}
}
return false;
}
int bipartite_match(){
int res=0;
memset(match,-1,sizeof(match));
for(int v=0; v<V;v++){
if(match[v]<0){
memset(used,0,sizeof(used));
if(dfs(v))res++;
}
}
return res;
}
int n;
int main(){
cin.sync_with_stdio(false);
cin>>n;
init(10100);
rep(i,n){
int r1,c1,r2,c2;
cin>>r1>>c1>>r2>>c2;
r1--; r2--; c1--; c2--;
add_edge(i,r1*100+c1+n);
add_edge(i,r2*100+c2+n);
}
if(bipartite_match()==n)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
DAyamaCTF