結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー ShirotsumeShirotsume
提出日時 2024-08-23 22:02:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 2,888 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 130,304 KB
最終ジャッジ日時 2024-08-23 22:02:32
合計ジャッジ時間 5,025 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
57,596 KB
testcase_01 AC 145 ms
78,712 KB
testcase_02 AC 142 ms
126,004 KB
testcase_03 AC 102 ms
109,188 KB
testcase_04 AC 172 ms
103,612 KB
testcase_05 AC 124 ms
95,728 KB
testcase_06 AC 112 ms
93,572 KB
testcase_07 AC 103 ms
87,768 KB
testcase_08 AC 74 ms
80,916 KB
testcase_09 AC 133 ms
100,124 KB
testcase_10 AC 137 ms
105,436 KB
testcase_11 AC 107 ms
91,248 KB
testcase_12 AC 189 ms
120,828 KB
testcase_13 AC 77 ms
79,768 KB
testcase_14 AC 71 ms
80,900 KB
testcase_15 AC 163 ms
115,296 KB
testcase_16 AC 75 ms
79,928 KB
testcase_17 AC 144 ms
104,028 KB
testcase_18 AC 95 ms
86,148 KB
testcase_19 AC 149 ms
120,336 KB
testcase_20 AC 98 ms
84,052 KB
testcase_21 AC 182 ms
130,304 KB
testcase_22 AC 240 ms
81,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys, time, random
from collections import deque, Counter, defaultdict
def debug(*x):print('debug:',*x, file=sys.stderr)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
class dsu():
    n=1
    parent_or_size=[-1 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.num = N
        self.parent_or_size=[-1 for i in range(N)]
    def merge(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        x=self.leader(a)
        y=self.leader(b)
        if x==y:
            return x
        self.num -= 1
        if (-self.parent_or_size[x]<-self.parent_or_size[y]):
            x,y=y,x
        self.parent_or_size[x]+=self.parent_or_size[y]
        self.parent_or_size[y]=x
        return x
    def same(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        return self.leader(a)==self.leader(b)
    def leader(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        if (self.parent_or_size[a]<0):
            return a
        self.parent_or_size[a]=self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]
    def size(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        return -self.parent_or_size[self.leader(a)]
    def groups(self):
        leader_buf=[0 for i in range(self.n)]
        group_size=[0 for i in range(self.n)]
        for i in range(self.n):
            leader_buf[i]=self.leader(i)
            group_size[leader_buf[i]]+=1
        result=[[] for i in range(self.n)]
        for i in range(self.n):
            result[leader_buf[i]].append(i)
        result2=[]
        for i in range(self.n):
            if len(result[i])>0:
                result2.append(result[i])
        return result2
    def count(self):
        return self.num


def solve():
    k, m, n = mi()
    m -= 1
    if m == 0:
        print('No')
        return
    
    graph = [[] for _ in range(k)]
    
    for i in range(k):
        graph[i].append((i + m) % k)
        
    visit = [False] * k
    
    ans = []
    
    for i in range(k):
        if visit[i]:
            continue
        seq = []
        while not visit[i]:
            visit[i] = True
            seq.append(i)
            i = graph[i][0]
        if len(seq) % 2 == 0:
            for i in range(0, len(seq), 2):
                ans.append(seq[i])
        else:
            for i in range(0, len(seq) - 1, 2):
                ans.append(seq[i])
    if len(ans) >= n:
        print('Yes')
        print(*[i + 1 for i in ans[:n]])
    else:
        print('No')
for _ in range(ii()):
    solve()
0