kmjp's blog

競技プログラミング参加記です

YUHA C88 謎解きコン : E - 必殺!無限覇王斬!、I - 姫への愛情と朽ちた兜

EはAtCoder初の日本語入力問題?
http://yuha-c88.contest.atcoder.jp/tasks/yuha_c88_e
http://yuha-c88.contest.atcoder.jp/tasks/yuha_c88_i

E - 必殺!無限覇王斬!

2文字の単語のリストと、以下のような形状の入力が与えられるので
適切な出力をせよ。

  連  
  ↓  
者←□→道
  ↓  
  王  

単語リストに登場する全文字を順に□に入れてみる。
□と各文字を矢印の順につなげた時、どれも単語リストにその単語が存在するなら、その文字が解。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math
import codecs

sys.stdin  = codecs.getreader('utf-8')(sys.stdin)
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

N=input()
L={}
LL=[]
S=[]

for i in range(N):
	s = raw_input().strip()
	L[s]=1
	LL.append(s[0])
	LL.append(s[1])

for i in range(5):
	S.append(raw_input())

for s in LL:
	if S[1][2]==u"↑":
		t = s+S[0][2]
	else:
		t = S[0][2]+s
	
	if t not in L:
		continue
		
	if S[3][2]==u"↑":
		t = S[4][2]+s
	else:
		t = s+S[4][2]
	
	if t not in L:
		continue
		
	if S[2][1]==u"←":
		t = s+S[2][0]
	else:
		t = S[2][0]+s
		
	if t not in L:
		continue
		
	if S[2][3]==u"←":
		t = S[2][4]+s
	else:
		t = s+S[2][4]
	if t not in L:
		continue
	print s
	break

I - 姫への愛情と朽ちた兜

N文字の文字列N個からなる暗号文与えられる。
問題文中のメッセージを元にこの暗号文を解読せよ。

メッセージをよく見ると、"monica"の下の文字を順に出力すればよいことがわかる。

int N;
string S[1001];
int ok[256];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,6) ok["monica"[i]]=1;
	
	cin>>N;
	FOR(y,N) cin>>S[y];
	FOR(y,N-1) {
		FOR(x,N) if(ok[S[y][x]]) cout<<S[y+1][x];
	}
	cout<<endl;
}

まとめ

幸いEもFA取れた。競プロ以外でプログラム組まない人は苦戦したっぽい?
Iは最初「彼女の元だからsheとかherの下かなー」とか思っちゃった。