Crossing

AtCoder
IDtenka1_2018_d
Time2000ms
Memory256MB
Difficulty
You are given an integer $N$. Determine if there exists a tuple of subsets of ${1,2,...N}$, $(S_1,S_2,...,S_k)$, that satisfies the following conditions: * Each of the integers $1,2,...,N$ is contained in exactly two of the sets $S_1,S_2,...,S_k$. * Any two of the sets $S_1,S_2,...,S_k$ have exactly one element in common. If such a tuple exists, construct one such tuple. ## Constraints * $1 \leq N \leq 10^5$ * $N$ is an integer. ## Input Input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
3
Output #1
Yes
3
2 1 2
2 3 1
2 2 3

It can be seen that $(S_1,S_2,S_3)=({1,2},{3,1},{2,3})$ satisfies the conditions.
Input #2
4
Output #2
No
API Response (JSON)
{
  "problem": {
    "name": "Crossing",
    "description": {
      "content": "You are given an integer $N$. Determine if there exists a tuple of subsets of ${1,2,...N}$, $(S_1,S_2,...,S_k)$, that satisfies the following conditions: *   Each of the integers $1,2,...,N$ is conta",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "tenka1_2018_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer $N$. Determine if there exists a tuple of subsets of ${1,2,...N}$, $(S_1,S_2,...,S_k)$, that satisfies the following conditions:\n\n*   Each of the integers $1,2,...,N$ is conta...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments