Skip to content

Commit d06fb28

Browse files
authored
Merge branch 'main' into atcoder/abc076
2 parents f256611 + 0507993 commit d06fb28

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed

atcoder/abc055/A/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 N;
11+
cin >> N;
12+
int x = N * 800;
13+
int y = N / 15 * 200;
14+
cout << x - y << endl;
15+
16+
return 0;
17+
}

atcoder/abc055/B/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
ll solve(int N) {
7+
const ll MOD = 1e9+7;
8+
ll p = 1;
9+
for (int i = 0; i < N; ++i) {
10+
p *= (i+1);
11+
p %= MOD;
12+
}
13+
return p;
14+
}
15+
16+
int main() {
17+
ios_base::sync_with_stdio(false);
18+
cin.tie(0); cout.tie(0);
19+
20+
int N;
21+
cin >> N;
22+
cout << solve(N) << endl;
23+
24+
return 0;
25+
}

atcoder/abc055/C/main.cpp

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

atcoder/abc055/D/main.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N;
7+
string S;
8+
9+
bool solve(vector<char>& ws, char c0, char c1) {
10+
ws[0] = c0, ws[1] = c1;
11+
for (int i = 1; i < N; ++i) {
12+
int j = (i - 1 + N) % N, k = (i + 1) % N;
13+
if (S[i] == 'o') {
14+
if (ws[i] == 'S') ws[k] = ws[j];
15+
if (ws[i] == 'W') ws[k] = ws[j] == 'S' ? 'W' : 'S';
16+
}
17+
if(S[i] == 'x') {
18+
if (ws[i] == 'S') ws[k] = ws[j] == 'S' ? 'W' : 'S';
19+
if (ws[i] == 'W') ws[k] = ws[j];
20+
}
21+
}
22+
bool satisfy = true;
23+
for (int i = 0; i < N; ++i) {
24+
int j = (i - 1 + N) % N, k = (i + 1) % N;
25+
if (S[i] == 'o') {
26+
if (ws[i] == 'S') satisfy &= (ws[k] == ws[j]);
27+
if (ws[i] == 'W') satisfy &= (ws[k] != ws[j]);
28+
}
29+
if (S[i] == 'x') {
30+
if (ws[i] == 'S') satisfy &= (ws[k] != ws[j]);
31+
if (ws[i] == 'W') satisfy &= (ws[k] == ws[j]);
32+
}
33+
}
34+
return satisfy;
35+
}
36+
37+
vector<char> solve() {
38+
vector<char> ws(N, ' ');
39+
if (solve(ws, 'S', 'S')) return ws;
40+
if (solve(ws, 'S', 'W')) return ws;
41+
if (solve(ws, 'W', 'S')) return ws;
42+
if (solve(ws, 'W', 'W')) return ws;
43+
return {};
44+
}
45+
46+
int main() {
47+
ios_base::sync_with_stdio(false);
48+
cin.tie(0); cout.tie(0);
49+
50+
cin >> N;
51+
cin >> S;
52+
auto ans = solve();
53+
cout << (ans.size() == 0 ? "-1" : string(ans.begin(), ans.end())) << endl;
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)