Find heavy ball - level: master
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<vector> using namespace std; unsigned int findBall(Scales scales) { int w = scales.getWeight({0,1,2},{3,4,5}); if(w == 0) { return scales.getWeight({6},{7}) == 1 ? 7 : 6; } if(w == 1) { w = scales.getWeight({3},{4}); if(w == 0) return 5; return w == 1 ? 4 : 3; } w = scales.getWeight({0},{1}); if(w == 0) return 2; return w == 1 ? 1 : 0; }
|