본문으로 건너뛰기
SERIES · BOJ 풀이 로그

[BOJ] 6786번 Blood Distribution

[BOJ] 6786번 Blood Distribution 풀이

2025년 12월 16일 · 1 min read


[P2] Blood Distribution



source -> 1 ~ 8 혈액, 9 ~ 16 환자 -> sink 순으로 모델링하면 된다.


bool chk[8][8] = {
	{1, 0, 0, 0, 0, 0, 0, 0},
	{1, 1, 0, 0, 0, 0, 0, 0},
	{1, 0, 1, 0, 0, 0, 0, 0},
	{1, 1, 1, 1, 0, 0, 0, 0},
	{1, 0, 0, 0, 1, 0, 0, 0},
	{1, 1, 0, 0, 1, 1, 0, 0},
	{1, 0, 1, 0, 1, 0, 1, 0},
	{1, 1, 1, 1, 1, 1, 1, 1}
};
 
void solve(){
	Dinic<int> flow(22);
	int st = 20, en = 21;
	for(int i = 0; i < 8; i++){
		int x; cin >> x;
		flow.add_edge(st, i, x);
	}
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			if(!chk[j][i]) continue;
			flow.add_edge(i, j + 1 + 8, INF); 
		}
	}
	for(int i = 9; i <= 16; i++){
		int x; cin >> x;
		flow.add_edge(i, en, x);
	}
	cout << flow.maximum_flow(st, en) << "\n";
}
Tags:BOJPS
SERIES7 / 11회차

BOJ 풀이 로그

  1. 5.[BOJ] 34295번 Rocky Mountain Road Trip
  2. 6.[BOJ] 33928번 나이트 오브 나이츠(Hard)
  3. 7.[BOJ] 6786번 Blood Distribution지금 읽는 중
  4. 8.[BOJ] 1974번 Jump Jump Championship
  5. 9.[BOJ] 20860번 DuTub

관련 글