Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo314 committed Nov 24, 2024
1 parent 850bec7 commit 1b8c477
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cpp/functional-graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct FunctionalGraph {
depth[v[j]] = k - j;
connected_list.back().push_back(v[j]);
}
for (int j = k; j < v.size(); j++) {
for (int j = k; j < (int)v.size(); j++) {
is_cycle[v[j]] = true;
root[v[j]] = v[j];
cycle_list.back().push_back(v[j]);
Expand All @@ -63,7 +63,7 @@ struct FunctionalGraph {
connected_list.back().push_back(v[j]);
}
} else {
for (int j = 0; j < v.size(); j++) {
for (int j = 0; j < (int)v.size(); j++) {
is_cycle[v[j]] = false;
root[v[j]] = root[u];
root_idx[v[j]] = root_idx[u];
Expand All @@ -83,7 +83,7 @@ struct FunctionalGraph {
for (int k = 0; !tmp.empty(); k++) {
std::vector<int> next_tmp;
for (int i : tmp) {
if (k < doubling[doubling[i][k]].size()) {
if (k < (int)doubling[doubling[i][k]].size()) {
doubling[i].push_back(doubling[doubling[i][k]][k]);
next_tmp.push_back(i);
}
Expand Down Expand Up @@ -132,7 +132,7 @@ struct FunctionalGraph {
x = root[x];
k %= cycle_list[connected_id[x]].size();
int y = root_idx[x] + k;
if (cycle_list[connected_id[x]].size() <= y) {
if ((int)cycle_list[connected_id[x]].size() <= y) {
y -= cycle_list[connected_id[x]].size();
}
return cycle_list[connected_id[x]][y];
Expand All @@ -149,6 +149,6 @@ struct FunctionalGraph {
* @brief 頂点xから0回以上の移動でたどり着ける頂点の個数
*/
int hopable(int x) const {
return depth[x] + cycle_list[connected_id[x]].size();
return depth[x] + (int)cycle_list[connected_id[x]].size();
}
};
2 changes: 1 addition & 1 deletion test/atcoder-abc256-d.test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define PROBLEM "https://atcoder.jp/contests/abc256/tasks/abc256_d"
#define PROBLEM "https://atcoder.jp/contests/abc256/tasks/abc256_e"

#include <iostream>

Expand Down
22 changes: 22 additions & 0 deletions test/atcoder-abc256-e.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#define PROBLEM "https://atcoder.jp/contests/abc256/tasks/abc256_d"

Check failure on line 1 in test/atcoder-abc256-e.test.cpp

View workflow job for this annotation

GitHub Actions / verify

failed to verify

#include <iostream>

#include "../cpp/functional-graph.hpp"

int main(void) {
int N;
std::cin >> N;
FunctionalGraph fg(N);
fg.read();
std::vector<int> C(N);
for (int& c : C) std::cin >> c;
long long ans = 0;
for (const auto& cycle : fg.cycle_list) {
int tmp = 1 << 30;
for (int u : cycle)
if (C[u] < tmp) tmp = C[u];
ans += tmp;
}
std::cout << ans << std::endl;
}

0 comments on commit 1b8c477

Please sign in to comment.