Similarity Graph
Time limit1sMemory limit1024 MB
Given a graph on N vertices, find two permutations p and q whose similarity graph equals it, or report NO if none exists.
- Level
Hard8 of 10
- Topics
- Graph, Topological sort, Implementation
- Solved
- No attempts yet
Problem
Let and be two permutations of .
The similarity graph of and , , is defined as follows:
- has labeled vertices, numbered from to .
- There is an edge between vertex and vertex if and only if both and are true, or both are false. ()
You are given a simple undirected graph with labeled vertices, numbered from to . Find a pair of permutations of that satisfies .
Input
The first line contains one integer .
The next lines each contain space-separated integers. The -th integer on the -th line is . is if there is an edge between vertex and vertex , and otherwise.
Output
If no pair satisfies the condition, output NO.
Otherwise, output YES on the first line. On the next two lines, output and . If there are multiple answers, any of them is accepted.
Constraints
- ()
- ()
- ()