Skip to content

Commit e5f96e5

Browse files
committed
Add problems from CF
1 parent 1ad59aa commit e5f96e5

File tree

3 files changed

+78
-1
lines changed
  • codeforces
    • Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

3 files changed

+78
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// http://codeforces.com/contest/765/problem/A
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
#define endl '\n'
7+
#define D(x) cout << #x << " = " << (x) << endl;
8+
9+
int main() {
10+
int n;
11+
cin >> n;
12+
13+
string h;
14+
cin >> h;
15+
16+
map<string, int> mapa;
17+
for (int i = 0; i < n; ++i) {
18+
string s;
19+
cin >> s;
20+
21+
string a, b;
22+
a = s.substr(0, 3);
23+
b = s.substr(5, 3);
24+
25+
if (a != h) mapa[b + a] ++;
26+
else mapa[a + b] ++;
27+
}
28+
29+
bool ok = true;
30+
for (auto i: mapa) {
31+
if (i.second % 2 != 0) {
32+
ok = false;
33+
break;
34+
}
35+
}
36+
37+
cout << (ok ? "home" : "contest") << endl;
38+
return 0;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// http://codeforces.com/contest/765/problem/B
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
#define endl '\n'
7+
#define D(x) cout << #x << " = " << (x) << endl;
8+
9+
int main() {
10+
string s;
11+
cin >> s;
12+
13+
bool ok = true;
14+
int next = 0;
15+
while (next < 26 && s.size() > 0) {
16+
int cur = s[0] - 'a';
17+
if (cur != next) {
18+
ok = false;
19+
break;
20+
}
21+
22+
string s2;
23+
for (int i = 0; i < s.size(); ++i) if ((int)(s[i] - 'a') != next) {
24+
s2.push_back(s[i]);
25+
}
26+
27+
s = s2;
28+
next ++;
29+
}
30+
31+
ok = !s.size();
32+
33+
cout << (ok ? "YES" : "NO") << endl;
34+
35+
return 0;
36+
}

codeforces/data.db

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,4 +932,6 @@
932932
24577323
933933
24578678
934934
24577407
935-
24578991
935+
24578991
936+
24681844
937+
24682004

0 commit comments

Comments
 (0)