PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000029. Trang trại của K nhỏ (Little K’s Farm)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trang trại của K nhỏ (Little K’s Farm)
Little K’s Farm
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
There are farms and three possible kinds of constraints: 1 a b c means value at is at least greater than at ; 2 a b c means value at exceeds value at by at most ; 3 a b requires equality. Determine consistency.
Input
First line , followed by constraints in one of the three formats.
Output
Print Yes if feasible, otherwise No.
Subtasks
- Subtask 1 (20 points): $2\le n\le 12; 1\le m\le 30; 1\le a,b\le n; a\ne b; 1\le c\le5000$.
- Subtask 2 (30 points): $2\le n\le 200; 1\le m\le1000; 1\le a,b\le n; a\ne b; 1\le c\le5000$.
- Subtask 3 (50 points): $2\le n\le5000; 1\le m\le5000; 1\le a,b\le n; a\ne b; 1\le c\le5000$.
Examples
Input
3 3
1 1 2 2
2 1 3 4
3 2 3
Output
Yes
Explanation
Set and . Then , , and , so Yes is correct.