Skip to content

Commit

Permalink
add: functional-graph test
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo314 committed Nov 24, 2024
1 parent 68c557a commit 6898038
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/atcoder-abc228-b.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#define PROBLEM "https://atcoder.jp/contests/abc228/tasks/abc228_b"

#include <iostream>

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

int main(void) {
int N, X;
std::cin >> N >> X;
FunctionalGraph fg(N);
fg.read();
std::cout << fg.hopable(X - 1) << std::endl;
}
22 changes: 22 additions & 0 deletions test/atcoder-abc256-d.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-d.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;
}
23 changes: 23 additions & 0 deletions test/atcoder-abc367-e.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#define PROBLEM "https://atcoder.jp/contests/abc367/tasks/abc367_e"

#include <iostream>

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

int main(void) {
int N;
long long K;
std::cin >> N >> K;
FunctionalGraph fg(N);
fg.read();
std::vector<int> A(N);
for (int& a : A) std::cin >> a;
for (int i = 0; i < N; i++) {
std::cout << A[fg.hop(i, K)];
if (i == N - 1) {
std::cout << std::endl;
} else {
std::cout << ' ';
}
}
}

0 comments on commit 6898038

Please sign in to comment.