結果

問題 No.775 tatyamと素数大富豪(hard)
ユーザー 👑 kmjpkmjp
提出日時 2018-12-22 01:18:35
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 76,800 KB
実行使用メモリ 101,376 KB
最終ジャッジ日時 2024-04-22 02:47:21
合計ジャッジ時間 7,013 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 148 ms
91,008 KB
testcase_02 AC 150 ms
91,136 KB
testcase_03 AC 149 ms
91,136 KB
testcase_04 AC 150 ms
91,776 KB
testcase_05 AC 151 ms
91,520 KB
testcase_06 AC 159 ms
91,520 KB
testcase_07 AC 165 ms
92,416 KB
testcase_08 AC 165 ms
92,032 KB
testcase_09 AC 190 ms
94,848 KB
testcase_10 AC 182 ms
94,848 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 174 ms
94,336 KB
testcase_14 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

import random

C=set()


def dfs(id,s,cur):
	global K
	global prev
	global C
	if id==N:
		if cur!=prev:
			C.add(cur)
			if len(C)>2*K:
				C=list(C)
				C.sort()
				C.reverse()
				for c in C[:K]:
					print(c)
				sys.exit(0)
			
			prev = cur
		return
		
	for i in range(N):
		if i not in s:
			if i>0 and A[i]==A[i-1] and (i-1) not in s:
				continue
			s.add(i)
			dfs(id+1,s,cur+A[i])
			s.remove(i)

N,K=map(int,raw_input().strip().split(" "))
A=raw_input().strip().split(" ")
prev=""

for x in range(N):
	for i in range(N-1):
		if A[i]+A[i+1] < A[i+1]+A[i] or (A[i]+A[i+1] == A[i+1]+A[i] and A[i]<A[i+1]):
			A[i],A[i+1]=A[i+1],A[i]

dfs(0,set(),"")




0