목록전체 글 (119)
while (1): study();
이런 문제는 처음부터 케이스를 직접 세다보면 정답이 보이는 것 같다. n=1일때는 어떠한 경우에도 가능한 경우의 수가 없으며, 그 이유를 확장하면 모든 홀수에 대해서 경우의 수가 0이라는 것을 알 수 있다.n=2일때, 가능한 경우의 수는 3.n=4 이후부터는 n=2일때의 케이스에 더해, 중간선을 침범하는 형태의 타일 구성이 가능해져서 하나의 중간선 당 2개의 케이스가 가능하다. 따라서 짝수에 대해서만 점화식을 동적 프로그래밍한다면 다음과 같이 구현할 수 있다.def solution(n): MOD = 1000000007 if n % 2 == 1: return 0 dp = [0] * (n // 2 + 1) dp[0] = 1 dp[1] = 3 ..
기본적인 소수판별 알고리즘이지만, 조금 더 개선할 여지는 있다.특히 2를 판별한 경우, 2의 배수(짝수)는 더 이상 판별할 가치가 없다는 점에 착안하여 홀수만을 검사하는 방식으로 구현한다면 훨씬 시간효율적으로 구현이 가능할 것이다. 예를 들어 기본적으로 이런 코드였다면,def solution(nums): from itertools import combinations def is_prime(n): for i in range(2, n): if n % i == 0: return 0 return 1 answer = 0 for com in combinations(nums, 3): answer +..
핵심은 모든 가능한 경우의 수를 열거하고, 그 중에서 불가능한 케이스를 소거법으로 제거해나가는 것이다.중요한 아이디어는 모든 가능한 경우의 수 안에, 반드시 정답이 존재한다는 것.즉 추측(guess)와 정답(secret)의 비교 결과가 추측과 후보(candidate)의 비교 결과와 같아야, 그 후보는 정답이 될 가능성이 존재한다는 것이다.from itertools import permuationsdef solution(n, submit): candidates = [''.join(p) for p in permutations('123456789', 4)] def get_hint(secret, guess): strike = sum(a == b for a, b in zip(secr..
링크: https://arxiv.org/abs/2005.00661 On Faithfulness and Factuality in Abstractive Summarization It is well known that the standard likelihood training and approximate decoding objectives in neural text generation models lead to less human-like responses for open-ended tasks such as language modeling and story generation. In this paper we have analyze arxiv.org Main Question 1. abstractive summa..
1. BLEU (bilingual evaluation understudy) n-gram precision, 생성한 문장을 기준으로 reference의 유사도를 파악. BLEU (bilingual evaluation understudy) is an algorithm for evaluating the quality of text which has been machine-translated from one natural language to another. Quality is considered to be the correspondence between a machine's output and that of a human: "the closer a machine translation is to a profes..
링크: https://arxiv.org/abs/1711.09724 Table-to-text Generation by Structure-aware Seq2seq Learning Table-to-text generation aims to generate a description for a factual table which can be viewed as a set of field-value records. To encode both the content and the structure of a table, we propose a novel structure-aware seq2seq architecture which consists arxiv.org Table-to-Text Generation에 있어 중요한 ..
링크: https://arxiv.org/abs/2010.00910 Continual Learning for Natural Language Generation in Task-oriented Dialog Systems Natural language generation (NLG) is an essential component of task-oriented dialog systems. Despite the recent success of neural approaches for NLG, they are typically developed in an offline manner for particular domains. To better fit real-life applicat arxiv.org 범용 인공지능에 다가..
링크:https://arxiv.org/abs/1704.04368 Get To The Point: Summarization with Pointer-Generator Networks Neural sequence-to-sequence models have provided a viable new approach for abstractive text summarization (meaning they are not restricted to simply selecting and rearranging passages from the original text). However, these models have two shortcomings: th arxiv.org 1. Introduction 문서 요약 태스크에는 Ext..
비트마스크를 입력받는 예제가 있다. vector getBitmask(vector bitmasks, const int length) { for (int n = 0; n < length; n++) { int numElem; int elem; scanf("%d", &numElem); bitset bitmask; for (int e = 0; e < numElem; e++) { scanf("%d", &elem); bitmask.set(elem, 1); } bitmasks.push_back(bitmask); } return bitmasks; } 이때 반환형이 void이든 벡터이든 결과의 size()를 호출하면 0이 나온다. 이후 빈 벡터에 대해 연산을 가하면 vector subscript out of range 등..
컴퓨터는 내부적으로 이진수(비트)를 사용합니다. 그렇기 때문에 십진수 혹은 불린형을 사용하는 것보다 이진수를 사용하여 데이터를 표현하는 것이 더 효과적인 경우가 있습니다. 이렇게 이진수로 데이터를 표현하는 방식을 비트마스크라고 합니다. 파이썬이 지원하는 비트 연산자는 다음과 같습니다. & : AND 연산 | : OR 연산 ^ : NOR 연산 ~ : NOT 연산 : 쉬프트 연산 파이썬이 지원하는 연산자들을 이용하여 비트마스크를 다양하게 조작해보겠습니다. 들어가기 앞서 파이썬에서 제공하는 bin함수는 '수를 이진수 문자열로 바꾸어 출력에 용이하게 해줄 뿐' 실제 형변환이 되거나 그러진 않습니다. 따라서 일반적인 정수로 연산 및 변수 할당을 진행하면 됩니다. 우선 비트마스크는 0으로 초기화하겠습니다. bitm..