cf/mirror

Design Tutorial: Make It Nondeterministic

CF
472C1400· specialist2s256 MB⌨ stdin/stdout
#greedy

Examples

Sample 1of 5
Input
3
gennady korotkevich
petr mitrichev
gaoyuan chen
1 2 3
Output
NO
Sample 2of 5
Input
3
gennady korotkevich
petr mitrichev
gaoyuan chen
3 1 2
Output
YES
Sample 3of 5
Input
2
galileo galilei
nicolaus copernicus
2 1
Output
YES
Sample 4of 5
Input
10
rean schwarzer
fei claussell
alisa reinford
eliot craig
laura arseid
jusis albarea
machias regnitz
sara valestin
emma millstein
gaius worzel
1 2 3 4 5 6 7 8 9 10
Output
NO
Sample 5of 5
Input
10
rean schwarzer
fei claussell
alisa reinford
eliot craig
laura arseid
jusis albarea
machias regnitz
sara valestin
emma millstein
gaius worzel
2 4 9 6 5 7 1 3 8 10
Output
YES
472C.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)