結果

問題 No.1480 Many Complete Graphs
ユーザー 沙耶花沙耶花
提出日時 2021-04-16 20:50:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 4,997 ms
コンパイル使用メモリ 276,992 KB
実行使用メモリ 97,952 KB
最終ジャッジ日時 2023-09-16 02:51:34
合計ジャッジ時間 12,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,420 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 39 ms
27,188 KB
testcase_14 AC 29 ms
20,784 KB
testcase_15 AC 60 ms
30,640 KB
testcase_16 AC 33 ms
18,864 KB
testcase_17 AC 32 ms
19,156 KB
testcase_18 AC 9 ms
6,952 KB
testcase_19 AC 34 ms
20,276 KB
testcase_20 AC 56 ms
32,064 KB
testcase_21 AC 48 ms
33,272 KB
testcase_22 AC 27 ms
20,496 KB
testcase_23 AC 94 ms
65,024 KB
testcase_24 AC 97 ms
64,064 KB
testcase_25 AC 114 ms
65,236 KB
testcase_26 AC 113 ms
65,104 KB
testcase_27 AC 98 ms
65,384 KB
testcase_28 AC 93 ms
68,012 KB
testcase_29 AC 95 ms
67,864 KB
testcase_30 AC 96 ms
68,448 KB
testcase_31 AC 96 ms
67,476 KB
testcase_32 AC 96 ms
67,836 KB
testcase_33 AC 94 ms
67,328 KB
testcase_34 AC 93 ms
67,492 KB
testcase_35 AC 105 ms
67,952 KB
testcase_36 AC 104 ms
67,500 KB
testcase_37 AC 102 ms
67,912 KB
testcase_38 AC 107 ms
67,400 KB
testcase_39 AC 106 ms
68,692 KB
testcase_40 AC 101 ms
67,984 KB
testcase_41 AC 100 ms
67,372 KB
testcase_42 AC 111 ms
67,788 KB
testcase_43 AC 111 ms
67,432 KB
testcase_44 AC 113 ms
67,616 KB
testcase_45 AC 112 ms
67,468 KB
testcase_46 AC 110 ms
67,988 KB
testcase_47 AC 207 ms
87,376 KB
testcase_48 AC 179 ms
88,148 KB
testcase_49 AC 197 ms
86,800 KB
testcase_50 AC 134 ms
87,132 KB
testcase_51 AC 236 ms
88,024 KB
testcase_52 AC 140 ms
75,996 KB
testcase_53 AC 155 ms
76,724 KB
testcase_54 AC 165 ms
75,644 KB
testcase_55 AC 165 ms
75,268 KB
testcase_56 AC 150 ms
75,868 KB
testcase_57 AC 163 ms
97,952 KB
testcase_58 AC 130 ms
86,620 KB
evil_aftercontest.txt AC 246 ms
168,820 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;
	cin>>N>>M;
	
	mcf_graph<long long,long long> G(N+M*8);
	
	rep(_,M){
		int k;
		cin>>k;
		
		long long c;
		cin>>c;
		
		vector<int> s(k);
		rep(i,k)cin>>s[i];
		
		rep(i,k){
			G.add_edge(s[i]-1,N+8*_+(s[i]%2)*2,1,s[i]/2);
			G.add_edge(s[i]-1,N+8*_+(s[i]%2)*2+1,1,s[i]/2);
			G.add_edge(N+8*_+4+(s[i]%2),s[i]-1,1,s[i]/2);
			G.add_edge(N+8*_+4+(s[i]%2)+2,s[i]-1,1,s[i]/2);			
		}
		
		G.add_edge(N+8*_+0,N+8*_+4+0,1,c);
		G.add_edge(N+8*_+1,N+8*_+4+1,1,c+1);
		G.add_edge(N+8*_+2,N+8*_+4+2,1,c+1);
		G.add_edge(N+8*_+3,N+8*_+4+3,1,c+1);
		
	}
	
	auto ans = G.flow(0,N-1,1);
	if(ans.first==0)cout<<-1<<endl;
	else cout<<ans.second<<endl;
	
    return 0;
}
0