卬高杯
提出id | 提出時刻 | ユーザー名 | 問題 | 言語 | 判定状況 | 判定 | 実行時間 |
---|---|---|---|---|---|---|---|
114887 | 2023-10-24 10:26:30 | euommo | H | cpp | - | CE | -1 |
#include <bits/stdc++.h>
struct UnionFind {
std::vector<int> e;
UnionFind(int n) : e(n, -1) {}
int find(int u) { return e[u] < 0 ? u : e[u] = find(e[u]); }
void join(int u, int v) {
u = find(u); v = find(v);
if (u == v) return;
if (e[u] > e[v]) std::swap(u, v);
e[u] += e[v]; e[v] = u;
return;
}
};
int main() {
std::cin.tie(0)->sync_with_stdio(0);
std::cin.exceptions(std::cin.failbit);
int N;
std::cin >> N;
std::vector<std::string> S(N);
for (string &s: S) std::cin >> s;
int ans = 0;
std::vector<std::vector<int>> dp(1 << N, std::vector<int>(N, 0));
for (int i = 0; i < (1 << N); ++i) {
for (int j = 0; j < N; ++j) if (i >> j & 1) {
for (int k = 0; k < N; ++k) if (k != j and (i >> k & 1) and S[k].back() == S[j][0])
dp[i][j] = std::max(dp[i][j], dp[i ^ (1 << j)][k]);
dp[i][j] += (int) S[j].size();
ans = max(ans, dp[i][j]);
}
}
std::cout << ans << '\n';
return 0;
}
-1 CE-1 CE
/var/www/judge/submit2/114887/a.cpp: In function ‘int main()’: /var/www/judge/submit2/114887/a.cpp:24:8: error: ‘string’ was not declared in this scope 24 | for (string &s: S) std::cin >> s; | ^~~~~~ /var/www/judge/submit2/114887/a.cpp:24:8: note: suggested alternatives: In file included from /usr/include/c++/11/iosfwd:39, from /usr/include/c++/11/ios:38, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from /var/www/judge/submit2/114887/a.cpp:1: /usr/include/c++/11/bits/stringfwd.h:79:33: note: ‘std::string’ 79 | typedef basic_string<char> string; | ^~~~~~ In file included from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from /var/www/judge/submit2/114887/a.cpp:1: /usr/include/c++/11/string:67:11: note: ‘std::pmr::string’ 67 | using string = basic_string<char>; | ^~~~~~ /var/www/judge/submit2/114887/a.cpp:24:17: error: found ‘:’ in nested-name-specifier, expected ‘::’ 24 | for (string &s: S) std::cin >> s; | ^ | :: /var/www/judge/submit2/114887/a.cpp:24:16: error: ‘s’ has not been declared 24 | for (string &s: S) std::cin >> s; | ^ /var/www/judge/submit2/114887/a.cpp:28:33: error: expected primary-expression before ‘dp’ 28 | std::vector<std::vector<int>> dp(1 << N, std::vector<int>(N, 0)); | ^~ /var/www/judge/submit2/114887/a.cpp:28:32: error: expected ‘)’ before ‘dp’ 28 | std::vector<std::vector<int>> dp(1 << N, std::vector<int>(N, 0)); | ^~~ | ) /var/www/judge/submit2/114887/a.cpp:24:7: note: to match this ‘(’ 24 | for (string &s: S) std::cin >> s; | ^ /var/www/judge/submit2/114887/a.cpp:28:33: error: ‘dp’ was not declared in this scope; did you mean ‘dup’? 28 | std::vector<std::vector<int>> dp(1 << N, std::vector<int>(N, 0)); | ^~ | dup /var/www/judge/submit2/114887/a.cpp:32:9: error: ‘dp’ was not declared in this scope; did you mean ‘dup’? 32 | dp[i][j] = std::max(dp[i][j], dp[i ^ (1 << j)][k]); | ^~ | dup /var/www/judge/submit2/114887/a.cpp:33:7: error: ‘dp’ was not declared in this scope; did you mean ‘dup’? 33 | dp[i][j] += (int) S[j].size(); | ^~ | dup /var/www/judge/submit2/114887/a.cpp:34:7: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 34 | ans = max(ans, dp[i][j]); | ^~~ | abs /var/www/judge/submit2/114887/a.cpp:34:13: error: ‘max’ was not declared in this scope 34 | ans = max(ans, dp[i][j]); | ^~~ /var/www/judge/submit2/114887/a.cpp:34:13: note: suggested alternatives: In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from /var/www/judge/submit2/114887/a.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ In file included from /usr/include/c++/11/algorithm:64, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from /var/www/judge/submit2/114887/a.cpp:1: /usr/include/c++/11/bits/ranges_algo.h:3011:29: note: ‘std::ranges::max’ 3011 | inline constexpr __max_fn max{}; | ^~~ /var/www/judge/submit2/114887/a.cpp:38:16: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 38 | std::cout << ans << '\n'; | ^~~ | abs