結果
問題 | No.1744 Selfish Spies 1 (à la Princess' Perfectionism) |
ユーザー |
![]() |
提出日時 | 2021-11-16 04:15:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 457 ms / 5,000 ms |
コード長 | 1,480 bytes |
コンパイル時間 | 3,312 ms |
コンパイル使用メモリ | 188,092 KB |
最終ジャッジ日時 | 2025-01-25 18:41:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #include <list> #include <atcoder/all> #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair<int, int> P; using mint=modint998244353; int main() { int n, m, l; cin>>n>>m>>l; int s=n+m, t=s+1; mf_graph<int> g(n+m+2); int a[100010], b[100010]; for(int i=0; i<l; i++){ cin>>a[i]>>b[i]; a[i]--; b[i]--; g.add_edge(a[i], b[i]+n, 1); } for(int i=0; i<n; i++) g.add_edge(s, i, 1); for(int i=0; i<m; i++) g.add_edge(i+n, t, 1); int f=g.flow(s, t); bool ans[100010]={}; //cout<<f<<endl; for(int i=0; i<l; i++){ if(g.get_edge(i).flow==0){ ans[i]=1; continue; } g.change_edge(i, 0, 0); if(g.flow(a[i], b[i]+n)){ ans[i]=1; g.change_edge(i, 1, 0); }else{ g.change_edge(i, 1, 0); g.flow(a[i], b[i]+n); } } for(int i=0; i<l; i++){ printf(ans[i] ? "Yes\n" : "No\n"); } return 0; }