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

Polygon

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

의견: 0

설명

Setubal 1998
Polygon
Polygon is a game for one player that starts on a
polygon with N vertices, like the one in Figure
1, where N=4. Each vertex is labelled with an
integer and each edge is labelled with either the
symbol + (addition) or the symbol * (product).
The edges are numbered from 1 to N.
-7
4
2
5
+
*
1
2
3
4
+
*
Figure 1. Graphical representation of a polygon
On the first move, one of the edges is removed.
Subsequent moves involve the following steps:
• pick an edge E and the two vertices V1 and V2
that are linked by E; and
• replace them by a new vertex, labelled with
the result of performing the operation
indicated in E on the labels of V1 and V2.
The game ends when there are no more edges,
and its score is the label of the single vertex
remaining.
Sample game:
Consider the polygon of Figure 1. The player
started by removing edge 3. The effects are
depicted in Figure 2.
-7
4
2
5
+
*
1
2
4
+
Figure 2. Removing edge 3
After that, the player picked edge 1,
4
2
+
*
2
4
-2
Figure 3. Picking edge 1
then edge 4,
4
+
2
-4
Figure 4. Picking edge 4
and, finally, edge 2. The score is 0.
0
Figure 5. Picking edge 2
Task
Write a program that, given a polygon,
computes the highest possible score and lists all
the edges that, if removed on the first move, can
lead to a game with that score.
Input Data
File POLYGON.IN describes a polygon with N
vertices. It contains two lines. On the first line is
the number N. The second line contains the
labels of edges 1, ..., N, interleaved with the
vertices' labels (first that of the vertex between
edges 1 and 2, then that of the vertex between
edges 2 and 3, and so on, until that of the vertex
between edges N and 1), all separated by one
space. An edge label is either the letter t
(representing +) or the letter x (representing *).

Sample Input

4
t -7 t 4 x 2 x 5
This is the input file for the polygon of Figure 1.
The second line starts with the label of edge 1.
Output Data
On the first line of file POLYGON.OUT your
program must write the highest score one can
get for the input polygon. On the second line it
must write the list of all edges that, if removed
on the first move, can lead to a game with that
score. Edges must be written in increasing order,
separated by one space.
Sample Output:
33
1 2
This must be the output file for the polygon of
Figure 1.

제약

3 ≤ N ≤ 50
For any sequence of moves, vertex labels are in
the range [-32768,32767].

입력 형식
출력 형식
문제 정보

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

출처 IOI 1998

평가 및 의견

Polygon

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

Log in to rate problems.

개별 의견

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

풀이 제출

Polygon

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