Created
December 29, 2016 21:48
-
-
Save grim-yawn/d7c88ed863f398b51ba511c19df23718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| #include <utility> | |
| #include <iostream> | |
| #include <algorithm> | |
| using namespace std; | |
| class Triplet | |
| { | |
| public: | |
| static Triplet read_triplet_from_stdin() | |
| { | |
| Triplet triplet; | |
| for (auto & el: triplet.triplet) { | |
| std::cin >> el; | |
| } | |
| return triplet; | |
| } | |
| std::pair<int, int> compute_scores( const Triplet & other) | |
| { | |
| std::pair<int, int> res{0, 0}; | |
| for (int i = 0; i < 3; ++i) { | |
| if (triplet[i] > other.triplet[i]) { | |
| res.first++; | |
| } else if (triplet[i] < other.triplet[i]){ | |
| res.second++; | |
| } | |
| } | |
| return res; | |
| } | |
| private: | |
| Triplet() = default; | |
| std::array<int, 3> triplet; | |
| }; | |
| int main() { | |
| auto alice = Triplet::read_triplet_from_stdin(); | |
| auto bob = Triplet::read_triplet_from_stdin(); | |
| auto res = alice.compute_scores(bob); | |
| std::cout << res.first << ' ' << res.second << std::endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment