luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/QUPO #716

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Chi tiết bài tập - Luyện Code Online

https://luyencode.net/problem/QUPO

ghost commented 2 years ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

```cpp #include #define FOR(i, l, r) for(int i = l; i <= r; ++i) #define FOD(i, l, r) for(int i = l; i >= r; --i) #define ll long long using namespace std; // Topic variable. int a, b; int c, d; int e, g; // Auxiliary variable. //___________________ bool GOC(int x, int y) { if (x == 0) { if (y == 0 || y == 8) return true; return false; } if (x == 9) { if (y == 0 || y == 8) return true; return false; } return false; } bool SoSa(int a, int b, int c) { return (a == b && b == c); } string res() { if (GOC(g, e)) cout << "-1"; else if (g == 0 && d > 0) return "-1"; else if (g == 9 && d < 9) return "-1"; else if (e == 0 && c > 0) return "-1"; else if (e == 8 && c < 8) return "-1"; else if (d != g && c != e) return "-1"; else if (SoSa(a, c, e)) { if ((b > g && g > d) || (b < g && g < d)) return "1"; else return "4"; } else if (SoSa(b, d, g)) { if ((a > e && e > c) || (a < e && e < c)) return "1"; else return "4"; } else if ((b > g && g > d) || (b < g && g < d)) return "2"; else if ((a > e && e > c) || (a < e && e < c)) return "2"; else return "3"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> b >> a; cin >> d >> c; cin >> g >> e; cout << res(); return 0; } ```