이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
vector<int> gx[N];
int my[N];
int vx[N], vy[N], vcnt;
bool dead[N];
int cnt[N];
bool dfs(int x)
{
if (vx[x] == vcnt)
return false;
vx[x] = vcnt;
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... |