Skip to main content

Practice · 3 of 5

Deranged and Non-Adjacent

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Print ANY permutation of 1..n with no fixed point (p[i] ≠ i) and no two adjacent entries differing by exactly 1, or -1 if impossible. **Constraints:** 2 ≤ n ≤ 1000; n is even. Construction: evens ascending, then odds ascending.

Back to lesson: Practice: Attack Pattern Drills