이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |