diff --git a/atcoder/abc071/A/main.cpp b/atcoder/abc071/A/main.cpp new file mode 100644 index 00000000..4b0ec7aa --- /dev/null +++ b/atcoder/abc071/A/main.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; +using ll = long long; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + int x, a, b; + cin >> x >> a >> b; + int da = abs(x - a); + int db = abs(x - b); + if (da < db) { + cout << "A" << endl; + } else if (db < da) { + cout << "B" << endl; + } else throw; + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc071/B/main.cpp b/atcoder/abc071/B/main.cpp new file mode 100644 index 00000000..82f2cdf5 --- /dev/null +++ b/atcoder/abc071/B/main.cpp @@ -0,0 +1,30 @@ +#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; + + vector used(26, false); + for (auto ch : S) { + int i = (ch - 'a'); + used[i] = true; + } + int i; + for (i = 0; i < 26; ++i) { + if (used[i]) continue; + break; + } + if (i < 26) { + cout << char('a' + i) << endl; + } else { + cout << "None" << endl; + } + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc071/C/main.cpp b/atcoder/abc071/C/main.cpp new file mode 100644 index 00000000..eb643e15 --- /dev/null +++ b/atcoder/abc071/C/main.cpp @@ -0,0 +1,43 @@ +#include + +using namespace std; +using ll = long long; + +int N; +vector A; + +ll solve() { + map mp; + for (auto v : A) { + ++mp[v]; + } + + ll ans = 0; + deque Q; + for (auto e : mp) { + auto v = e.first, c = e.second; + if (c <= 1) continue; + if (c >= 4) { + ans = max(ans, ll(v) * v); + } + Q.push_back(v); + if (Q.size() < 2) continue; + if (Q.size() > 2) Q.pop_front(); + ans = max(ans, ll(Q[0]) * Q[1]); + } + return ans; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> N; + A.assign(N, 0); + for (int i = 0; i < N; ++i) { + cin >> A[i]; + } + cout << solve() << endl; + + return 0; +} \ No newline at end of file diff --git a/atcoder/abc071/D/main.cpp b/atcoder/abc071/D/main.cpp new file mode 100644 index 00000000..af780370 --- /dev/null +++ b/atcoder/abc071/D/main.cpp @@ -0,0 +1,54 @@ +#include + +using namespace std; +using ll = long long; + +ll MOD = 1000000007; + +int N; +vector S(2); + +ll solve() { + vector DP(N, 0); + for (int x = 0; x < N; ++x) { + if (S[0][x] == S[1][x]) { + if (x == 0) { + // | + DP[x] = 3; + } else if (S[0][x-1] == S[1][x-1]) { + // || + DP[x] = DP[x-1] * 2 % MOD; + } else { + // =| + DP[x] = DP[x-1]; + } + } else if (x > 0 && S[0][x] == S[0][x-1]) { + // = + DP[x] = DP[x-1]; + } else { + if (x == 0) { + // = + DP[x] = 6; + } else if (S[0][x-1] == S[1][x-1]) { + // |= + DP[x] = DP[x-1] * 2 % MOD; + } else { + // == + DP[x] = DP[x-1] * 3 % MOD; + } + } + } + return DP[N-1]; +} + + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> N; + cin >> S[0] >> S[1]; + cout << solve() << endl; + + return 0; +} \ No newline at end of file