Skip to content

Commit d2ed5c6

Browse files
Add 3 problems from AtCoder Regular Contest 131
1 parent 86af54d commit d2ed5c6

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

Atcoder/grid_repainting_4.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int H, W;
12+
cin >> H >> W;
13+
14+
vector<string> grid(H);
15+
for (int i = 0; i < H; i++)
16+
cin >> grid[i];
17+
18+
for (int i = 0; i < H; i++)
19+
for (int j = 0; j < W; j++)
20+
if (grid[i][j] == '.')
21+
for (char color = '1'; color <= '5'; color++) {
22+
if (i && grid[i - 1][j] == color) continue;
23+
if (i + 1 < H && grid[i + 1][j] == color) continue;
24+
if (j && grid[i][j - 1] == color) continue;
25+
if (j + 1 < W && grid[i][j + 1] == color) continue;
26+
27+
grid[i][j] = color;
28+
break;
29+
}
30+
31+
for (int i = 0; i < H; i++)
32+
cout << grid[i] << "\n";
33+
}

Atcoder/two_lucky_numbers.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int A, B;
12+
cin >> A >> B;
13+
14+
string ans = to_string((10 * B) / 2);
15+
ans += to_string(A);
16+
17+
cout << ans << "\n";
18+
}

Atcoder/zero_xor.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int N; cin >> N;
12+
13+
int x = 0;
14+
vector<int> A(N);
15+
16+
for (int i = 0; i < N; i++) {
17+
cin >> A[i];
18+
x ^= A[i];
19+
}
20+
21+
if (N & 1) cout << "Win\n";
22+
else {
23+
bool win = false;
24+
for (int i = 0; i < N && !win; i++)
25+
if (A[i] == x) win = true;
26+
27+
cout << (win ? "Win" : "Lose") << "\n";
28+
}
29+
}

0 commit comments

Comments
 (0)