Skip to Content
Pythonレベルアップドリル 初心者から一歩進むための厳選問題集
book

Pythonレベルアップドリル 初心者から一歩進むための厳選問題集

by paiza株式会社, リブロワークス
August 2025
Intermediate
216 pages
5h 41m
Japanese
Shōeisha
Content preview from Pythonレベルアップドリル 初心者から一歩進むための厳選問題集
★★★★★
19

★★★★★

あなたは集団行動のリーダーです。次のような指示を出すことでさまざまな列の
操作ができます。
swapab:先頭からa番目の人と、先頭からb 番目の人の位置を入れ替える
reverse:列を逆順にする
resizec:先頭から c 人を列に残し、それ以外の人を全員列から離れさせる。ただ
し、列がすでにc 人以下の場合、何も行わない
はじめ、列には番号1~nのn 人がおり、先頭から番号の昇順に並んでいます。あ
なたの出した指示の回数q とその指示の内容s_i(1 ≦ i ≦ q)が順に与えられるので、
すべての操作を順に行った後の列を出力してください。
入力される値
1行目では、はじめの列の人数 nと、指示の回数q が半角スペース区切りで与えら
れます。以降のn 行では、指示の内容を表す s_i(1 ≦ i ≦ q)が与えられます。
n q
s_1
……
s_q
また、入力される値は、次の条件を満たします。
1≦n,q≦100
s_iは、"swapab"、"reverse"、"resizec"のいずれかの形式
1≦c≦n
a、bはその時点で操作可能であるような生徒番号
期待する出力
すべての操作を終えた後の列sの生徒番号を先頭から順に改行区切りで出力して
ください。
また、出力の末尾には改行を入れてください。
194
s_1
……
……

10 2
reverse
resize 7

10
9
8
7
6
5
4
ここでは列を表すリストをstudents ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

図解まるわかり コンピュータのしくみ

図解まるわかり コンピュータのしくみ

前山 和喜, 武井 一巳

Publisher Resources

ISBN: 9784798188744