結果
問題 | No.654 Air E869120 |
ユーザー | shiomusubi496 |
提出日時 | 2021-09-05 13:12:39 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 1,953 bytes |
コンパイル時間 | 2,629 ms |
コンパイル使用メモリ | 222,080 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-01 11:43:04 |
合計ジャッジ時間 | 3,985 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,948 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 13 ms
6,940 KB |
testcase_11 | AC | 10 ms
6,940 KB |
testcase_12 | AC | 10 ms
6,944 KB |
testcase_13 | AC | 18 ms
6,940 KB |
testcase_14 | AC | 6 ms
6,940 KB |
testcase_15 | AC | 7 ms
6,940 KB |
testcase_16 | AC | 6 ms
6,940 KB |
testcase_17 | AC | 10 ms
6,940 KB |
testcase_18 | AC | 11 ms
6,944 KB |
testcase_19 | AC | 6 ms
6,944 KB |
testcase_20 | AC | 5 ms
6,944 KB |
testcase_21 | AC | 5 ms
6,940 KB |
testcase_22 | AC | 4 ms
6,940 KB |
testcase_23 | AC | 4 ms
6,944 KB |
testcase_24 | AC | 4 ms
6,940 KB |
testcase_25 | AC | 4 ms
6,944 KB |
testcase_26 | AC | 4 ms
6,940 KB |
testcase_27 | AC | 4 ms
6,944 KB |
testcase_28 | AC | 4 ms
6,940 KB |
testcase_29 | AC | 4 ms
6,940 KB |
testcase_30 | AC | 4 ms
6,944 KB |
testcase_31 | AC | 5 ms
6,944 KB |
testcase_32 | AC | 4 ms
6,944 KB |
testcase_33 | AC | 5 ms
6,944 KB |
testcase_34 | AC | 4 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In instantiation of 'void MaxFlowGraph<Cap>::add_edge(int, int, Cap) [with Cap = long long int]': main.cpp:55:15: required from here main.cpp:13:37: warning: narrowing conversion of '(&((MaxFlowGraph<long long int>*)this)->MaxFlowGraph<long long int>::G.std::vector<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >, std::allocator<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> > > >::operator[](((std::vector<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >, std::allocator<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> > > >::size_type)b)))->std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >::size()' from 'std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing] 13 | G[a].push_back({b, G[b].size(), c}); | ~~~~~~~~~^~ main.cpp:14:39: warning: narrowing conversion of '((&((MaxFlowGraph<long long int>*)this)->MaxFlowGraph<long long int>::G.std::vector<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >, std::allocator<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> > > >::operator[](((std::vector<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >, std::allocator<std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> > > >::size_type)a)))->std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >::size() - 1)' from 'std::vector<MaxFlowGraph<long long int>::edge, std::allocator<MaxFlowGraph<long long int>::edge> >::size_type' {aka 'long unsigned int'}
ソースコード
#include<bits/stdc++.h> using namespace std; template<class Cap> struct MaxFlowGraph{ struct edge{ int to, rev; Cap cap; }; MaxFlowGraph(int n): G(n), _n(n), cap_max(0){} void add_edge(int a, int b, Cap c){ assert(0<=a && a<_n); assert(0<=b && b<_n); assert(0<=c); G[a].push_back({b, G[b].size(), c}); G[b].push_back({a, G[a].size()-1, 0}); if(cap_max < c) cap_max = c; } Cap flow(int s, int t){ Cap res = 0; while(true){ used.assign(_n, false); Cap fw = dfs(s, t, cap_max); if(fw==0)break; res += fw; } return res; } private: int _n; Cap cap_max; std::vector<std::vector<edge>> G; std::vector<bool> used; Cap dfs(int v, int t, Cap f){ if(v==t) return f; used[v] = true; for(edge &e:G[v]){ if(used[e.to] || e.cap==0) continue; Cap fw = dfs(e.to, t, min(f, e.cap)); if(fw==0) continue; e.cap -= fw; G[e.to][e.rev].cap += fw; return fw; } return 0; } }; int main(){ int N,M,d; cin>>N>>M>>d; int s=2*M,t=s+1; MaxFlowGraph<long long> G(2*M+2); vector<int> U(M),V(M),P(M),Q(M),W(M); vector<vector<pair<int,int>>> A(N); for(int i=0;i<M;i++){ cin>>U[i]>>V[i]>>P[i]>>Q[i]>>W[i]; --U[i]; --V[i]; G.add_edge(2*i,2*i+1,W[i]); if(U[i]==0)G.add_edge(s,2*i,W[i]); if(V[i]==N-1)G.add_edge(2*i+1,t,W[i]); A[U[i]].push_back({P[i],i}); } for(int i=0;i<N;i++){ sort(A[i].begin(),A[i].end()); for(int j=0;j+1<A[i].size();j++)G.add_edge(A[i][j].second*2,A[i][j+1].second*2,1e18); } for(int i=0;i<M;i++){ int itr=lower_bound(A[V[i]].begin(),A[V[i]].end(),pair(Q[i]+d,0))-A[V[i]].begin(); if(itr==A[V[i]].size())continue; G.add_edge(i*2+1,A[V[i]][itr].second*2,1e18); } cout<<G.flow(s,t)<<endl; }