diff --git a/atcoder/abc051/A/main.cpp b/atcoder/abc051/A/main.cpp new file mode 100644 index 00000000..40a7a3e8 --- /dev/null +++ b/atcoder/abc051/A/main.cpp @@ -0,0 +1,17 @@ +#include + +using namespace std; +using ll = long long; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + string s; + cin >> s; + s[5] = ' '; + s[13] = ' '; + cout << s << endl; + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc051/B/main.cpp b/atcoder/abc051/B/main.cpp new file mode 100644 index 00000000..1212f06b --- /dev/null +++ b/atcoder/abc051/B/main.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; +using ll = long long; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + int K, S; + cin >> K >> S; + + int ans = 0; + for (int x = 0; x <= K; ++x) { + for (int y = 0; y <=K; ++y) { + int z = S - (x + y); + if (z <= K && z >= 0) ++ans; + } + } + cout << ans << endl; + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc051/C/main.cpp b/atcoder/abc051/C/main.cpp new file mode 100644 index 00000000..7266a042 --- /dev/null +++ b/atcoder/abc051/C/main.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; +using ll = long long; + +int sx, sy, tx, ty; + +string solve() { + int W = tx - sx, H = ty - sy; + assert(W > 0 && H > 0); + + vector route; + for (int x = 0; x < W; ++x) route.push_back('R'); + for (int y = 0; y < H; ++y) route.push_back('U'); + for (int x = 0; x < W; ++x) route.push_back('L'); + for (int y = 0; y < H; ++y) route.push_back('D'); + route.push_back('D'); + for (int x = 0; x < W + 1; ++x) route.push_back('R'); + for (int y = 0; y < H + 1; ++y) route.push_back('U'); + route.push_back('L'); + route.push_back('U'); + for (int x = 0; x < W + 1; ++x) route.push_back('L'); + for (int y = 0; y < H + 1; ++y) route.push_back('D'); + route.push_back('R'); + + return string(route.begin(), route.end()); +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> sx >> sy >> tx >> ty; + cout << solve() << endl; + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc051/D/main.cpp b/atcoder/abc051/D/main.cpp new file mode 100644 index 00000000..a191c405 --- /dev/null +++ b/atcoder/abc051/D/main.cpp @@ -0,0 +1,56 @@ +#include + +using namespace std; +using ll = long long; + +const int inf = 1e7; +int N, M; +vector> G; +vector> O; + +int solve() { + // COPY + O = G; + + for (int k = 0; k < N; ++k) { + for (int i = 0; i < N; ++i) { + for (int j = 0; j < N; ++j) { + if (G[i][k] == inf || G[k][j] == inf) continue; + if (G[i][k] + G[k][j] < G[i][j]) { + G[i][j] = G[i][k] + G[k][j]; + } + } + } + } + + int ans = 0; + for (int i = 0; i < N; ++i) { + for (int j = i + 1; j < N; ++j) { + if (i == j || O[i][j] == inf) continue; + bool use = false; + for (int s = 0; s < N; ++s) { + if (G[s][i] + O[i][j] == G[s][j]) use = true; + } + if (!use) ++ans; + } + } + return ans; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> N >> M; + G.assign(N, vector(N, inf)); + for (int i = 0; i < N; ++i) G[i][i] = 0; + for (int i = 0; i < M; ++i) { + int a, b, c; + cin >> a >> b >> c; + --a, --b; + G[a][b] = G[b][a] = c; + } + cout << solve() << endl; + + return 0; +} \ No newline at end of file