Submission #728077

# Submission time Handle Problem Language Result Execution time Memory
728077 2023-04-21T23:45:03 Z jnjwnwnw Carnival (CEOI14_carnival) Python 3
20 / 100
265 ms 3712 KB
import random


test_check_repeats_save = {}
def test_check_repeats(a, b):
    if a > b:
        a, b = b, a
    if a in test_check_repeats_save and b in test_check_repeats_save[a]:
        return test_check_repeats_save[a][b]
    result = test([a, b]) == 1
    if a in test_check_repeats_save:
        test_check_repeats_save[a][b] = result
    else:
        test_check_repeats_save[a] = {b:result}
    return result

def getAnItem(s):
	for thing in s:
		return thing
 
def test(lst):
	return int(input(str(len(lst)) + " " + " ".join([str(i+1) for i in lst]) + "\n"))

def div_and_conquer(l,u):
    if l == u - 1:
        return [{l}]
    mid = (l + u) // 2
    rl = div_and_conquer(l, mid)
    rr = div_and_conquer(mid, u)
    used = set()
    for val_in in rr:
        flag = True
        for key_out, val_out in enumerate(rl):
            if key_out not in used and test_check_repeats(getAnItem(val_in), getAnItem(val_out)):
                val_out.update(val_out.union(val_in))
                used.add(key_out)
                flag = False
                break

        if flag:
            rl.append(val_in)
    return rl

def iterative(n):
    dat = []
    for i in range(n):
        flag = True
        for val in dat:
            if test_check_repeats(i, getAnItem(val)):
                val.add(i)
                flag = False
                break
        if flag:
            dat.append({i})

    return dat


def main():
	n = int(input())
	c = int(input(str(n) + " " + " ".join([str(i+1) for i in range(n)]) + "\n"))
	div_and_conquer(0, n)
	res = iterative(n)
	toPrint = ["0"]*(n+1)

	for i, s in enumerate(res):
		for j in s:
			toPrint[j+1] = str(i+1)
	print(" ".join(toPrint))

main()

# Verdict Execution time Memory Grader output
1 Correct 56 ms 3212 KB Output is correct
2 Correct 100 ms 3344 KB Output is correct
3 Partially correct 165 ms 3424 KB Partially correct
4 Partially correct 193 ms 3536 KB Partially correct
5 Correct 27 ms 3152 KB Output is correct
6 Correct 21 ms 3152 KB Output is correct
7 Correct 69 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3212 KB Output is correct
2 Correct 100 ms 3272 KB Output is correct
3 Partially correct 123 ms 3256 KB Partially correct
4 Partially correct 188 ms 3424 KB Partially correct
5 Correct 25 ms 3172 KB Output is correct
6 Correct 33 ms 3176 KB Output is correct
7 Correct 47 ms 3176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3192 KB Output is correct
2 Correct 41 ms 3204 KB Output is correct
3 Partially correct 121 ms 3324 KB Partially correct
4 Partially correct 265 ms 3576 KB Partially correct
5 Correct 32 ms 3152 KB Output is correct
6 Correct 42 ms 3220 KB Output is correct
7 Partially correct 92 ms 3428 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3232 KB Output is correct
2 Correct 33 ms 3152 KB Output is correct
3 Partially correct 229 ms 3556 KB Partially correct
4 Partially correct 257 ms 3572 KB Partially correct
5 Correct 45 ms 3204 KB Output is correct
6 Correct 77 ms 3272 KB Output is correct
7 Correct 91 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3152 KB Output is correct
2 Correct 67 ms 3184 KB Output is correct
3 Partially correct 119 ms 3452 KB Partially correct
4 Partially correct 172 ms 3656 KB Partially correct
5 Partially correct 83 ms 3316 KB Partially correct
6 Partially correct 141 ms 3376 KB Partially correct
7 Partially correct 164 ms 3712 KB Partially correct