Skip to content

Commit 1ad59aa

Browse files
committed
Add round 379 from CF
1 parent 1dcf35c commit 1ad59aa

File tree

4 files changed

+163
-1
lines changed

4 files changed

+163
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// http://codeforces.com/contest/734/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 s;
14+
cin >> s;
15+
16+
int cnt = 0;
17+
for (int i = 0; i < s.size(); ++i) {
18+
if (s[i] == 'D') cnt ++;
19+
}
20+
21+
if (cnt > s.size() - cnt) cout << "Danik" << endl;
22+
else if ( cnt < s.size() - cnt) cout << "Anton" << endl;
23+
else cout << "Friendship" << endl;
24+
25+
return 0;
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// http://codeforces.com/contest/734/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+
int a, b, c, d;
11+
cin >> a >> b >> c >> d;
12+
13+
long long mm = min(a, min(c, d));
14+
long long sum = mm * 256LL;
15+
a -= mm;
16+
c -= mm;
17+
d -= mm;
18+
19+
mm = min(a, b);
20+
sum += mm * 32LL;
21+
22+
cout << sum << endl;
23+
24+
return 0;
25+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// http://codeforces.com/contest/734/problem/D
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+
const long long inf = LLONG_MAX;
10+
11+
struct Piece {
12+
long long x, y, t;
13+
Piece () {}
14+
Piece (long long a, long long b, long long c) {
15+
x = a;
16+
y = b;
17+
t = c;
18+
}
19+
};
20+
21+
long long dist (long long x1, long long y1, long long x2, long long y2) {
22+
return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
23+
}
24+
25+
long long f (long long x, long long y, long long x2, long long y2, long long type, long long k) {
26+
long long d = dist (x, y, x2, y2);
27+
28+
if (type == 1) if (x + k == x2 && y + k == y2) return d;
29+
if (type == 2) if (x - k == x2 && y - k == y2) return d;
30+
if (type == 3) if (x + k == x2 && y - k == y2) return d;
31+
if (type == 4) if (x - k == x2 && y + k == y2) return d;
32+
33+
if (type == 5) if (x - k == x2 && y == y2) return d;
34+
if (type == 6) if (x + k == x2 && y == y2) return d;
35+
if (type == 7) if (x == x2 && y - k == y2) return d;
36+
if (type == 8) if (x == x2 && y + k == y2) return d;
37+
38+
return inf;
39+
}
40+
41+
int main() {
42+
int n;
43+
cin >> n;
44+
45+
long long x, y;
46+
cin >> x >> y;
47+
48+
vector<Piece> v;
49+
for (int i = 0; i < n; ++i) {
50+
char op;
51+
cin >> op;
52+
53+
long long x2, y2;
54+
cin >> x2 >> y2;
55+
if (op == 'Q') {
56+
v.push_back(Piece(x2, y2, 0));
57+
}
58+
else if (op == 'B') {
59+
v.push_back(Piece(x2, y2, 1));
60+
}
61+
else {
62+
v.push_back(Piece(x2, y2, 2));
63+
}
64+
}
65+
66+
for (int j = 1; j <= 8; ++j) {
67+
long long mm = inf;
68+
bool found = false;
69+
Piece p;
70+
for (int i = 0; i < n; ++i) {
71+
long long a = f(x, y, v[i].x, v[i].y, j, abs(v[i].y - y));
72+
long long b = f(x, y, v[i].x, v[i].y, j, abs(v[i].x - x));
73+
long long tmp = min(a, b);
74+
75+
if (tmp < mm) {
76+
mm = tmp;
77+
p = v[i];
78+
found = true;
79+
}
80+
}
81+
82+
bool paila = false;
83+
if (found) {
84+
for (int i = 1; i <= 8; ++i) {
85+
if (p.t == 1 && i > 4) continue;
86+
if (p.t == 2 && i < 5) continue;
87+
88+
long long a = f(p.x, p.y, x, y, i, abs(p.y - y));
89+
long long b = f(p.x, p.y, x, y, i, abs(p.x - x));
90+
long long tmp = min(a, b);
91+
if (tmp != inf) {
92+
paila = true;
93+
break;
94+
}
95+
}
96+
}
97+
98+
if (paila) {
99+
cout << "YES" << endl;
100+
return 0;
101+
}
102+
}
103+
104+
cout << "NO" << endl;
105+
106+
return 0;
107+
}

codeforces/data.db

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,4 +928,8 @@
928928
24357587
929929
24539441
930930
24537637
931-
24537148
931+
24537148
932+
24577323
933+
24578678
934+
24577407
935+
24578991

0 commit comments

Comments
 (0)