AtCoder Beginner Contest 058 Review of past questions

Past questions solved for the first time

Time required

スクリーンショット 2020-01-08 12.17.21.png

Impressions

It is regrettable that I can only solve the C problem in the last two times. I want to be able to solve the problems of light blue and blue difficulty.

Problem A

As it is

answerA.py


a,b,c=map(int,input().split())

if b-a==c-b:
    print("YES")
else:
    print("NO")

B problem

It's OK if you change the output by chance

answerB.py


o=input()
lo=len(o)
e=input()
le=len(e)
for i in range(lo+le):
    if i%2==0:
        print(o[i//2],end="")
    else:
        print(e[i//2],end="")
print()

C problem

Since it is necessary to make it in lexicographic order in the end, create an array of alphabets first, find out how many each there are, and output them together at the end. Also, since we count common things, we need to take min, so we need to be careful there as well. It's very convenient because you can intuitively operate Python and character strings.

answerC.py


alp=[chr(i) for i in range(97, 97+26)]
inf=10000000
check=[inf]*26

n=int(input())
for i in range(n):
    s=input()
    ls=len(s)
    check_sub=[0]*26
    for j in range(ls):
        #print(s[j])
        check_sub[alp.index(s[j])]+=1
    for k in range(26):
        check[k]=min(check[k],check_sub[k])
    #print(check_sub)
ans=""
for i in range(26):
    #print(check[i])
    ans+=check[i]*alp[i]
print(ans)

D problem

It was a problem that could be solved in a little while, but I missed it due to a misunderstanding. (I didn't realize that ** if there is no mistake in the code, there is a mistake in my consideration ** ...) Below, I would like to put what I wrote on paper as my own consideration. Also, commenting out in the code is a code based on your own mistakes.

IMG_5591.JPG

** I made a mistake in the basics of counting **, which counts all possible things without duplication. From now on, I want to tell my heart not to make a mistake in this basic.

answerD.py


mod=1000000007
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

xc=0
for i in range(1,n):
    a=x[i]-x[i-1]
    l=min(i,n-i)
    #xc+=a*(l*n-((l*l+l)//2))
    xc+=a*(l*(n-l))
    xc%=mod

yc=0
for i in range(1,m):
    a=y[i]-y[i-1]
    l=min(i,m-i)
    #yc+=a*(l*m-((l*l+l)//2))
    yc+=a*(l*(m-l))
    yc%=mod
print((xc*yc)%mod)

Recommended Posts

AtCoder Beginner Contest 102 Review of past questions
AtCoder Beginner Contest 072 Review of past questions
AtCoder Beginner Contest 085 Review of past questions
AtCoder Beginner Contest 062 Review of past questions
AtCoder Beginner Contest 113 Review of past questions
AtCoder Beginner Contest 074 Review of past questions
AtCoder Beginner Contest 051 Review of past questions
AtCoder Beginner Contest 127 Review of past questions
AtCoder Beginner Contest 119 Review of past questions
AtCoder Beginner Contest 151 Review of past questions
AtCoder Beginner Contest 075 Review of past questions
AtCoder Beginner Contest 054 Review of past questions
AtCoder Beginner Contest 110 Review of past questions
AtCoder Beginner Contest 117 Review of past questions
AtCoder Beginner Contest 070 Review of past questions
AtCoder Beginner Contest 112 Review of past questions
AtCoder Beginner Contest 076 Review of past questions
AtCoder Beginner Contest 089 Review of past questions
AtCoder Beginner Contest 069 Review of past questions
AtCoder Beginner Contest 079 Review of past questions
AtCoder Beginner Contest 067 Review of past questions
AtCoder Beginner Contest 093 Review of past questions
AtCoder Beginner Contest 046 Review of past questions
AtCoder Beginner Contest 123 Review of past questions
AtCoder Beginner Contest 049 Review of past questions
AtCoder Beginner Contest 078 Review of past questions
AtCoder Beginner Contest 081 Review of past questions
AtCoder Beginner Contest 047 Review of past questions
AtCoder Beginner Contest 060 Review of past questions
AtCoder Beginner Contest 104 Review of past questions
AtCoder Beginner Contest 057 Review of past questions
AtCoder Beginner Contest 126 Review of past questions
AtCoder Beginner Contest 090 Review of past questions
AtCoder Beginner Contest 103 Review of past questions
AtCoder Beginner Contest 061 Review of past questions
AtCoder Beginner Contest 059 Review of past questions
AtCoder Beginner Contest 044 Review of past questions
AtCoder Beginner Contest 083 Review of past questions
AtCoder Beginner Contest 048 Review of past questions
AtCoder Beginner Contest 124 Review of past questions
AtCoder Beginner Contest 116 Review of past questions
AtCoder Beginner Contest 097 Review of past questions
AtCoder Beginner Contest 088 Review of past questions
AtCoder Beginner Contest 053 Review of past questions
AtCoder Beginner Contest 094 Review of past questions
AtCoder Beginner Contest 107 Review of past questions
AtCoder Beginner Contest 071 Review of past questions
AtCoder Beginner Contest 064 Review of past questions
AtCoder Beginner Contest 082 Review of past questions
AtCoder Beginner Contest 084 Review of past questions
AtCoder Beginner Contest 068 Review of past questions
AtCoder Beginner Contest 058 Review of past questions
AtCoder Beginner Contest 043 Review of past questions
AtCoder Beginner Contest 098 Review of past questions
AtCoder Beginner Contest 114 Review of past questions
AtCoder Beginner Contest 045 Review of past questions
AtCoder Beginner Contest 120 Review of past questions
AtCoder Beginner Contest 108 Review of past questions
AtCoder Beginner Contest 106 Review of past questions
AtCoder Beginner Contest 122 Review of past questions
AtCoder Beginner Contest 125 Review of past questions