fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
Codeforces Round 1045-A (Div. 2) (C++) Painting With Two Colors
최초 업로드: 2025-08-26 17:13:00
최근 수정 시간: 2025-08-30 14:06:27
게시자: rlatjwls3333
카테고리: Codeforces
조회수: 41
# A. Painting With Two Colors [문제 링크](https://codeforces.com/contest/2134/problem/A) ## Problem Statement You are given three positive integers $n$, $a$, and $b$ ($1 \le a,b \le n$). Consider a row of $n$ cells, initially all white and indexed from $1$ to $n$. Perform the following two steps **in order**: 1) Choose an integer $x$ with $1 \le x \le n-a+1$, and paint the $a$ consecutive cells $x, x+1, \ldots, x+a-1$ red. 2) Choose an integer $y$ with $1 \le y \le n-b+1$, and paint the $b$ consecutive cells $y, y+1, \ldots, y+b-1$ blue. If a cell is painted both red and blue, its final color is blue. A coloring of the grid is **symmetric** if, for every integer $i$ from $1$ to $n$ (inclusive), the color of cell $i$ is the same as the color of cell $(n+1-i)$. Determine whether there exist integers $x$ and $y$ such that the final coloring of the grid is symmetric. ## Input Each test contains multiple test cases. The first line contains an integer $t$ ($1 \le t \le 500$) — the number of test cases. Each test case consists of one line with three integers $n$, $a$, $b$ ($1 \le n \le 10^9$, $1 \le a,b \le n$). ## Output For each test case, print `"YES"` if it is possible that the final coloring of the grid is symmetric; otherwise, print `"NO"`. You may print each letter in any case (upper or lower). ## 풀이 #### 홀수일 때, 홀수 칸 색칠, 짝수일 때, 짝수칸 색칠하면 된다. 파란색 칸이 큰 경우 빨간색 칸은 신경 안쓸 수 있다. ``` 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 n, a, b; cin >> n >> a >> b; if(n%2==1) { if((a%2==1 || a<b) && b%2==1) cout << "YES\n"; else cout << "NO\n"; } else { if((a%2==0 || a<b) && b%2==0) cout << "YES\n"; else cout << "NO\n"; } } } ```