結果

問題 No.1744 Selfish Spies 1 (à la Princess' Perfectionism)
ユーザー 沙耶花沙耶花
提出日時 2021-11-14 21:35:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 664 ms / 5,000 ms
コード長 1,041 bytes
コンパイル時間 6,575 ms
コンパイル使用メモリ 274,264 KB
実行使用メモリ 12,136 KB
最終ジャッジ日時 2023-08-20 06:13:29
合計ジャッジ時間 13,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 14 ms
4,380 KB
testcase_15 AC 19 ms
4,376 KB
testcase_16 AC 23 ms
4,380 KB
testcase_17 AC 57 ms
4,380 KB
testcase_18 AC 56 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 79 ms
5,016 KB
testcase_25 AC 23 ms
4,376 KB
testcase_26 AC 23 ms
4,380 KB
testcase_27 AC 62 ms
4,376 KB
testcase_28 AC 593 ms
12,060 KB
testcase_29 AC 65 ms
4,380 KB
testcase_30 AC 65 ms
4,376 KB
testcase_31 AC 63 ms
4,380 KB
testcase_32 AC 63 ms
4,376 KB
testcase_33 AC 627 ms
11,992 KB
testcase_34 AC 621 ms
12,136 KB
testcase_35 AC 623 ms
11,948 KB
testcase_36 AC 657 ms
12,120 KB
testcase_37 AC 664 ms
11,960 KB
testcase_38 AC 639 ms
11,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001


int main(){

	int N,M,L;
	cin>>N>>M>>L;
	
	mf_graph<int> G(2+N+M);
	int S = N+M,T = N+M+1;
	
	vector<int> s(L),t(L);
	vector<int> ind(L);
	rep(i,L){
		cin>>s[i]>>t[i];
		s[i]--;t[i]--;
		ind[i] = G.add_edge(s[i],N+t[i],1);
	}
	vector<int> inds(N),indt(M);
	rep(i,N)inds[i] = G.add_edge(S,i,1);
	rep(i,M)indt[i] = G.add_edge(N+i,T,1);
	
	vector<bool> f(L,false);
	int ans = G.flow(S,T);
	vector<int> p;
	rep(i,L){
		if(G.get_edge(ind[i]).flow==0)f[i] = true;
		else p.push_back(i);
	}
	
	
	rep(i,p.size()){
		int cur = ans;
		int ii = p[i];
		auto GG = G;
		G.change_edge(ind[ii],0,0);
		cur--;
		if(G.flow(s[ii],N+t[ii],1)){
			cur++;
		}
		else{
			G.change_edge(inds[s[ii]],1,0);
			G.change_edge(indt[t[ii]],1,0);
		}
		
		if(cur==ans)f[ii] = true;
		G = GG;
	}
	rep(i,L){
		cout<<(f[i]?"Yes":"No")<<endl;
	}
	
	return 0;
}
0