#!/usr/bin/env python3
from typing import *
def solve(n: int, k: int, a: List[str]) -> List[str]:
cnt = {}
for a_i in a:
if a_i not in cnt:
cnt[a_i] = 0
cnt[a_i] += 1
que = []
for i in range(3 * n):
que.append((cnt[a[i]], - i, a[i]))
used = set()
ans = []
while len(ans) < k and que:
_, _, s = que.pop()
if s not in used:
used.add(s)
ans.append(s)
return ans
# generated by oj-template v4.8.0 (https://github.com/online-judge-tools/template-generator)
def main():
n, k = map(int, input().split()) # TODO: edit here
a = []
for _ in range(3 * n):
a.append(input().strip())
ans = solve(n, k, a)
for x in ans:
print(x) # TODO: edit here
if __name__ == '__main__':
main()
~/Algo/codeforces/103081/A> oj t -c 'python3 main.py' -D
[INFO] online-judge-tools 11.4.0 (+ online-judge-api-client 10.10.0)
[INFO] 2 cases found
[INFO] sample-1
[INFO] time: 0.018912 sec
[FAILURE] WA
input:
2_2
Supportive_parents
Being_able_to_solve_a_hard_problem
Good_food
Fun_game_with_friends
Good_food
Being_healthy
[ERROR]
Traceback (most recent call last):
File "/home/ubuntu/GitHub/oj/onlinejudge_command/main.py", line 101, in main
sys.exit(run_program(parsed, parser=parser))
File "/home/ubuntu/GitHub/oj/onlinejudge_command/main.py", line 70, in run_program
if not subcommand_test.run(args):
File "/home/ubuntu/GitHub/oj/onlinejudge_command/subcommand/test.py", line 338, in run
history += [test_single_case(name, paths['in'], paths.get('out'), args=args)]
File "/home/ubuntu/GitHub/oj/onlinejudge_command/subcommand/test.py", line 276, in test_single_case
status = display_result(proc, answer, memory, test_input_path, test_output_path, mle=args.mle, display_mode=DisplayMode(args.display_mode), compare_mode=CompareMode(args.compare_mode), does_print_input=args.print_input, silent=args.silent, match_result=match_result)
File "/home/ubuntu/GitHub/oj/onlinejudge_command/subcommand/test.py", line 229, in display_result
logger.info(utils.NO_HEADER + pretty_printers.make_pretty_diff(answer.encode(), expected=expected, compare_mode=compare_mode, limit=40))
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 663, in make_pretty_diff
tokens += _tokenize_pretty_diff(output, expected=expected, compare_mode=compare_mode, char_in_line=char_in_line, limit=limit)
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 651, in _tokenize_pretty_diff
ops = _make_diff_between_file_and_file(output, expected, compare_mode=compare_mode)
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 451, in _make_diff_between_file_and_file
return _make_diff_between_file_and_file_by_comparing_line_by_line(a, b, compare_mode=compare_mode)
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 363, in _make_diff_between_file_and_file_by_comparing_line_by_line
tokens_a, tokens_b = _make_diff_between_line_and_line(lines_a[i], lines_b[i])
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 339, in _make_diff_between_line_and_line
return _make_diff_between_line_and_line_by_comparing_word_by_word(a, b)
File "/home/ubuntu/GitHub/oj/onlinejudge_command/pretty_printers.py", line 290, in _make_diff_between_line_and_line_by_comparing_word_by_word
assert l_a == len(a) and l_b == len(b) # The two strings have the same number of words, so this must be true.
AssertionError
Summary / 概要
Steps to reproduce / 再現方法
https://codeforces.com/gym/103081/problem/A のサンプルで以下を使って
$ oj t -c 'python3 main.py' -D
environments:
Expected behavior / 期待される挙動
Actual behavior / 実際の挙動
Other notes / その他