fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
Codeforces Round 1046-A (Div. 2) (C++) In the Dream
최초 업로드: 2025-08-28 19:10:20
최근 수정 시간: 2025-08-30 14:05:55
게시자: rlatjwls3333
카테고리: Codeforces
조회수: 47
# A. In the Dream [문제 링크](https://codeforces.com/contest/2136/problem/A) ## Problem Statement Two football teams, the RiOI team and the KDOI team, are about to have a football match. A football match consists of two halves — the first half and the second half. At the beginning of the match, both teams have a score of \$0\$. As a fan of both teams, Aquawave knows that the two teams have similar levels, so neither team will score **three consecutive** goals in the **same half**. Aquawave had a dream the night before the match, in which: * The score at the end of the first half was \$a\:b\$, where \$a\$ is the score of the RiOI team, and \$b\$ is the score of the KDOI team; * And, the score at the end of the second half was \$c\:d\$, where \$c\$ is the score of the RiOI team, and \$d\$ is the score of the KDOI team. You have to determine whether Aquawave's dream can come true according to the above information. ## Input Each test contains multiple test cases. The first line contains the number of test cases \$t\$ (\$1 \le t \le 1000\$). The description of the test cases follows. The only line of each test case contains four integers \$a\$, \$b\$, \$c\$, and \$d\$ (\$0 \le a \le c \le 100\$, \$0 \le b \le d \le 100\$) — the score at the end of the first half and the score at the end of the second half. ## Output For each test case, print "YES" if Aquawave's dream can come true. Otherwise, print "NO". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses. ## 풀이 최대로는 bb a bb a ... bb 이렇게 번갈아가며 나올 수 있기에 두 점수는 +1한 값의 *2한 값보다 크면 안된다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { int a, b, c, d; cin >> a >> b >> c >> d; if((a+1)*2<b || a>(b+1)*2 || a>c || b>d || (c-a+1)*2<d-b || c-a>(d-b+1)*2) cout << "NO\n"; else cout << "YES\n"; } } ```