1
0

More than 1 year has passed since last update.

進化戦略のプロシージャ

Last updated at Posted at 2021-08-30

Twitterの広告にシュタインズゲートが流れてきたので
お?っと心惹かれ paizaで電脳言語のオルダーソンループ挑戦したけど
進化戦略のプロシージャは問題文がわかりにくすぎるだろこれ、
二度もしくってイラッとしたわ

競プロやったことないんで
はじめinput() の使い方からしてWhat?って感じだったわ

# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ!!
import sys
n,m = input().split()

#if n == m:
#    print('Yes')
#    sys.exit()

act_dict = {}
for i in range(int(m)):
    k,v = input().split()
    act_dict[int(k)] = int(v)

stay_home = {}
for k,v in act_dict.items():
    if k in stay_home or k == v: # 同じ部屋には移動可能
        continue
    idx = k
    while idx in act_dict:
        nxt = act_dict[idx]
        if nxt in stay_home:
            break
        if nxt == k:
            print('Yes')
            sys.exit()
        stay_home[nxt] = True
        idx = nxt

print('No')
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0