[PYTHON] AtCoder Sumitomo Mitsui Trust Bank Programming Contest 2019 Participation Report

AtCoder Sumitomo Mitsui Trust Bank Programming Contest 2019 Participation Report

A - November 30

Break through in 2 minutes. Just write.

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

B - Tax Rate

It broke through in four and a half minutes. I didn't know what to do if it didn't become an integer, and I issued it properly, but it was AC.

N = int(input())

X = N / 1.08
if int(X) * 108 // 100 == N:
    print(int(X))
elif int(X + 1) * 108 // 100 == N:
    print(int(X + 1))
else:
    print(':(')

C - 100 to 105

Break through in 7 and a half minutes. WA1. I thought it was more difficult than the recent ABC C problem. It wasn't because it was difficult, it was just Chombo.

X = int(input())

dp = [0] * (X + 1 + 105)
dp[0] = 1

for i in range(X):
    if dp[i] == 1:
        for j in range(100, 106):
            dp[i + j] = 1
print(dp[X])

D - Lucky PIN

It breaks through in 22 minutes and a half. Since there are 3 characters, there are only 1000 patterns at the maximum from 000 to 999, so I can afford to try all patterns, but if N ≤ 30000, it seems to be TLE, so if 4 or more of the same characters are consecutive, it will be 3 I compressed and searched. Since only 3 characters are used anyway, a sequence of 4 or more characters is meaningless.

N = int(input())
S = input()

t = [S[0]]
p = S[0]
r = 1
for i in range(1, N):
    if S[i] == p:
        r += 1
        if r < 4:
            t.append(S[i])
    else:
        r = 1
        t.append(S[i])
T = ''.join(t)

result = 0
for i in range(10):
    a = T.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = T.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(10):
            if T.find(str(k), b + 1) != -1:
                result += 1
print(result)

Addendum: I didn't need to compress it (^^; I thought there was an extreme test case where there was a continuation after a series of about 30,000 characters. Otherwise, it's not a D problem difficulty.

N = int(input())
S = input()

result = 0
for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(10):
            if S.find(str(k), b + 1) != -1:
                result += 1
print(result)

E - Colorful Hats 2

Break through in 28 minutes. WA1. I didn't want to trust that A1 was 0. Just keep applying the possible patterns from the beginning. E Easy for problems.

N = int(input())
A = list(map(int, input().split()))

result = 1
t = [0, 0, 0]
for i in range(N):
    a = A[i]
    f = -1
    k = 0
    for j in range(3):
        if t[j] == a:
            k += 1
            if f == -1:
                t[j] += 1
                f = j
    result = (result * k) % 1000000007
print(result)

F - Interval Running

I couldn't break through. But it's very easy as an F problem. I was disappointed that I missed it even though I seemed to be able to complete it for the first time.

from sys import exit

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

if A1 > B1:
    A1, B1 = B1, A1
    A2, B2 = B2, A2

if A2 < B2:
    print(0)
    exit()

if A1 * T1 + A2 * T2 < B1 * T1 + B2 * T2:
    print(0)
    exit()

if A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2:
    print('infinity')
    exit()

a = B1 * T1 - A1 * T1
b = (A1 * T1 + A2 * T2) - (B1 * T1 + B2 * T2)
t = a // b

if a % b == 0:
    print(t * 2)
else:
    print(t * 2 + 1)

Recommended Posts

AtCoder Sumitomo Mitsui Trust Bank Programming Contest 2019 Participation Report
Sumitomo Mitsui Trust Bank Programming Contest 2019 Review
AtCoder HHKB Programming Contest 2020 Participation Report
AtCoder Acing Programming Contest 2020 Participation Report
AtCoder Keyence Programming Contest 2020 Participation Report
AtCoder Panasonic Programming Contest 2020 Participation Report
[Python] Sumitomo Mitsui Trust Bank Programming Contest 2019 C (How to use DP) [AtCoder]
AtCoder Beginner Contest 181 Participation Report
AtCoder Beginner Contest 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 176 Participation Report
AtCoder Grand Contest 041 Participation Report
AtCoder Grand Contest 040 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest 165 Participation Report
AtCoder Beginner Contest 160 Participation Report
AtCoder Beginner Contest 169 Participation Report
AtCoder Beginner Contest 178 Participation Report
AtCoder Beginner Contest 163 Participation Report
AtCoder Beginner Contest 159 Participation Report
AtCoder Beginner Contest 164 Participation Report
AtCoder Beginner Contest 168 Participation Report
AtCoder Beginner Contest 150 Participation Report
AtCoder Beginner Contest 158 Participation Report
AtCoder Beginner Contest 180 Participation Report
AtCoder Beginner Contest 156 Participation Report
AtCoder Beginner Contest 167 Participation Report
AtCoder Beginner Contest 179 Participation Report
AtCoder Beginner Contest 182 Participation Report
AtCoder Beginner Contest 146 Participation Report
AtCoder Beginner Contest 152 Participation Report
AtCoder Beginner Contest 155 Participation Report
AtCoder Beginner Contest 174 Participation Report
AtCoder Beginner Contest 171 Participation Report
AtCoder Beginner Contest 149 Participation Report
AtCoder Beginner Contest 148 Participation Report
AtCoder Beginner Contest 188 Participation Report
AtCoder Beginner Contest 170 Participation Report
AtCoder Beginner Contest 187 Participation Report
AtCoder Chokudai Contest 005 Participation Report
AtCoder Grand Contest 047 Participation Report
AtCoder Beginner Contest 183 Participation Report
AtCoder Hitachi, Ltd. Social Systems Division Programming Contest 2020 Participation Report
AtCoder Library Practice Contest Participation Report (Python)
AtCoder Judge System Update Test Contest 202004 Participation Report
ACL Beginner Contest Participation Report
Atcoder Beginner Contest 146 Participation Diary
AtCoder 3rd Algorithm Practical Test Participation Report
AtCoder 2nd Algorithm Practical Test Virtual Participation Report