Skip to content

Commit 46ab7cc

Browse files
committed
Codeforces: European Championship 2025 - Online Mirror (Unrated, ICPC Rules, Teams Preferred)
1 parent 863b927 commit 46ab7cc

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

Codeforces/2068F.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @file 2068F.cpp
3+
* @author Macesuted ([email protected])
4+
* @date 2025-04-24
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#define endl '\n'
14+
15+
#define maxn 200005
16+
17+
vector<int> rec[26];
18+
string s[maxn];
19+
20+
void solve(void) {
21+
int n;
22+
cin >> n;
23+
for (int i = 1; i <= n; i++) {
24+
cin >> s[i];
25+
reverse(s[i].begin(), s[i].end());
26+
rec[s[i].back() - 'a'].push_back(i);
27+
}
28+
string t, ans;
29+
cin >> t;
30+
reverse(t.begin(), t.end());
31+
while (n) {
32+
int p = -1;
33+
for (int x = 0; x < 26; x++)
34+
if (t.back() - 'a' != x && !rec[x].empty()) p = x;
35+
if (p == -1) {
36+
p = t.back() - 'a';
37+
t.pop_back();
38+
if (t.empty()) return cout << "NO" << endl, void();
39+
}
40+
ans.push_back(p + 'a');
41+
vector<int> rrec;
42+
rrec.swap(rec[p]);
43+
for (auto idx : rrec) {
44+
s[idx].pop_back();
45+
if (s[idx].empty())
46+
n--;
47+
else
48+
rec[s[idx].back() - 'a'].push_back(idx);
49+
}
50+
}
51+
cout << "YES" << endl << ans << endl;
52+
return;
53+
}
54+
55+
int main() {
56+
ios::sync_with_stdio(false), cin.tie(nullptr);
57+
58+
int _ = 1;
59+
while (_--) solve();
60+
61+
return 0;
62+
}

Codeforces/2068J.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file 2068J.cpp
3+
* @author Macesuted ([email protected])
4+
* @date 2025-04-24
5+
*
6+
* @copyright Copyright (c) 2025
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#define endl '\n'
14+
15+
void solve(void) {
16+
int n;
17+
string s;
18+
cin >> n >> s;
19+
int cnt[2] = {0, 0};
20+
for (int i = 0; i < n; i++) cnt[s[i] == 'R']++;
21+
if (cnt[0] & 1) return cout << "NO" << endl, void();
22+
for (int i = 0; i < (cnt[0] >> 1); i++)
23+
if (s[i] == 'R' || s[s.size() - 1 - i] == 'W') return cout << "NO" << endl, void();
24+
cout << "YES" << endl;
25+
return;
26+
}
27+
28+
int main() {
29+
ios::sync_with_stdio(false), cin.tie(nullptr);
30+
31+
int _ = 1;
32+
cin >> _;
33+
while (_--) solve();
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)