#P10733. [NOISG 2019 Prelim] Lost Array

    ID: 12217 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2019Special Judge构造NOISG(新加坡)

[NOISG 2019 Prelim] Lost Array

Background

Translated from NOISG2019 Prelim B.Lost Array.

This problem uses Special Judge. Any answer that satisfies the conditions will be considered correct.

Problem Description

Given MM relations of the form min(XAi,XBi)=Ci\min (X_{A_i}, X_{B_i}) = C_i, construct an array XX of length NN such that every number in the array is between 11 and 10910^9, and the array satisfies all relations.

It is guaranteed that such an array exists.

Input Format

The first line contains two integers N,MN, M.

The next MM lines each contain three numbers Ai,Bi,CiA_i, B_i, C_i.

Output Format

Output one line with NN integers, representing the array XX you construct.

2 1
2 1 7
9 7
5 6
1 2 1
3 5 4
1 5 3
1 3 3
2 3 1
2 4 1
3 1 4 1 5
2 5
1 2 1
2 1 1
1 2 1
1 2 1
2 1 1
1 114514
5 1
1 2 123
123 1000000000 3 4 26311337

Hint

Sample #1 Explanation

Clearly, min(X2,X1)=min(9,7)=7\min (X_2, X_1) = \min (9, 7) = 7, which satisfies the conditions.

Sample #3 Explanation

The original statement did not include this sample, but it exists in the testdata.

The first constraint is min(X1,X2)=1\min (X_1, X_2) = 1. In fact, all constraints are the same as this one.

Sample #4 Explanation

The only constraint is min(X1,X2)=123\min (X_1, X_2) = 123. The other numbers can be any values between 11 and 10910^9.

Constraints

Subtask\text{Subtask} Score Special Property
00 Samples
11 55 N=2,M=1N = 2, M = 1
22 66 M3M \leq 3
33 2020 N,M1000N, M \leq 1000
44 2121 Ci10,N5C_i \leq 10, N \leq 5
55 4848 None

For 100%100\% of the data:

  • 1N,M1051 \leq N, M \leq 10^5.
  • 1Ai,BiN1 \leq A_i, B_i \leq N.
  • AiBiA_i \neq B_i.
  • 1Ci1091 \leq C_i \leq 10^9.

Translated by ChatGPT 5