結果

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

ソースコード

diff #

import heapq 
from heapq import heappop,heappush,heapify
from sys import stdin, setrecursionlimit
input = stdin.readline
readline = stdin.readline
T=int(input())
from collections import deque
d=deque()

for _ in range(T):
  K,M,N=map(int, input().split())
  V=[0]*K;ans=[]
  for i in range(N):
    nex=(i+M-1)%K
    if V[i]==0 and V[nex]==0 and i!=nex:
      ans.append((i+1))
      p,q=i,nex
      V[p]=1;V[q]=1
      while True:
        p=(q+M-1)%K
        q=(p+M-1)%K 
        if V[p]==0 and V[q]==0:
          V[p]=1;V[q]=1
          ans.append((p+1))
        else:
          break 
  if len(ans)>=N:
    print('Yes')
    print(*ans[:N])
  else:
    print('No')
        
  #C=list(map(int, input().split()))
  
0