結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー Ayuna
提出日時 2024-08-23 23:38:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 526 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 118,916 KB
最終ジャッジ日時 2024-08-23 23:38:34
合計ジャッジ時間 4,494 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    k, m, n = map(int, input().split())
    if k < n * 2 or m == 1:
        print("No")
        continue
    graph = [0 for _ in range(k + 1)]
    for a in range(1, k + 1):
        b = (a + m - 2) % k + 1
        graph[a] = b
    ans = []
    st = set()
    for start in range(1, k + 1):
        if start in st:
            continue
        now = start
        while (not now in st) and (not graph[now] in st):
            st.add(now)
            st.add(graph[now])
            ans.append(now)
            now = graph[graph[now]]
            if len(ans) == n:
                break
        if len(ans) == n:
            break
        
    if len(ans) == n:
        print("Yes")
        print(*ans)
    else:
        print("No")
0