Ich habe am Einführung in den Heuristik-Wettbewerb teilgenommen. Dies ist der zweite Marathon-Wettbewerb seit Chokudai-Wettbewerb 004. Das Ergebnis war 83275739 Punkte, 497. von 1731. Der endgültige Code wurde von PyPy unten eingereicht.
from time import time
from random import random
limit_secs = 2
start_time = time()
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
def calc_score():
score = 0
S = 0
last = [-1] * 26
for d in range(D):
S += s[d][t[d]]
last[t[d]] = d
for i in range(26):
S -= c[i] * (d - last[i])
score += max(10 ** 6 + S, 0)
return score
def solution():
return [i % 26 for i in range(D)]
t = solution()
score = calc_score()
while time() - start_time + 0.14 < limit_secs:
d = int(random() * D)
q = int(random() * 26)
old = t[d]
t[d] = q
new_score = calc_score()
if new_score < score:
t[d] = old
else:
score = new_score
print('\n'.join(str(e + 1) for e in t))
Unten finden Sie eine grobe Zeitleiste.
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
for i in range(D):
print(i % 26 + 1)
D = int(input())
c = [None] + list(map(int, input().split()))
s = [None] + [[None] + list(map(int, input().split())) for _ in range(D)]
t = [None] + [int(input()) for _ in range(D)]
S = 0
last = [0] * 27
score = 0
for d in range(1, D + 1):
S += s[d][t[d]]
last[t[d]] = d
for i in range(1, 27):
S -= c[i] * (d - last[i])
score += max(10 ** 6 + S, 0)
print(S)
def calc_satisfaction():
S = 0
last = [0] * 27
for d in range(1, D + 1):
S += s[d][t[d]]
last[t[d]] = d
for i in range(1, 27):
S -= c[i] * (d - last[i])
return S
D = int(input())
c = [None] + list(map(int, input().split()))
s = [None] + [[None] + list(map(int, input().split())) for _ in range(D)]
t = [None] + [int(input()) for _ in range(D)]
M = int(input())
for _ in range(M):
d, q = map(int, input().split())
old = t[d]
t[d] = q
print(calc_satisfaction())
Last = [0] * 26
war falsch.D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) - 1 for _ in range(D)]
S = 0
last = [-1] * 26
score = 0
for d in range(D):
S += s[d][t[d]]
last[t[d]] = d
for i in range(26):
S -= c[i] * (d - last[i])
score += max(10 ** 6 + S, 0)
print(S)
from time import time
from random import random
start_time = time()
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
def calc_score():
S = 0
last = [-1] * 26
score = 0
for d in range(D):
S += s[d][t[d]]
last[t[d]] = d
for i in range(26):
S -= c[i] * (d - last[i])
score += max(10 ** 6 + S, 0)
return score
def solution():
return [i % 26 for i in range(D)]
t = solution()
score = calc_score()
while time() - start_time < 1.5:
d = int(random() * D)
q = int(random() * 26)
old = t[d]
t[d] = q
new_score = calc_score()
if new_score < score:
t[d] = old
for e in t:
print(e + 1)
while time () --start_time <limit_secs * 0.9:
, um es bis zur letzten Minute zu verbessern. if new_S < S:
t[d] = old
S = new_S
for e in t:
if 0 <= e <= 25:
print(e + 1)
else:
print(0)
while time () --start_time + 0.15 <limit_secs:
, geändert, um bis zur letzten Minute zu denken. 81865683 Punkte (nach unten).while time () --start_time + 0.14 <limit_secs:
, 83275738 Punkte. Dies war der höchste und letzte Code, und ich habe denselben Code noch zweimal gepostet, aber nur mit einer niedrigen Punktzahl.Recommended Posts