ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1323. Classmates

algo
Posted by hoan 8 Dec 2010 19:04
i use O((n-1)!* n^2) and got AC in 0.109 s.
just use o(n^2) memory.
for all permutation check its valid or not, for example for this test:
4
3
1 2
2 3
3 4

the permutation 1 2 3 4 is valid but 1 3 4 2 is nonvalid.

GOOD LUCK!!!