제출 #169325

#제출 시각아이디문제언어결과실행 시간메모리
169325pr3pony새로운 문제 (POI11_pro)C++14
100 / 100
119 ms3276 KiB
#include <bits/stdc++.h> using namespace std; const int N = 505; vector<int> gx[N]; int my[N]; int vy[N], vcnt; bool dead[N]; int cnt[N]; bool dfs(int x) { for (const int & y : gx[x]) { if (vy[y] == vcnt) continue; vy[y] = vcnt; if (!my[y] || dfs(my[y])) { my[y] = x; return true; } } return false; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, r, t, k; cin >> n >> m >> r >> t >> k; vector<pair<int,int>> vs; for (int i = 0; i < k; ++i) { int a, b; cin >> a >> b; gx[a].push_back(b); int w = gx[a].size() * r; if (w <= t) vs.emplace_back(w, a); } sort(begin(vs), end(vs)); int tot = 0, mat = 0; for (auto tdd : vs) { int w, u; tie(w, u) = tdd; if (dead[u]) continue; ++vcnt; if (dfs(u)) tot += w, ++mat; else dead[u] = true; } cout << mat << ' ' << tot << '\n'; for (int i = 1; i <= m; ++i) if (my[i]) cout << my[i] << ' ' << i << ' ' << cnt[my[i]]++ * r << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...