Skip to content

Commit a155a83

Browse files
authored
Merge pull request #308 from xirc/atcoder/abc071
AtCoder/ABC071
2 parents 1156503 + bdf65ef commit a155a83

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

atcoder/abc071/A/main.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
int x, a, b;
11+
cin >> x >> a >> b;
12+
int da = abs(x - a);
13+
int db = abs(x - b);
14+
if (da < db) {
15+
cout << "A" << endl;
16+
} else if (db < da) {
17+
cout << "B" << endl;
18+
} else throw;
19+
20+
return 0;
21+
}

atcoder/abc071/B/main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
string S;
11+
cin >> S;
12+
13+
vector<bool> used(26, false);
14+
for (auto ch : S) {
15+
int i = (ch - 'a');
16+
used[i] = true;
17+
}
18+
int i;
19+
for (i = 0; i < 26; ++i) {
20+
if (used[i]) continue;
21+
break;
22+
}
23+
if (i < 26) {
24+
cout << char('a' + i) << endl;
25+
} else {
26+
cout << "None" << endl;
27+
}
28+
29+
return 0;
30+
}

atcoder/abc071/C/main.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N;
7+
vector<int> A;
8+
9+
ll solve() {
10+
map<int,int> mp;
11+
for (auto v : A) {
12+
++mp[v];
13+
}
14+
15+
ll ans = 0;
16+
deque<int> Q;
17+
for (auto e : mp) {
18+
auto v = e.first, c = e.second;
19+
if (c <= 1) continue;
20+
if (c >= 4) {
21+
ans = max(ans, ll(v) * v);
22+
}
23+
Q.push_back(v);
24+
if (Q.size() < 2) continue;
25+
if (Q.size() > 2) Q.pop_front();
26+
ans = max(ans, ll(Q[0]) * Q[1]);
27+
}
28+
return ans;
29+
}
30+
31+
int main() {
32+
ios_base::sync_with_stdio(false);
33+
cin.tie(0); cout.tie(0);
34+
35+
cin >> N;
36+
A.assign(N, 0);
37+
for (int i = 0; i < N; ++i) {
38+
cin >> A[i];
39+
}
40+
cout << solve() << endl;
41+
42+
return 0;
43+
}

atcoder/abc071/D/main.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
ll MOD = 1000000007;
7+
8+
int N;
9+
vector<string> S(2);
10+
11+
ll solve() {
12+
vector<ll> DP(N, 0);
13+
for (int x = 0; x < N; ++x) {
14+
if (S[0][x] == S[1][x]) {
15+
if (x == 0) {
16+
// |
17+
DP[x] = 3;
18+
} else if (S[0][x-1] == S[1][x-1]) {
19+
// ||
20+
DP[x] = DP[x-1] * 2 % MOD;
21+
} else {
22+
// =|
23+
DP[x] = DP[x-1];
24+
}
25+
} else if (x > 0 && S[0][x] == S[0][x-1]) {
26+
// =
27+
DP[x] = DP[x-1];
28+
} else {
29+
if (x == 0) {
30+
// =
31+
DP[x] = 6;
32+
} else if (S[0][x-1] == S[1][x-1]) {
33+
// |=
34+
DP[x] = DP[x-1] * 2 % MOD;
35+
} else {
36+
// ==
37+
DP[x] = DP[x-1] * 3 % MOD;
38+
}
39+
}
40+
}
41+
return DP[N-1];
42+
}
43+
44+
45+
int main() {
46+
ios_base::sync_with_stdio(false);
47+
cin.tie(0); cout.tie(0);
48+
49+
cin >> N;
50+
cin >> S[0] >> S[1];
51+
cout << solve() << endl;
52+
53+
return 0;
54+
}

0 commit comments

Comments
 (0)