ARC # 016 Participation memo

A-quiz game http://arc016.contest.atcoder.jp/tasks/arc016_1 The input shows that there are N choices for the quiz game and that the correct answer is M, and it is said that numbers other than M are output from 1 to N.

My submission

a.py


#!/usr/bin/env python
# -*- coding:utf-8 -*-
import timeit
import time
import sys
import io
import re
import math
import random
#start = time.time()
#start = time.clock()
i = 1
j = 0
n,m=map(int,raw_input().split())
while True:
    i=random.randint(1,n)
    if i != m:
        print i
        break

I made it output with random numbers with playfulness. I haven't seen anyone else using random, so ...

It seems that it was easy, fast, and sure that it was good to output 2 if the correct answer is 1 and 1 if the correct answer is 2, even if there are more options, in accordance with the minimum of 2 options.

B-Music game http://arc016.contest.atcoder.jp/tasks/arc016_2 Is it okay to count x as it is, and count o for the first appearance and not count it continuously? My submission: Well, the time has expired.

b.py


#!/usr/bin/env python
# -*- coding:utf-8 -*-
import timeit
import time
import sys
import io
import re
import math
j=[]
k=[]
l=0
ans=0
i=int(raw_input())
for x in xrange(i):
    j.append(str(raw_input()))
for y in xrange(9):
    h=0
    while h < i:
        if str(j[h][l])=='x': ans+=1
        if str(j[h][l])=='o':
            if h==0:
                ans+=1
            elif str(j[h-1][l])=='o':
                pass
            else:
                ans+=1
        h+=1
    l+=1
print ans

Reflection I should have used x and y as they are, without using functions that I don't understand such as h and l. List operation and more

Nekarugo's source that was concise and easy to understand while I saw some others

Reprint / Quote.py


a = input()
inputs = [raw_input() for x in xrange(a)]
res = 0
for x in xrange(a):
 for y in xrange(9):
  if inputs[x][y] == 'x':res += 1
  if inputs[x][y] == 'o' and (x == 0 or inputs[x - 1][y] != 'o'): res += 1
 
print res

Receive the number of lines and the score in a list. If you look at the list vertically with [x] [y] and there is an'x', add it as it is, if there is an'o', add it if it is the first line of the list, if it is after the first line, the previous line is' o'The process of adding when it doesn't appear (should be ...) If you think that the basic policy is the same, read it sideways and if there is an'o', it seems to be a policy to check the previous line. The desperate difference in cleanliness remains the same Questions C and D are untouched.

Recommended Posts

ARC # 016 Participation memo
Raspberry-pi memo
Pandas memo
HackerRank memo
python memo
graphene memo
Flask memo
pyenv memo
Matplotlib memo
pytest memo
sed memo
Python memo
Install Memo
BeautifulSoup4 memo
networkx memo
AtCoderBeginnerContest154 Participation memo (Python, A ~ E problem)
python memo
tomcat memo
command memo
Generator memo.
psycopg2 memo
Python memo
SSH memo
Command memo
Memo: rtl8812
pandas memo
Shell memo
Python memo
Pycharm memo
Python memo