RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03532

J3. Exactly Electrical

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Time limit: 1 second

You live in Grid City, which is composed of integer-numbered streets
which run east-west (parallel to the \(x\)-axis) and integer-numbered avenues
which run north-south (parallel to the \(y\)-axis). The streets and avenues have
infinite length, and there is a street for every integer \(y\)-coordinate and an avenue for every
\(x\)-coordinate. All intersections are
labelled by their integer coordinates: for example, avenue 7 and street
-3 intersect at (7,-3).

You drive a special electric car which uses up one unit of electrical
charge moving between adjacent intersections: that is, moving either
north or south to the next street, or moving east or west to the next
avenue). Until your battery runs out, at each intersection, your car can
turn left, turn right, go straight through, or make a U-turn. You may
visit the same intersection multiple times on the same trip.

Suppose you know your starting intersection, your destination
intersection and the number of units of electrical charge in your
battery. Determine whether you can travel from the starting intersection
to the destination intersection using the charge available to you in
such a way that your battery is empty when you reach your
destination.

제약

\((-1000 \leq a \leq 1000; -1000 \leq b \leq 1000)\)
\((-1000 \leq c \leq 1000; -1000 \leq d \leq 1000)\)
\((0 \leq t \leq 10\ 000)\)
\(0 \leq a, b, c, d \leq 2\)
\(t \leq 8\)

입력 형식

The input consists of three lines. The first line contains \(a\) followed by \(b\), indicating the starting coordinate
\((a,b)\) \((-1000 \leq a \leq 1000; -1000 \leq b \leq 1000)\).

The second line contains \(c\)
followed by \(d\), indicating the
destination coordinate \((c,d)\) \((-1000 \leq c \leq 1000; -1000 \leq d \leq 1000)\).

The third line contains an integer \(t\) \((0 \leq t \leq 10\ 000)\) indicating the initial number of units of
electrical charge of your battery.

For 3 of the 15 available marks, \(0 \leq a, b, c, d \leq 2\).

For an additional 3 of the 15 marks available, \(t \leq 8\).

출력 형식

Output Y if it is possible to move from the
starting coordinate to the destination coordinate using exactly \(t\) units of electrical charge. Otherwise
output N.

예제 1
입력
3 4
3 3
3
출력
Y
설명

One possibility is to travel from \((3,4)\) to \((4,4)\) to \((4, 3)\) to \((3,3)\).

예제 2
입력
10 2
10 4
5
출력
N
설명

It is possible to get from \((10,2)\) to \((10,4)\) using exactly 2 units of
electricity, by going north 2 units.

It is also possible to travel using 4 units of electricity as in the
following sequence:
$$ (10,2) \rightarrow (10,3) \rightarrow (11,3) \rightarrow (11,4) \rightarrow (10,4). $$
It is also possible to travel using 5 units of
electricity from \((10,2)\) to \((11,4)\) by the following sequence:
$$ (10,2) \rightarrow (10,3) \rightarrow (11,3) \rightarrow (12,3) \rightarrow (12,4) \rightarrow (11,4). $$
It is
not possible to move via any path of length 5 from \((10,2)\) to \((10,4)\), however.

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2017 Junior

평가 및 의견

J3. Exactly Electrical

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

J3. Exactly Electrical

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8