{"problem":{"name":"Find Permutation","description":{"content":"There is a length-$N$ sequence $A=(A_1,\\ldots,A_N)$ that is a permutation of $1,\\ldots,N$. While you do not know $A$, you know that $A_{X_i}<A_{Y_i}$ for $M$ pairs of integers $(X_i,Y_i)$. Can $A$ be ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc291_e"},"statements":[{"statement_type":"Markdown","content":"There is a length-$N$ sequence $A=(A_1,\\ldots,A_N)$ that is a permutation of $1,\\ldots,N$.\nWhile you do not know $A$, you know that $A_{X_i}<A_{Y_i}$ for $M$ pairs of integers $(X_i,Y_i)$.\nCan $A$ be uniquely determined? If it is possible, find $A$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2\\times 10^5$\n*   $1 \\leq M \\leq 2\\times 10^5$\n*   $1\\leq X_i,Y_i \\leq N$\n*   All values in the input are integers.\n*   There is an $A$ consistent with the input.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$X_1$ $Y_1$\n$\\vdots$\n$X_M$ $Y_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc291_e","tags":[],"sample_group":[["3 2\n3 1\n2 3","Yes\n3 1 2\n\nWe can uniquely determine that $A=(3,1,2)$."],["3 2\n3 1\n3 2","No\n\nTwo sequences $(2,3,1)$ and $(3,2,1)$ can be $A$."],["4 6\n1 2\n1 2\n2 3\n2 3\n3 4\n3 4","Yes\n1 2 3 4"]],"created_at":"2026-03-03 11:01:14"}}