-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Contest.cpp
More file actions
258 lines (251 loc) · 6.32 KB
/
A_Contest.cpp
File metadata and controls
258 lines (251 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
// gl hf
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define bl bool
#define vct vector
#define ull unsigned long long
#define vi vector<ll>
#define vl vector<ll>
#define vb vector<bl>
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define vpvp vector<pair<ll, pair<ll, ll>>>
#define Map map<ll, ll>
#define Set set<ll>
#define PQ priority_queue<ll>
#define MinPQ priority_queue<ll, vector<ll>, greater<ll>>
#define UM unordered_map<ll, ll>
#define US unordered_set<ll>
#define Stk stack<ll>
#define Que queue<ll>
#define Deque deque<ll>
#define OS ordered_set<ll>
#define Rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define For(i, n) for (ll i = 0; i < (n); ++i)
#define Rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define ForV(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define cinAll(v) \
for (auto &x : v) \
cin >> x;
#define coutAll(v) \
for (const auto &x : v) \
cout << x << " ";
#define sumAll(v) accumulate(v.begin(), v.end(), 0LL)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define sortAll(v) sort(v.begin(), v.end())
#define sortMax64(v) sort(v.begin(), v.end(), std::greater<ll>())
#define sortMax32(v) sort(v.begin(), v.end(), std::greater<int>())
#define py cout << "YES" << endl;
#define pn cout << "NO" << endl;
#define ps cout << " " << endl;
#define nocap true
#define cap false
#define dbg(x) cout << x << endl;
#define r return;
#define minAll(v) *min_element(v.begin(), v.end())
#define maxAll(v) *max_element(v.begin(), v.end())
#define firstSet(x) __builtin_ffs(x) - 1
#define countSet(x) __builtin_popcount(x)
#define leadingZeros(x) __builtin_clz(x)
#define trailingZeros(x) __builtin_ctz(x)
#define parityBit(x) __builtin_parity(x)
#define leadingSignBits(x) __builtin_clrsb(x)
#define byteSwap32(x) __builtin_bswap32(x)
#define byteSwap64(x) __builtin_bswap64(x)
#define addOverflow(a, b, res) __builtin_add_overflow(a, b, res)
#define subOverflow(a, b, res) __builtin_sub_overflow(a, b, res)
#define mulOverflow(a, b, res) __builtin_mul_overflow(a, b, res)
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll NEG = -1e9;
// Graph Algorithms
/********************************** DSU **********************************/
struct DSU
{
vector<int> parent, size;
DSU(int n)
{
parent.resize(n);
size.resize(n, 1);
For(i, n) parent[i] = i;
}
int find(int v)
{
if (v == parent[v])
return v;
return parent[v] = find(parent[v]);
}
bool unite(int a, int b)
{
a = find(a);
b = find(b);
if (a != b)
{
if (size[a] < size[b])
swap(a, b);
parent[b] = a;
size[a] += size[b];
return true;
}
return false;
}
};
/******************************** Dijkstra ********************************/
vector<ll> dijkstra(int src, int n, vector<vector<pii>> &adj)
{
vector<ll> dist(n, INF);
priority_queue<pll, vector<pll>, greater<pll>> pq;
pq.push({0, src});
dist[src] = 0;
while (!pq.empty())
{
ll d = pq.top().first;
int u = pq.top().second;
pq.pop();
if (d > dist[u])
continue;
for (auto edge : adj[u])
{
int v = edge.first;
ll weight = edge.second;
if (dist[u] + weight < dist[v])
{
dist[v] = dist[u] + weight;
pq.push({dist[v], v});
}
}
}
return dist;
}
/******************************* Kruskal MST ******************************/
struct Edge
{
int u, v;
ll weight;
bool operator<(Edge const &other)
{
return weight < other.weight;
}
};
ll kruskal(int n, vector<Edge> &edges)
{
sort(all(edges));
DSU dsu(n);
ll total_weight = 0;
for (Edge e : edges)
{
if (dsu.unite(e.u, e.v))
{
total_weight += e.weight;
}
}
return total_weight;
}
/****************************** Bellman-Ford *******************************/
bool bellman_ford(int src, int n, vector<Edge> &edges, vector<ll> &dist)
{
dist.assign(n, INF);
dist[src] = 0;
for (int i = 0; i < n - 1; ++i)
{
for (Edge e : edges)
{
if (dist[e.u] < INF && dist[e.u] + e.weight < dist[e.v])
{
dist[e.v] = dist[e.u] + e.weight;
}
}
}
// Check for negative cycles
for (Edge e : edges)
{
if (dist[e.u] < INF && dist[e.u] + e.weight < dist[e.v])
{
return false; // Negative cycle detected
}
}
return true;
}
/**************************** Floyd-Warshall ****************************/
void floyd_warshall(vector<vector<ll>> &dist, int n)
{
For(k, n)
{
For(i, n)
{
For(j, n)
{
if (dist[i][k] < INF && dist[k][j] < INF)
{
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
}
}
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
os << "{ ";
for (const T &x : v)
os << x << " ";
os << "}";
return os;
}
void solve()
{
ll a, b, ta, tb;
cin >> a >> b >> ta >> tb;
ll apt = max(3 * (a * 1.0) / 10, a - ((1.0 * a / 250) * ta));
ll bpt = max(3 * (1.0 * b) / 10, b - ((1.0 * b / 250) * tb));
if (apt > bpt)
{
dbg("Misha")
}
else if (bpt > apt)
{
dbg("Vasya")
}
else
{
dbg("Tie")
}
}
// gg wp
int main()
{
const static auto fast = []()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
ll t = 1;
if (t != 1)
cin >> t;
while (t--)
{
solve();
}
return 0;
}