This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
for (int i = 0; i < k; ++i) {
int a, b;
cin >> a >> b;
gx[a].push_back(b);
}
int tot = 0, mat = 0;
for (int i = 1; i <= m && i * r <= t; ++i)
for (int u = 1; u <= n; ++u) {
if (dead[u])
continue;
++vcnt;
if (dfs(u))
tot += i * r, ++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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |