結果
問題 |
No.2868 Another String of yuusaan
|
ユーザー |
|
提出日時 | 2025-08-08 13:49:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 197 ms / 2,000 ms |
コード長 | 2,099 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 82,644 KB |
実行使用メモリ | 93,048 KB |
最終ジャッジ日時 | 2025-08-08 13:50:04 |
合計ジャッジ時間 | 5,148 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import os,sys,random,threading from random import randint,choice,shuffle from copy import deepcopy from io import BytesIO,IOBase from types import GeneratorType from functools import lru_cache,reduce from bisect import bisect_left,bisect_right from collections import Counter,defaultdict,deque from itertools import accumulate,combinations,permutations from heapq import heapify,heappop,heappush from typing import Generic,Iterable,Iterator,TypeVar,Union,List from string import ascii_lowercase,ascii_uppercase,digits from math import ceil,floor,sqrt,pi,factorial,gcd,log,log10,log2,inf from decimal import Decimal,getcontext from sys import stdin, stdout, setrecursionlimit input = lambda: sys.stdin.readline().rstrip("\r\n") MI = lambda :map(int,input().split()) li = lambda :list(MI()) ii = lambda :int(input()) mod = int(1e9 + 7) #998244353 inf = 1<<60 py = lambda :print("YES") pn = lambda :print("NO") MI=lambda:map(int,input().split()) n,k=MI() INF=10**30 e=[1] for _ in range(100): v=4*e[-1]+3 if v>INF:v=INF e.append(v) def E(y): if y<0:return 0 if y>=len(e):return INF return e[y] def jump(s,k): hi=min(s-1,k-1) if s>=1 else 0 lo=0 while lo<hi: mid=(lo+hi+1)//2 if k-mid<=E(s-mid-1):lo=mid else:hi=mid-1 return lo def get(seed,s,k): while 1: if s==0:return seed if k==1:return 'y' k-=1 L=E(s-1) if k<=L: s-=1 t=jump(s,k) s-=t k-=t seed='u' continue k-=L if k<=L: s-=1 seed='u' continue k-=L if k==1:return 's' k-=1 if k<=L: s-=1 seed='a' continue k-=L if k<=L: s-=1 seed='a' continue return 'n' S1='yuusaan' if n==1: print(S1[k-1]) else: s=n-1 for c in S1: L=1 if c in 'ysn' else E(s) if k<=L: if c in 'ysn':print(c) else:print(get(c,s,k)) break k-=L