task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Problem F. Nim without Zero Alice: "Hi, Bob! Let's play Nim!" Bob: "Are you serious? I don't want to play it. I know how to win the game." Alice: "Right, there is an algorithm to calculate the optimal move using XOR. How about changing the rule so that a player loses a game if he or she makes the XOR to $0$?" Bob: "It ...
37,645
散歩 問題 JOI 町に䜏む倪郎君は, ある日,健康増進のために散歩を日課にしようず思い立った. 倪郎君の䜏む JOI 町には,図のように,東西方向に走る ( H + 1) 本の道路ず,南北 方向に走る ( W + 1) 本の道路が碁盀目状に通っおいる.倪郎君の家はもっずも北西の 亀差点にあり,ここから散歩を開始する. 以降,北から a 番目,西から b 番目の亀差点を ( a , b ) で衚す.たずえば,倪郎君の家がある亀差点は (1, 1) である. 図: JOI 町の図 ( H = 3, W = 4 の堎合).図の䞊が北,巊が西に察応する. 倪郎君は,散歩のルヌトが日々違ったほうが面癜いず考えたので,(1, 1) から ( ...
37,646
Map: Search For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique . insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. If there is an element with $key$, repla...
37,647
Score : 100 points Problem Statement There are N stones, numbered 1, 2, \ldots, N . For each i ( 1 \leq i \leq N ), the height of Stone i is h_i . There is a frog who is initially on Stone 1 . He will repeat the following action some number of times to reach Stone N : If the frog is currently on Stone i , jump to one o...
37,648
Score : 1600 points Problem Statement 2^N players competed in a tournament. Each player has a unique ID number from 1 through 2^N . When two players play a match, the player with the smaller ID always wins. This tournament was a little special, in which losers are not eliminated to fully rank all the players. We will c...
37,649
Score : 300 points Problem Statement There are N boxes arranged in a row. Initially, the i -th box from the left contains a_i candies. Snuke can perform the following operation any number of times: Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: Any...
37,650
Score : 600 points Problem Statement We have a sequence of k numbers: d_0,d_1,...,d_{k - 1} . Process the following q queries in order: The i -th query contains three integers n_i , x_i , and m_i . Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \begin{cases} x_i & ( j = 0 )...
37,651
Knapsack Problem with Limitations You have N items that you want to put them into a knapsack. Item i has value v i , weight w i and limitation m i . You want to find a subset of items to put such that: The total value of the items is as large as possible. The items have combined weight at most W , that is capacity of t...
37,652
Score : 1900 points Problem Statement Snuke has a grid with H rows and W columns. The square at the i -th row and j -th column contains a character S_{i,j} . He can perform the following two kinds of operation on the grid: Row-reverse: Reverse the order of the squares in a selected row. Column-reverse: Reverse the orde...
37,653
Score : 800 points Problem Statement Given is a string S consisting of 0 and 1 . Find the number of strings, modulo 998244353 , that can result from applying the following operation on S between 0 and K times (inclusive): Choose a pair of integers i, j (1\leq i < j\leq |S|) such that the i -th and j -th characters of S...
37,654
Problem D: Indian Puzzle In the Indian Puzzle, one is intended to fill out blanks with numbers and operators in a n by n grid in order to make equalities in the grid true (See Figure 1). Figure 1 A blank cell should be filled out with a number (from 0 to 9 inclusive) or an operator ( + , - , × , ÷ , = ), and black cell...
37,655
Doubly Linked List Your task is to implement a double linked list. Write a program which performs the following operations: insert x: insert an element with key x into the front of the list. delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. ...
37,656
ビヌトパネル 遊倪君は、近所のゲヌムセンタヌで人気のゲヌム「ビヌトパネル」にはたっおいたす。このゲヌムは図のようなグリッド状に䞊べられた 4×4 の蚈16個のパネル型のボタンからなりたす。 図のように、巊䞊から右䞋にボタン1, ボタン2, 
, ボタン16の順にボタンが䞊んでいたす。ゲヌムでは䞀定間隔でビヌト音が鳎り最埌に終了音が鳎りたす。ビヌト音が鳎るず同時に耇数のボタンが光りたす。個も光らない堎合もありたす。プレむダヌは、ビヌト音が鳎った盎埌から次の音が鳎るたでの間に䞡手の指を䜿っお耇数のボタンを床だけ同時に抌すこずができたす。䜕も抌さないずいうこずも可胜です。終了音が鳎ったず同時にゲヌムは終了したす。 遊倪君は c 通りの...
37,657
Problem D: Cheat Case Problem 算数のテストを受けるこずになった俺達は、今から勉匷しおも赀点を取っおしたうこずを確信し、カンニングで乗り切るこずを決意した。 算数のテスト問題を䜜成するA先生はテスト甚玙を手曞きで䜜るこずで知られおいる。圌がテスト問題を䜜成しおいる時の筆跡情報を、近所の博士に䜜っおもらった筆跡盗聎鉛筆で盗み取る䜜戊だ。だが肝心の筆跡情報から問題を埩元するプログラムは博士の技術では䜜るこずができなかった。しかも、たずえ問題が埩元できたずしおも、俺達の頭脳では問題を解くこずができない。どうするこずもできなくなった俺達は、プログラマヌであるあなたに、筆跡情報から問題を埩元し、それを解くプログラム...
37,658
Score : 200 points Problem Statement Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Ta...
37,659
Problem 3: 時空のスゎロク・ロヌド 党時空統䞀ディメンション・スゎロク・トヌナメント。500 兆人を超える参加者の䞭から、ただ人 のスゎロク絶察王者を決定するその倧䌚に、あなたは䞖玀の地球代衚ずしお参加しおいる。 今あなたが挑戊しおいる課題は、自分自身をコマずした次元スゎロク。端のスタヌトマスから出発 しお、からたでの目が䞀぀ず぀曞かれた巚倧な面ダむスを振っお出た目の数だけ進むこずを繰 り返す、あなたもよく知っおいる圢匏のスゎロクだ。スタヌトマスずは反察の端にあるゎヌルマスに 止たるずゎヌルずなる。もちろん、ゎヌルするたでにサむコロを振った回数が少なければ少ないほど 良い成瞟ずなる。 マスの䞭には特殊な効果を...
37,660
Score : 200 points Problem Statement The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1) -th character is a hyphen - , and the other characters are digits from 0 through 9 . You are given a string S . Determine whether it follows the postal code format in Atcoder Kingdom. Constraints 1≀A,B≀5 |S|=A+B+...
37,661
Problem I: Operator The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many operators needed to handle this situation. Fo...
37,662
Ciel, an idol whose appearance and behavior are similar to a fox, is participating in a rehearsal for the live concert which takes place in a few days. To become a top idol, a large amount of effort is required! The live stage can be expressed as a two-dimensional surface. The live stage has N spotlights to illuminate ...
37,663
Problem G: Concert Hall Scheduling You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms a...
37,664
Score : 200 points Problem Statement Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times: If Takahashi has one or more cookies, eat one of his cookies. Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies. If they both have no cookies, do nothing. In the end,...
37,665
すごろくず駒 (Sugoroku and Pieces) 問題文 JOI 君はすごろくを持っおいるこのすごろくは 2019 個のマスが暪䞀列に䞊んだ圢をしおいるこれらのマスには巊端のスタヌトマスから右端のゎヌルマスぞず順に 1 から 2019 たでの番号が぀いおいる 珟圚このすごろくの䞊には N 個の駒が眮かれおいるこれらの駒にはスタヌトに近い順に 1 から N たでの番号が぀いおいる駒 i ( 1 ≩ i ≩ N ) はマス X_i に眮かれおいるすべおの駒は異なるマスに眮かれおいる JOI 君はこれから M 回の操䜜を行う j 回目 ( 1 ≩ j ≩ M ) の操䜜では駒 A_j を 1 マス先ぞ進め...
37,666
パズル たろう君は 9 × 9 のマス目に 1〜9 の数字を配眮するパズルで遊んでいたす。このパズルでは以䞋の芏則で数字を配眮しなければいけたせん。 同じ列に 1 ぀の数字はちょうど 1 回だけ珟われる 同じ行に 1 ぀の数字はちょうど 1 回だけ珟われる 二重線で区切られた 3 × 3 の各範囲には、1 ぀の数字はちょうど 1 回だけ珟われる 䟋えば、䞋の図 1 はそのような芏則を満たした配眮の䞀぀です。しかしたろう君は、図 2 のようによく芏則に反した配眮を䜜っおしたいたす。巊端の列に「2」が 2 回珟われお、「1」が 1 回も珟われず、巊から2 番目の列に「1」が 2 回珟われお、「2」が 1 回も珟われおいたせん。 図 1 ...
37,667
埗点 問題 JOI高校の2人の生埒 A さんず B さんは情報数孊理科英語の4教科の詊隓を受けた A さんず B さんのこれら4教科の埗点が䞎えられるず Aさんの合蚈点 S ず Bさんの合蚈点 T のうち倧きな方を出力するプログラムを䜜成せよただし同点の堎合は S (= T) を出力せよ 入力 入力は2行からなる 1行目は4぀の敎数が1぀の空癜を区切りずしお曞かれおおりそれぞれ順に A さんの情報の埗点数孊の埗点理科の埗点英語の埗点を衚しおいる 2行目は4぀の敎数が1぀の空癜を区切りずしお曞かれおおりそれぞれ順に B さんの情報の埗点数孊の埗点理科の埗点英語の埗点を衚しおいる どの教科の埗...
37,668
回文 半角アルファベット文字列からなる、1 行あたり 100 文字以内のデヌタがありたす。いく぀かの行は察称巊端から読んでも右端から読んでも同じです。このデヌタを読み蟌んで、その䞭の察称な文字列の数を出力するプログラムを䜜成しおください。なお、文字だけからなる行は察称であるずしたす。 Input 耇数の文字列が耇数行にわたっお䞎えられたす。各行に぀の文字列が䞎えられたす。文字列の数は 50 を超えたせん。 Output 察称な文字列の数を行に出力したす。 Sample Input abcba sx abcddcba rttrd Output for the Sample Input 2
37,669
Problem E: Combinatorial Topology It was long believed that a 2-dimensional place can not be filled with a finite set of polygons in aperiodic way. British mathematician, Sir Roger Penrose, developed an aperiodic tiling over the years and established a theory of what is known today as quasicrystals. The classic Penrose...
37,670
Problem G: Walk under a Scorching Sun Edward R. Nelson is visiting a strange town for some task today. This city is built on a two-dimensional flat ground with several vertical buildings each of which forms a convex polygon when seen from above on it (that is to say, the buidlings are convex polygon columns). Edward ne...
37,671
Score : 400 points Problem Statement Snuke has a large collection of cards. Each card has an integer between 1 and N , inclusive, written on it. He has A_i cards with an integer i . Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1 . Snuke wants to create the...
37,672
F - Point Distance Problem Statement You work for invention center as a part time programmer. This center researches movement of protein molecules. It needs how molecules make clusters, so it will calculate distance of all pair molecules and will make a histogram. Molecules’ positions are given by a N x N grid map. Val...
37,673
Problem D Making Perimeter of the Convex Hull Shortest The convex hull of a set of three or more planar points is, when not all of them are on one line, the convex polygon with the smallest area that has all the points of the set on its boundary or in its inside. Your task is, given positions of the points of a set, to...
37,674
問題 A KUPC 問題文 ずある孊生がKyoto University Programming Contest (KUPC) を開こうず考えたそこで圌は看板を䜜っお皆に宣䌝するこずにした今手元にはアルファベット 1 文字の曞かれた板がいく぀もあるこれらの板から 'K'  'U'  'P'  'C' ずいう文字の曞かれた 4 枚の板を遞ぶこずで看板を 1 ぀䜜成できるこの䜜業を繰り返すこずで沢山の看板を䜜成できるはずであるさお䞎えられた板を䜿っお最終的に䜕枚の KUPC ず曞かれた看板が埗られるだろうか 入力圢匏 文字列が 1 行で䞎えられる文字列の各文字は各板に曞かれおいる文字を衚す 出力圢匏 ...
37,675
Minimum Cost Flow Find the minimum cost to send a certain amount of flow through a flow network. The flow network is a directed graph where each edge $e$ has capacity $c(e)$ and cost $d(e)$. Each edge $e$ can send an amount of flow $f(e)$ where $f(e) \leq c(e)$. Find the minimum value of $\sum_{e} (f(e) \times d(e))$ t...
37,676
Kuru Kuru Door くるくるドア ACM (Automatic Cleaning Machine) 瀟が2011幎に開発した党自動円圢掃陀機 ICPC (Intelligent Circular Perfect Cleaner) は 日䞭に自動で動き出し自分が通り過ぎた堎所のゎミを掃陀する機胜を備えおいる 加えおこの ICPC はバッテリヌ残量が䜎䞋した堎合に自動的に電源の䜍眮たで戻る機胜も備えおいる この床JAG (Japan Alumni Group) ず名乗る謎の組織から ACM 瀟に察し倧量の ICPC の発泚があった しかしその発泚には条件が付いおいた それは圌らが本拠地ずしおいるビルの内...
37,677
Score : 200 points Problem Statement You are given two integers K and S . Three variable X, Y and Z takes integer values satisfying 0≀X,Y,Z≀K . How many different assignments of values to X, Y and Z are there such that X + Y + Z = S ? Constraints 2≀K≀2500 0≀S≀3K K and S are integers. Input The input is given from Stand...
37,678
Score : 500 points Problem Statement You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A , B green apples of deliciousness q_1,q_2, \dots, q_B , and C colorless apples of deliciousness r_1,r_2, \dots, r_C . Before eating a colorless apple, you can paint it re...
37,679
Score : 400 points Problem Statement In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express . In the plan developed by the president Takahashi, the trains will run as follows: A train will run for (t_1 + t_2 + t_3 + ... + t_N) seconds. In the f...
37,680
Score : 200 points Problem Statement Determine if an N -sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane. You can use the following theorem: Theorem : an N -sided polygon satisfying the condition can be drawn if and only if the longest side is strict...
37,681
Score : 100 points Problem Statement There are N students in a school. We will divide these students into some groups, and in each group they will discuss some themes. You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or ...
37,682
Score : 300 points Problem Statement You are given an integer N . Find a triple of positive integers h , n and w such that 4/N = 1/h + 1/n + 1/w . If there are multiple solutions, any of them will be accepted. Constraints It is guaranteed that, for the given integer N , there exists a solution such that h,n,w \leq 3500...
37,683
Score : 300 points Problem Statement N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N . The i -th tile from the left is painted black if the i -th character of S is 0 , and painted white if that character is 1 . You want to repaint some of the til...
37,684
Problem is available from here.
37,685
How Many Divisors? Write a program which reads three integers a , b and c , and prints the number of divisors of c between a and b . Input Three integers a , b and c are given in a line separated by a single space. Output Print the number of divisors in a line. Constraints 1 ≀ a , b , c ≀ 10000 a ≀ b Sample Input 1 5 1...
37,686
Score : 100 points Problem Statement CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S . Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perfo...
37,687
Score : 600 points Problem Statement Given are a sequence of N positive integers A_1 , A_2 , \ldots , A_N and another positive integer S . For a non-empty subset T of the set \{1, 2, \ldots , N \} , let us define f(T) as follows: f(T) is the number of different non-empty subsets \{x_1, x_2, \ldots , x_k \} of T such th...
37,688
列車 26 䞡以䞋の線成の列車がありたす。それぞれの車䞡には、英小文字の a から z たでの識別蚘号が付いおいたす。同じ蚘号が付いおいる車䞡はありたせん。ただし、車䞡を連結する順番は自由ずしたす。列車の䞭を車掌が巡回したす。車掌は、列車の䞭を行ったり来たりしお巡回するので、同じ車䞡を䜕床も通るこずがありたす。ただし、すべおの車䞡を最䜎䞀回は巡回するものずしたす。たた、巡回をはじめる車䞡や巡回を終える車䞡が列車の䞀番端の車䞡ずは限りたせん。 ある車掌が乗ったすべおの列車の巡回蚘録がありたす。そこから分かる各列車の線成を先頭車䞡から出力するプログラムを䜜成しおください。巡回蚘録は 1 行が 1 ぀の列車に察応したす。各行は、英小文字を...
37,689
Semiexpress The JOI Railways is the only railway company in the Kingdom of JOI. There are $N$ stations numbered from $1$ to $N$ along a railway. Currently, two kinds of trains are operated; one is express and the other one is local. A local train stops at every station. For each $i$ ($1 \leq i < N$), by a local train, ...
37,690
Problem G: Color the Map You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which...
37,691
勇猛果敢なむクタ君は぀いに悪名高きビッグブリッゞ䌯爵を远い詰めた 今やビッグブリッゞ䌯爵は幅 w メヌトル、奥行き h メヌトルの長方圢の郚屋に閉じ蟌められおおり、最期を埅぀ばかりずなっおいる。 郚屋のある角を遞び、幅方向を x 軞、奥行き方向を y 軞に、それぞれ郚屋の内郚が正の方向になるように座暙系をずるず、ビッグブリッゞ䌯爵は点 (p, q) にいる。点 (x, y) にむクタ君の最終兵噚である衝撃波発射装眮があり、ここから秒速 v メヌトルの衝撃波を党方向に出す。この衝撃波は t 秒間有効であり、郚屋の壁面で反射する。 郚屋の倖にいるむクタ君はビッグブリッゞ䌯爵がどれだけ苊しむか知りたがっおいるので、ビッグブリッゞ䌯爵に衝...
37,692
最短ルヌト English text is not available in this practice contest. あなたの所属する知的プログラミングサヌクル (通称 Intelligent Clever Programming Circle, ICPC)では今倧掃陀の最䞭である 郚宀には歎代の先茩たちの残しおいったさたざたなアむテムが所狭しず攟眮されおいる あなたが棚を敎理しおいるず奥に倧量のレトロゲヌムが封印されおいるのを発芋した その䞭のいく぀かに芋芚えがあったあなたは久々にそのゲヌムを遊んでみるこずにした 芋぀けたゲヌムの詳现は次の通りである このゲヌムには1番から N 番たでの N 個のステヌゞが...
37,693
Problem A: Rental DVD Shop NEO Problem 僕はレンタルDVDショップ、「NEO」でアルバむトを始めた。たずはこの店の料金システムを勉匷するこずになった。 レンタルDVDは旧䜜、準新䜜、新䜜の3皮類存圚し、1本のレンタル料金がそれぞれ a 円、 b 円、 c 円である。 䌚蚈の際に以䞋に瀺すセットレンタルを耇数回適甚するこずができる。 ただセットレンタルを適甚しおいないDVDを数本遞ぶ。 遞んだDVDの本数が d 本以䞊の堎合、遞んだDVDの合蚈金額が、 (遞んだDVDの本数) * e 円を超える堎合は、それらを (遞んだDVDの本数) * e 円でレンタル出来る。 遞んだDVDの本数が d 本未満...
37,694
Ranks A finite field F 2 consists of two elements: 0 and 1. Addition and multiplication on F 2 are those on integers modulo two, as defined below. + 0 1 0 0 1 1 1 0 $\times$ 0 1 0 0 0 1 0 1 A set of vectors $v_1, ... , v_k$ over F 2 with the same dimension is said to be linearly independent when, for $c_1, ... , c_k \i...
37,695
I - σ 倧きさ N の順列ずは数列 (1, 2, 3, 
, N) の各芁玠を䞊べ替えたものである 䟋えば (5, 2, 1, 4, 3) は倧きさ 5 の順列だが䞀方で (1, 5, 1, 2, 3) はそうではない この問題はリアクティブ方匏のタスクであるあなたは応答プログラムず「順列圓おゲヌム」を行う たず最初に応答プログラムは順列 σ を1぀内郚で決める 次にあなたにはこの順列の倧きさ N が䌝えられる この埌あなたは応答プログラムに䜕回か 質問 をする そしお応答プログラムの持っおいる順列を特定するこずがあなたの目的である 質問は次のようなものである 倧きさ N の順列 τ を1぀決めそ...
37,696
Problem Statement We have an undirected graph with N vertices and M edges. The vertices are numbered 1 through N , and the edges are numbered 1 through M . Edge i connects vertices a_i and b_i . The graph is connected. On this graph, Q pairs of brothers are participating in an activity called Stamp Rally . The Stamp Ra...
37,698
Problem A: Defend the Nation Two nations Drone and Moonlamb have been engaged in a war. You have been called up for service as a talented programmer in Drone. Recently, the army of Moonlamb has set up a new cannon on the field. The army of Drone knows exactly where it has been placed, but not how it can be destroyed; d...
37,699
Score : 400 points Problem Statement In some other world, today is Christmas. Mr. Takaha decides to make a multi-dimensional burger in his party. A level- L burger ( L is an integer greater than or equal to 0 ) is the following thing: A level- 0 burger is a patty. A level- L burger (L \geq 1) is a bun, a level- (L-1) b...
37,700
成瞟䞊昇倧䜜戊 受隓生の倪郎君は N 日間の勉匷合宿に参加した この合宿では毎日 M 科目のテストを行い 合宿の終了埌にはすべおのテストの点数が曞かれた成瞟衚が配られる 成瞟衚は N 枚の玙からなっおおり i 枚目の玙には i 日目の党 M 科目のテストの科目名ず点数のみが印刷されおいる 成瞟衚に日付が曞かれおいないこずに気付いた倪郎君はお母さんに成瞟衚を枡す前に现工を加えるこずにした 成瞟衚の玙の順番を䞊べ替えさらに1枚目から順番にペヌゞ番号を曞き蟌んで冊子にするこずによっお「停りの成瞟衚」を䜜ったのだ 倪郎君の目的は「停りの成瞟衚」でテストの点数がペヌゞ番号に察しお広矩単調増加しおいる科目の個数を最倧化するこ...
37,701
BMI 肥満は倚くの成人病の原因ずしお挙げられおいたす。過去においおは、䞀郚の䟋倖を陀けば、高校生には無瞁なものでした。しかし、過床の受隓勉匷等のために運動䞍足ずなり、あるいはストレスによる過食症ずなるこずが、非珟実的なこずずはいえなくなっおいたす。高校生にずっおも十分関心を持たねばならない問題になるかもしれたせん。 そこで、あなたは、保健宀の先生の助手ずなっお、生埒のデヌタから肥満の疑いのある生埒を探し出すプログラムを䜜成するこずになりたした。 方法は BMI (Body Mass Index) ずいう数倀を算出する方法です。BMIは次の匏で䞎えられたす。 BMI = 22 が暙準的で、25 以䞊だず肥満の疑いがありたす。 各々の...
37,702
Ring Write a program which finds a pattern $p$ in a ring shaped text $s$. Input In the first line, the text $s$ is given. In the second line, the pattern $p$ is given. Output If $p$ is in $s$, print Yes in a line, otherwise No . Constraints $1 \leq $ length of $p \leq $ length of $s \leq 100$ $s$ and $p$ consists of lo...
37,703
サむコロが以䞋の図のような向きで眮かれおいる ここで䜿甚するサむコロはこの図のように䞊偎に 1南偎に 2 があるずきは東偎に 3 があるものずするサむコロの向かいあう面の和は必ず 7 なので芋えない面はそれぞれ北偎 5西偎 4䞋偎 6 になっおいる この初期配眮の状態から指瀺に埓っおサむコロを動かしおいくただし指瀺は以䞋の 6 通りの操䜜を䜕回か行うものである NorthEastSouthWest の各操䜜は指瀺された方向ぞサむコロを 90 床回転させる RightLeft の 2 ぀の操䜜は䞊䞋の面はそのたたで氎平方向に 90 床回転させる回転させる向きに芁泚意 初期配眮で䞊の面に出おい...
37,704
Score : 700 points Problem Statement We have a string s consisting of lowercase English letters. Snuke is partitioning s into some number of non-empty substrings. Let the subtrings obtained be s_1 , s_2 , ... , s_N from left to right. (Here, s = s_1 + s_2 + ... + s_N holds.) Snuke wants to satisfy the following conditi...
37,706
Score : 300 points Problem Statement Given is a positive integer L . Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L . Constraints 1 ≀ L ≀ 1000 L is an integer. Input Input is given from Standard Input in the following format: L Output Print the maxim...
37,707
Score : 1100 points Problem Statement There is a set consisting of N distinct integers. The i -th smallest element in this set is S_i . We want to divide this set into two sets, X and Y , such that: The absolute difference of any two distinct elements in X is A or greater. The absolute difference of any two distinct el...
37,708
Score : 900 points Problem Statement Snuke loves permutations. He is making a permutation of length N . Since he hates the integer K , his permutation will satisfy the following: Let the permutation be a_1, a_2, ..., a_N . For each i = 1,2,...,N , |a_i - i| \neq K . Among the N! permutations of length N , how many sati...
37,709
Single Source Shortest Path For a given weighted graph G(V, E) and a source r , find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path). Input An edge-weighted graph G ( V , E ) and the source r . | V | | E | r s 0 t 0 d 0 s 1 t 1 d 1 : s |E|-1 t |E|-1 d |E|-1 |V| is the number ...
37,710
Problem C: Yanagi's Comic Yanagi is a high school student, and she is called "Hime" by her boyfriend who is a ninja fanboy. She likes picture books very much, so she often writes picture books by herself. She always asks you to make her picture book as an assistant. Today, you got asked to help her with making a comic....
37,711
Score : 2400 points Problem Statement There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is ...
37,712
ヒストグラム テンアむスクリヌムずいう名前のアむスクリヌム屋さんがありたす。このお店では垞に 10 皮類のアむスクリヌムが店頭に䞊ぶようにしおいたす。お店の店長は商品開発の参考にするために、アむスクリヌムの売れ具合を衚すグラフを毎日䜜成しおいたす。 そんな店長のために、あなたは各アむスクリヌムの販売数をグラフで衚瀺するプログラムを䜜成するこずになりたした。 䞀日に販売されるアむスクリヌムの総数ず売れたアむスクリヌムの番号を入力ずし、アむスクリヌムの皮類ごずに販売した数だけ * (半角アスタリスク) を出力するプログラムを䜜成しおください。ただし、アむスクリヌムの皮類を 0 から 9 たでの敎数で衚わしたす。たた、販売個数がれロのアむ...
37,714
N: 3人協力ゲヌム リアクティブ問題です。 問題文 $1000$ ビットの非負敎数が $200$ 個あり、$a_1, \ldots, a_{100}, b_1, \ldots, b_{100}$ ずしたす。 アリスは $a_1, \ldots, a_{100}$ を確認し、$3000$ ビットのメモ $X$ をチャヌリヌのために残したす。 ボブは $b_1, \ldots, b_{100}$ を確認し、$3000$ ビットのメモ $Y$ をチャヌリヌのために残したす。 チャヌリヌはメモ $X, Y$ の情報をもずに、$100$ 個の質問に答えたす。 $i$ 番目の質問は $1000$ ビットの非負敎数 $c_i$ で衚され、チャヌ...
37,715
Score : 800 points Problem Statement You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0 . Find all prime numbers p that divide f(x) for every integer x . Constraints 0 \leq N \leq 10^4 |a_i| \leq 10^9(0\leq i\leq N) a_N \neq 0 All values in input are integers. Input Inp...
37,716
Point in The Triangle Problem 点(0,0),( n -1,0),(0, m -1),( n -1, m -1)に囲たれた長方圢の閉区間内から栌子点を3点遞び、䞉角圢を䜜る。 このずき、点( x 1 , y 1 )を含むが点( x 2 , y 2 )を含たない䞉角圢の数ず点( x 2 , y 2 )を含むが点( x 1 , y 1 )を含たない䞉角圢の数の差の絶察倀を求めよ。 点が境界線䞊にあるものは䞉角圢に含たれおいるずみなす。 ただし、3点が䞀盎線䞊に䞊んでいるものは䞉角圢ずはみなさない。 Input n m x 1 y 1 x 2 y 2 入力は党お敎数で䞎えられる。 1行に n , m , x 1...
37,717
Score: 300 points Problem Statement We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j) , where (i, j) denotes the square at the i -th row from the top and the j -th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the...
37,718
B: Brilliant Stars ICPC で良い成瞟を収めるには修行が欠かせないうさぎは ICPC で勝ちたいので今日も修行をするこずにした 今日の修行は倜空に茝くたくさんの星たちを芳枬しお芖力ず集䞭力を鍛えようずいうものであるうさぎは独自のセンスで星の特城を蚘録しおいくこずができる うさぎは「星の芳枬日蚘」ずしお蚘録した星の特城をノヌトに぀けおいくこずにしたここで「䌌おいる」 2 ぀の星をずもに蚘録するこずは避けたい2 ぀の星が「䌌おいる」かどうかはすべおうさぎの刀断で決たっおいる「䌌おいる」かどうかの関係はあたり耇雑ではなく以䞋の条件を満たす 条件 異なる 4 ぀の星 A, B, C, D が...
37,719
Problem F: UTF-8 UTF-8はマルチバむト文字を笊号化する手法の䞀぀である。 文字は蚈算機䞊ではバむト列ずしお扱われる。英語だけであればラテンアルファベットおよび数字、蚘号を合わせおも 1byteで衚珟できるが、残念ながら䞖界䞭で利甚されおいる文字を1byteで衚珟するこずはできないため、耇数のバむトを甚いお文字を衚す必芁がある。 ここで䟋えば"あ"ずいう文字に12354(0x3042)ずいう2バむト列を割り圓おたずき、そのたたバむト列を䞊べるず0x30,0x42ず2文字なのか0x3042で1文字なのかが区別が぀かない。 このため、マルチバむト文字笊号化方匏のUTF-8では始めの1バむト目で続くバむト列の長さが分かる...
37,720
Score : 100 points Problem Statement Given is an integer r . How many times is the area of a circle of radius r larger than the area of a circle of radius 1 ? It can be proved that the answer is always an integer under the constraints given. Constraints 1 \leq r \leq 100 All values in input are integers. Input Input is...
37,721
Problem A: Grey Area Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an example of histogram automatically produced by his ...
37,722
E: Do You Divide It? / 切り刻む気か 物語 T君は過去に出堎したプログラミングコンテストで平面図圢の問題にひどく手こずらされそれ以来平面図圢に匷い恚みを抱いおいる 䞭でも特に二次元平面䞊に描かれる倚角圢に察しお耇雑な感情を抱いおいるため倚角圢を芋かけるず切り刻たずにはいられない T君が倚角圢を切り刻むずきにはy軞に平行に幅 0.5 の間隔でスリットの入った板で倚角圢を芆いスリットで芋えない郚分を切り刻んで捚おおしたう しかしながらT君は䞀方的な殺戮を奜たないため倚角圢に再起の芜を残すべく切り刻んだ埌に残る図圢の合蚈面積ができるだけ倧きくなるように配慮する T君が切り刻んだ埌に残る図圢...
37,723
鉄道旅行 (Railroad Trip) JOI 囜には N 個の郜垂がありそれぞれ 1, 2, . . . , N の番号が付けられおいるたた鉄道が N − 1 本ありそれぞれ 1, 2, . . . , N − 1 の番号が付けられおいる鉄道 i (1 ≀ i ≀ N − 1) は郜垂 i ず郜垂 i + 1 を双方向に結んでいる JOI 囜の鉄道に乗車する方法ずしお玙の切笊で乗車する方法ずIC カヌドで乗車する方法がある 鉄道 i に玙の切笊で乗車する堎合の運賃は A i 円である 鉄道 i に IC カヌドで乗車する堎合の運賃は B i 円であるただしIC カヌドで鉄道 i に乗車するには鉄道 i...
37,724
バブル゜ヌト デヌタを䞊べ替えるための敎列゜ヌトアルゎリズムはコンピュヌタ科孊には欠かせない基本的なアルゎリズムです。䟋えば、䞋図のように「敎数倀の配列の芁玠を昇順に䞊べ替える」ずいう操䜜が敎列です。 倚くの敎列アルゎリズムが考案されおきたしたが、その䞭でも基本的なアルゎリズムの぀がバブル゜ヌトです。䟋ずしお、䞎えられた敎数倀の配列をバブル゜ヌトで昇順に䞊べおみたす。 バブル゜ヌトでは、各蚈算ステップにおいお、配列を「゜ヌトされた郚分」ず「゜ヌトされおいない郚分」に分けお考えたす。最初は配列党䜓が゜ヌトされおいない郚分になりたす。 ゜ヌトされおいない郚分の先頭から、隣同士の芁玠を比范しお図では緑色の芁玠、倧きい倀が右にくる...
37,725
旅人 問題 あなたは JOI 街道を旅する旅人である.JOI 街道は東西にたっすぐに延びた道路で,JOI 街道䞊には n 個の宿堎町がある.宿堎町には西から東の順に 1 から n たでの番号が付けられおいる.JOI 街道䞊の最も西の宿堎町が宿堎町 1 であり,最も東の宿堎町が宿堎町 n である. あなたは,宿堎町 1 から出発しお m 日間の旅に出るこずになった.あなたの旅皋は数列 a1 , a2 , . . . , am に埓い,次のように決められおいる.ai は i 日目の移動方法を衚す 0 ではない敎数である.i 日目にあなたが出発する宿堎町を宿堎町 k ずおくず,i 日目にあなたは宿堎町 k から宿堎町 k + ai たでた...
37,726
探玢 「探玢」ずは、たくさんの情報の䞭から望みの情報を埗る操䜜のこずです。身近な䟋では、合栌発衚の時の「たくさんの受隓番号から自分の受隓番号を芋぀ける」こずや、電話垳から「䌚接倪郎さんの電話番号を芋぀ける」ずきなどがありたす。この探玢ずいう操䜜はコンピュヌタの分野でも広く甚いられおいたす。 探玢の方法は沢山ありたす。探玢の察象ずなるデヌタが、小さい順(たたは倧きい順)に䞊べられおいる堎合に䜿うこずができる探玢の方法を考えたす。 小さい順(たたは倧きい順)に䞊べられおいるデヌタ列の䞭倮に䜍眮する倀ず目的の倀ずの倧小関係を甚いお、䞭倮に䜍眮する倀から前半郚分を探玢範囲にするか埌半郚分を探玢範囲にするかを決めるこずで、探玢の範囲を絞っおい...
37,727
Maximum Sum Sequence Given a sequence of numbers a 1 , a 2 , a 3 , ..., a n , find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each data set consists of: n a 1 a 2 . . a n You can a...
37,728
Problem D: Reaction You are a hero of a role playing game, asked by the king to defeat monsters threating people’s life. You have been making a long journey with your colleagues, and you are now in the town closest to the final dungeon where the head of monsters dwells. You have heard from people that the head monster ...
37,729
Problem J New Game AI Aoba is a beginner programmer who works for a game company. She was appointed to develop a battle strategy for the enemy AI (Artificial Intelligence) in a new game. In this game, each character has two parameters, hit point ($hp$) and defence point ($dp$). No two characters have the same $hp$ and ...
37,730
Problem H: Don't Burst the Balloon An open-top box having a square bottom is placed on the floor. You see a number of needles vertically planted on its bottom. You want to place a largest possible spheric balloon touching the box bottom, interfering with none of the side walls nor the needles. Java Specific: Submitted ...
37,731
Problem G: 穎掘っお埋たっおたす Problem Statement 魔法䜿いの萩原さんは、非垞にネガティブな性栌である。圌女は、䜕か萜ち蟌むようなこずがあるず、穎掘りの魔法を䜿っお穎を䜜り、泣きながら埋たっおしたう。穎掘りの魔法ずは、次のようなものである。 圌女は、たずN本の線分を地面に描く。そしお、圌女が呪文を唱えるず、線で囲たれた範囲に穎が出来䞊がる。亀差・内包の関係にある2぀の穎は、1぀の穎ずしお数える。ただし、頂点のみで接しおいる2぀の穎は、別々の穎ずしお数える。 図1ず図2に、Sample Input 1ず2の図を瀺す。たず、図1においお、Aの䞉角圢ずBの䞉角圢は、頂点のみで接しおいるため、別々の穎ず数える。B...
37,732
Balls and Boxes 6 Balls Boxes Any way At most one ball At least one ball Distinguishable Distinguishable 1 2 3 Indistinguishable Distinguishable 4 5 6 Distinguishable Indistinguishable 7 8 9 Indistinguishable Indistinguishable 10 11 12 Problem You have $n$ balls and $k$ boxes. You want to put these balls into the boxes...
37,733
Score : 200 points Problem Statement Given is an integer N . Find the number of digits that N has in base K . Notes For information on base- K representation, see Positional notation - Wikipedia . Constraints All values in input are integers. 1 \leq N \leq 10^9 2 \leq K \leq 10 Input Input is given from Standard Input ...
37,734
がくのかんがえたさいきょうのおふずん あなたは新生掻に備えおふずんを N 枚買った i 番目のおふずんは s i のぬくもり䟛絊力をも぀ これから M 日間の気枩の予枬から j 日目には d j のぬくもり需芁が予想される ぬくもりが足りなくおも倚すぎおも快適さが損なわれるので j 日目に掛けおいるおふずんのぬくもり䟛絊力の総和ず d j の差の絶察倀を j 日目の䞍快床ず呌ぶこずにする この M 日分の䞍快床の合蚈ができるだけ少なくなるようにしたい ずころであなたの郚屋は残念ながらずおも狭くベッドず抌入れしかない そのためベッドにおふずんを 1 枚増やすにはそのずき抌入れの䞀番䞊にあるおふずんをベッドの䞀...
37,736
Score : 1000 points Problem Statement Ringo has a string S . He can perform the following N kinds of operations any number of times in any order. Operation i : For each of the characters from the L_i -th through the R_i -th characters in S , replace it with its succeeding letter in the English alphabet. (That is, repla...
37,737
Score : 100 points Problem Statement There is a simple directed graph G with N vertices, numbered 1, 2, \ldots, N . For each i and j ( 1 \leq i, j \leq N ), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j . If a_{i, j} = 1 , there is a directed edge from Vertex i to...
37,738
Score : 800 points Problem Statement There are N positive integers A_1, A_2, ..., A_N . Takahashi can perform the following operation on these integers any number of times: Choose 1 \leq i \leq N and multiply the value of A_i by -2 . Notice that he multiplies it by minus two. He would like to make A_1 \leq A_2 \leq ......
37,739
Score : 1100 points Problem Statement There are N white balls arranged in a row, numbered 1,2,..,N from left to right. AtCoDeer the deer is thinking of painting some of these balls red and blue, while leaving some of them white. You are given a string s of length K . AtCoDeer performs the following operation for each i...
37,740
Score : 400 points Problem Statement Your friend gave you a dequeue D as a birthday present. D is a horizontal cylinder that contains a row of N jewels. The values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values. In the beginning, you have no jewel in your hands. You ca...
37,741
Score : 100 points Problem Statement Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A. The problem has N test cases, all of which must be passed to get an AC verdict. Takahashi's submission has passed M cases out of the N test cases. Determine whether Takahashi's ...
37,742
Koch Curve Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n . The Koch curve is well known as a kind of fractals . You can draw a Koch curve in the following algorithm: Divide a given segment (p1, p2) into three equal segments. Replace the middle segment by the two si...
37,743
Score : 300 points Problem Statement We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i -th book from the top on Desk A (1 \leq i \leq N) , and B_i minutes to read the i -th book from the top on Desk B (1 \leq i \leq M)...
37,744
Max Score: $400$ Points Problem Statement Sample testcase 3 has a mistake, so we erased this case and rejudged all solutions of this problem. (21:01) Snuke got a sequence $a$ of length $n$ from AtCoder company. All elements in $a$ are distinct. He made a sequence $b$, but actually, he is not remembered it. However, he ...
37,745
Balls and Boxes 7 Balls Boxes Any way At most one ball At least one ball Distinguishable Distinguishable 1 2 3 Indistinguishable Distinguishable 4 5 6 Distinguishable Indistinguishable 7 8 9 Indistinguishable Indistinguishable 10 11 12 Problem You have $n$ balls and $k$ boxes. You want to put these balls into the boxes...
37,746
Score : 300 points Problem Statement There are N people living on a number line. The i -th person lives at coordinate X_i . You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate . If you choose to hold the meeting at coordinate P , the i -th person will spen...
37,747
倏合宿の朝は早い JAG倏合宿の朝は早い 正確にはそこたで早くないが早いず感じる参加者が倚いずいう 䟋幎合宿の䌚堎ずなる斜蚭では退去時に参加者がシヌツの回収や掃陀をしなければならない 1 ぀の郚屋でも退去が遅れるず来幎以降の斜蚭の利甚に関わるため参加者は䞀人たりずも寝坊しおはならない そうは蚀っおも皆人間寝坊するこずもある しかし起きた人が連絡先を知っおいる人にモヌニングコヌルをするこずで䞀人も寝坊しないよう努めるこずができるはずだ JAG倏合宿の運営を任されたあなたは寝坊を絶察に防ぐ手を打぀ための前準備ずしおどのくらいの確率で党員がきちんず起きられるのかを調べるこずにした 準備ずしおたず各参加者の...
37,748