MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / solve

Function solve

Codeforces_problems/RockPaperScissors/solution.cpp:38–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38inline void solve() {
39 int ans1 = INT_MAX;
40 vector<pair<int, int> > ord;
41 ord.pb({0, 0});
42 ord.pb({0, 2});
43 ord.pb({1, 1});
44 ord.pb({1, 0});
45 ord.pb({2, 2});
46 ord.pb({2, 1});
47 sort(all(ord));
48 do {
49 vector<int> a1 = a, b1 = b;
50 for (int i = 0; i < sz(ord); i++) {
51 int cnt = min(a1[ord[i].ft], b1[ord[i].sc]);
52 a1[ord[i].ft] -= cnt;
53 b1[ord[i].sc] -= cnt;
54 }
55 int cur = min(a1[0], b1[1]) + min(a1[1], b1[2]) + min(a1[2], b1[0]);
56 ans1 = min(ans1, cur);
57 } while(next_permutation(all(ord)));
58 int ans2 = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]);
59 cout << ans1 << ' ' << ans2 << endl;
60}
61
62int main () {
63 read();

Callers 1

mainFunction · 0.70

Calls 1

minFunction · 0.85

Tested by

no test coverage detected