| Task: | Download Speed |
| Sender: | ileska |
| Submission time: | 2025-10-15 14:18:14 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.01 s | details |
| #7 | WRONG ANSWER | 0.01 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | ACCEPTED | 0.00 s | details |
| #10 | WRONG ANSWER | 0.00 s | details |
| #11 | WRONG ANSWER | 0.01 s | details |
| #12 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:69:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int ii = 0; ii < (path.size() - 1); ii++) {
| ~~~^~~~~~~~~~~~~~~~~~~Code
#include <bits/stdc++.h>
#include <vector>
#define ll long long
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
os << "[";
for (int i = 0; i < v.size(); ++i) {
os << v[i];
if (i != v.size() - 1)
os << ", ";
}
os << "]";
return os;
}
ll something(std::vector<std::unordered_map<ll, ll>> &costMap,
std::vector<std::unordered_map<ll, ll>> &emptMap,
std::vector<char> &checked, std::vector<ll> &path, ll start,
ll wholeEnd) {
path.push_back(start);
if (start == wholeEnd) {
return 1e15;
}
checked[start] = 1;
for (const auto &[end, speed] : costMap[start]) {
if (speed > 0 && !checked[end]) {
ll ret = something(costMap, emptMap, checked, path, end, wholeEnd);
if (ret != -1) {
return std::min(ret, costMap[start][end]);
}
}
}
path.pop_back();
return -1;
}
int main() {
ll compCount, conCount;
std::cin >> compCount;
std::cin >> conCount;
// std::cout << compCount << " " << conCount << std::endl;
std::vector<std::unordered_map<ll, ll>> costMap(compCount,
std::unordered_map<ll, ll>());
std::vector<std::unordered_map<ll, ll>> emptMap(compCount,
std::unordered_map<ll, ll>());
for (ll ii = 0; ii < conCount; ii++) {
ll start, end, speed;
// std::cout << start << " " << end << " " << speed << std::endl;
std::cin >> start;
std::cin >> end;
std::cin >> speed;
costMap[start - 1][end - 1] = speed;
costMap[end - 1][start - 1] = 0;
}
std::vector<char> checked(compCount, 0);
ll minCost = 0;
ll throughtPut = 0;
while (1) {
std::vector<ll> path;
minCost = something(costMap, emptMap, checked, path, 0, compCount - 1);
if (minCost == -1)
break;
throughtPut += minCost;
// std::cout << path << " " << minCost << std::endl;
for (int ii = 0; ii < (path.size() - 1); ii++) {
ll start = path[ii];
ll end = path[ii + 1];
costMap[start][end] -= minCost;
costMap[end][start] += minCost;
}
};
std::cout << throughtPut << std::endl;
}Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 4 3 1 2 5 2 3 3 3 4 6 |
| correct output |
|---|
| 3 |
| user output |
|---|
| 3 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 4 5 1 2 1 1 3 1 2 3 1 2 4 1 ... |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 4 5 1 2 1000000000 1 3 1000000000 2 3 1 2 4 1000000000 ... |
| correct output |
|---|
| 2000000000 |
| user output |
|---|
| 2000000000 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 2 1 2 1 100 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 2 1000 1 2 1000000000 1 2 1000000000 1 2 1000000000 1 2 1000000000 ... |
| correct output |
|---|
| 1000000000000 |
| user output |
|---|
| 1000000000 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 500 998 1 2 54 1 3 59 1 4 83 2 5 79 ... |
| correct output |
|---|
| 60 |
| user output |
|---|
| 23 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 500 998 1 2 530873053 1 3 156306296 1 4 478040476 3 5 303609600 ... |
| correct output |
|---|
| 1093765123 |
| user output |
|---|
| 175616504 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 2 1 1 2 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 4 5 1 2 3 2 4 2 1 3 4 3 4 5 ... |
| correct output |
|---|
| 6 |
| user output |
|---|
| 6 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 4 5 1 2 1 1 3 2 3 2 1 2 4 2 ... |
| correct output |
|---|
| 3 |
| user output |
|---|
| 2 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 10 999 1 2 1000000000 1 2 1000000000 1 2 1000000000 1 2 1000000000 ... |
| correct output |
|---|
| 111000000000 |
| user output |
|---|
| 1000000000 |
Test 12
Verdict: ACCEPTED
| input |
|---|
| 7 9 1 2 1 1 3 1 1 4 1 2 5 1 ... |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
