 Once Around the Lock

Problem Description
Most of us at one time or another have used a circular combination lock (think back to those glorious days in high school and your gym locker). Most combination locks consist of a dial with the numbers 0 through n1 printed on it in clockwise order. The dial can be turned either clockwise or counterclockwise, bringing one of the numbers to the top of the dial (if 0 is at the top of the dial, a turn of 1 in the counterclockwise direction would bring 1 to the top). Each lock has a three number code (x, y, z) and can only be opened after the following series of steps:
1. The lock dial must first be spun clockwise at least one full rotation, ending with the number x at the top (with no intervening counterclockwise turns). Note this could be accomplished with consecutive clockwise turns.
2. The lock must be turned counterclockwise until the number y appears at the top for the second time. Note this could be accomplished with consecutive counterclockwise turns (but no intervening clockwise turns).
3. The lock must then be turned clockwise until the number z appears on top, without going more than one full rotation. Note this could be accomplished with consecutive clockwise turns (but no intervening counterclockwise turns).
Any rotation after this last step will cause the lock to be closed again.
For this problem, you will be given a lock and a series of turns and you must determine at the end whether or not the lock is open. You should assume prior to the first turn that the lock has just been closed, and the dial spun counterclockwise until 0 is on top.Input
Input will consist of multiple test cases. The first line of each test case will contain four integers n x y z, indicating the number of digits on the lock’s dial and the threenumber combination (x, y and z will all be different and n <= 1000). The next line(s) will consist of a series of dial rotations of the form d s, where d is either C or CC (for clockwise or counterclockwise) and s (> 0) indicates how many numbers to spin through at the top of the dial. For example, if n = 50 and the current number on top of the dial is 4, the rotation CC 6 would bring the number 10 to the top, while a rotation of C 6 would bring 48 to the top. The series of dial rotations may extend over multiple lines, ending with the character ?. A line with a single 0 on it will follow the last test case.Output
For each problem instance, output a single line containing either the word Open or Closed, prefaced by the test case number as shown in the sample output.Sample Input
60 6 1 58
C 114 CC 115 C 3 ?
60 6 1 58
C 54 CC 115 C 3 ?
60 6 1 58
C 54 C 60 CC 115 C 3 ?
0Sample Output
Case 1: Open
Case 2: Closed
Case 3: Open
Agents _course
20171011Description The topsecret organization Agency of C.M. (The agency is so secretive that nobody is allowed to know what C.M. was supposed to mean. The most common interpretation  "Crazy Madmen"  is vehemently, but of course futilely, denied by leadership of the ACM.) was given a difficult mission. In order to complete the mission, all agents of ACM must be used. To make the situation worse, it is known that certain pairs of agents hate each other or simply do not work well together for some other reasons. Therefore to increase the efficiency, the leader of ACM has decided to split his subordinates to several teams, so that no such pair of agents belongs to the same team. The nature of the mission however makes it impossible to have more than three teams. At first this seemed to be an easy task, but he quickly noticed that there are some quite unpleasant persons in his organization. Such "bad guys" are of course necessary in this type of organizations, since there are tasks that simply cannot be solved in the "gentle" way. There used to be a lot more of them, but after recent reforms, the regulations only permit at most three (but at least one) such characters in the organization. Still, he found out that each normal (i.e. not bad guy) member of the organization hates at least one of these bad guys, which made him doubt that such a split is possible. Your task is to decide whether he is right with his doubts, or whether splitting the agents to at most three teams according to the criterion described above is possible. Input The input consists of several instances. The first line of each instance contains two integers 1 <= A <= 500 and R >= 0 separated by a single space. A is the number of agents in the organization. Agents are assigned integers between 0 and A  1. R is the number of pairs of agents that hate each other. The following R lines of the instance describe these pairs. Each of the lines contains two integers 0 <= a1, a2 < A separated by a single space, meaning that agents with numbers a1 and a2 hate each other. Every pair of agents that hate each other is described exactly once. An empty line follows each instance. The input is terminated by a line containing two zeros. Output The output consists of several lines. The ith line of the output corresponds to the ith input instance. If it is possible to split the agents in the instance to at most three teams, the corresponding output line describes such a split. If there are several possible splits, then only one (arbitrary) of them is described. The line contains A integers in {0, 1, 2} separated by single spaces, where the ith number is the number of the team to that the agent with number (i  1) is assigned. If it is not possible to split the agents in the instance so that no two persons in the same team hate each other, the corresponding output line consists of the string "The agents cannot be split". Sample Input 3 3 0 1 0 2 2 1 4 6 0 1 0 2 0 3 1 2 1 3 2 3 0 0 Sample Output 0 1 2 The agents cannot be split
spark 中rdd与dataframe的合并（join）_course
20160622以下是我写的代码： ``` /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // scalastyle:off println package com.shine.ncc import org.apache.spark.SparkConf import org.apache.spark.storage.StorageLevel import org.apache.spark.streaming.{Seconds, StreamingContext} import org.apache.spark.mllib.classification.NaiveBayesModel import org.apache.spark.rdd.RDD import org.apache.spark.streaming.Time import org.apache.spark.sql.SQLContext import org.apache.spark.SparkContext import org.apache.spark.ml.feature.Tokenizer import org.ansj.splitWord.analysis.ToAnalysis import org.ansj.util.FilterModifWord import java.util.Arrays import org.apache.spark.mllib.feature.HashingTF import scala.collection.JavaConversions._ import org.apache.spark.mllib.feature.IDF import org.apache.spark.mllib.feature.IDFModel import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Put import org.apache.hadoop.hbase.util.Bytes object NetworkNewsClassify1 { var sameModel = null /** Case class for converting RDD to DataFrame */ case class Record(content: String,time:String,title:String) /** Lazily instantiated singleton instance of SQLContext */ object SQLContextSingleton { @transient private var instance: SQLContext = _ def getInstance(sparkContext: SparkContext): SQLContext = { if (instance == null) { instance = new SQLContext(sparkContext) } instance } } def main(args: Array[String]) { // if (args.length < 2) { // System.err.println("Usage: NetworkWordCount <hostname> <port>") // System.exit(1) // } StreamingExamples.setStreamingLogLevels() // Create the context with a 1 second batch size val sparkConf = new SparkConf().setAppName("NetworkNewsClassify") sparkConf.setMaster("local[2]"); val ssc = new StreamingContext(sparkConf, Seconds(1)) // Create a socket stream on target ip:port and count the 获取json信息 val lines = ssc.socketTextStream("localhost", 9999, StorageLevel.MEMORY_AND_DISK_SER) val myNaiveBayesModel = NaiveBayesModel.load(ssc.sparkContext, "D:/myNaiveBayesModel") //将接送转换成rdd lines.foreachRDD((rdd: RDD[String], time: Time) => { // Get the singleton instance of SQLContext val sqlContext = SQLContextSingleton.getInstance(rdd.sparkContext) import sqlContext.implicits._ val newsDF = sqlContext.read.json(rdd) newsDF.count(); val featurizedData = newsDF.map{ line => val temp = ToAnalysis.parse(line.getAs("title")) //加入停用词 FilterModifWord.insertStopWords(Arrays.asList("r","n")) //加入停用词性???? FilterModifWord.insertStopNatures("w",null,"ns","r","u","e") val filter = FilterModifWord.modifResult(temp) //此步骤将会只取分词，不附带词性 val words = for(i<Range(0,filter.size())) yield filter.get(i).getName //println(words.mkString(" ; ")); //计算每个词在文档中的词频 new HashingTF(500000).transform(words) }.cache() if(featurizedData.count()>0){ //计算每个词的TFIDF val idf = new IDF() val idfModel = idf.fit(featurizedData) val tfidfData = idfModel.transform(featurizedData); //分类预测 val resultData = myNaiveBayesModel.predict(tfidfData) println(resultData) //将result结果与newsDF信息join在一起 //**??? 不会实现了。。。** //保存新闻到hbase中 } }) ssc.start() ssc.awaitTermination() } } ``` 其中newsDF是新闻信息，包含字段（title，body，date），resultData 是通过贝叶斯模型预测的新闻类型，我现在希望把result结果作为一个type字段与newsDF合并（join），保存到hbase中，这个合并的操作怎么做呢
Direct Subtraction _course
20170228Statement of the Problem Some algorithms on image processing are more efficient when applied to small patterns, such as 3 x 3 matrices. One way of decomposing a given figure into small components is to apply the operation of direct subtraction, which is described in the following. Given a 0/1 matrix Amxm and a 0/1 matrix B3x3 we define the matrix C(m2)x(m2) = A  B obtained in the following way: We call matrix C a valid direct subtraction of B from A if for every aij = 1 in matrix A, there is a 1 in matrix C which results from a subtraction of B from a submatrix of A containing aij, and the element of B which is subtracted from aij is equal to 1. Example: Given matrices A and B, the direct subtraction C = A  B is valid and is given by Now, given matrices A and B, The direct subtraction C = A  B is not valid and is given by The objective of this problem is to determine if a matrix A can be transformed into a 3 x 3 matrix through a sequence of valid direct subtractions of, possibly different, 3 x 3 matrices. Input Format Several input instances are given. Each instance begins with the dimension 0 < n < 20 of the matrix to be decomposed. The following n lines describe the rows of that matrix, as a sequence of n 0's and 1's, with no blank spaces between them. The input ends with a line with a single 0. Output Format For each input instance your program must identify it by printing Instance i: (where i is the number of the instance) and, in the next line a message Yes or No for the case, resp. that the matrix is (resp. is not) decomposable. Sample Input 5 01010 11111 01111 00111 00010 5 10001 00000 00100 00000 10001 0 Sample Output Instance 1: Yes Instance 2: No
The Alphabet Game _course
20171015Description Little Dara has recently learned how to write a few letters of the English alphabet (say k letters). He plays a game with his little sister Sara. He draws a grid on a piece of paper and writes p instances of each of the k letters in the grid cells. He then asks Sara to draw as many sidetoside horizontal and/or vertical bold lines over the grid lines as she wishes, such that in each rectangle containing no bold line, there would be p instances of one letter or nothing. For example, consider the sheet given in Figure 1, where Sara has drawn two bold lines creating four rectangles meeting the condition above. Sara wins if she succeeds in drawing the required lines. Dara being quite fair to Sara, wants to make sure that there would be at least one solution to each case he offers Sara. You are to write a program to help Dara decide on the possibility of drawing the right lines. ![](http://poj.org/images/1231_1.jpg) Input The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case consists of two integers k (1 <= k <= 26), the number of different letters, and p (1 <= p <= 10), the number of instances of each letter. Followed by the first line, there are k lines, one for each letter, each containing p pairs of integers (xi, yi) for 1 <= i <= p. A pair indicates coordinates of the cell on the paper where one instance of the letter is written. The coordinates of the upper left cell of the paper is assumed to be (1,1). Coordinates are positive integers less than or equal to 1,000,000. You may assume that no cell contains more than one letter. Output There should be one line per test case containing a single word YES or NO depending on whether the input paper can be divided successfully according to the constraints stated in the problem. Sample Input 2 3 2 6 4 8 4 4 2 2 1 2 3 2 4 3 3 1 1 3 1 5 1 2 1 4 1 6 1 2 2 4 2 8 1 Sample Output YES NO
Herbalists _course
20170901A group of herbalists has decided to move to a new village on the boundary of a huge forest. The arrangement of houses and paths in the village turned out to be a major problem: Many of the herbalists are friends and want to visit each other often, so they want to have a path between their houses. However the herbalists are also known for quarreling with everyone else. To avoid the chance of meeting with someone they do not like, it is required that no two paths intersect  there should be no crossroads in the village (And of course also no other means of crossing; overpasses spoil the scenery and underpasses destroy the root systems of precious herbs.) . Each herbalist also wants to be able to visit the forest, of course without having to cross any path  i.e., it is also necessary to make it possible to get from each house to "infinity" without crossing a path. You are given a description of the relationships between herbalists. Your task is to decide whether such an ideal village can be built. Input The input consists of several instances. The first line of each instance contains two integers 1 <= H <= 10 000 and F >= 0 separated by a single space. H is the number of herbalists. The herbalists have assigned integers between 0 and H  1. F is the number pairs of friends. The following F lines of the instance describe the pairs of friends. Each of the lines contains two integers 0 <= h1, h2 < H separated by a single space, meaning that herbalists with numbers h1 and h2 are friends. Each pair of friends is described exactly once. The instances follow each other immediately, without any separator. The input is terminated by a line containing two zeros. Output The output consists of several lines. The ith line of the output corresponds to the ith instance. If it is possible to build a village for the corresponding input instance, the output line consists of "Yes, village can be built" string. If it is not possible to build such a village, the output line consists of "No, village cannot be built" string. Sample Input 3 3 0 1 0 2 1 2 4 6 0 1 0 2 0 3 1 2 1 3 2 3 0 0 Sample Output Yes, village can be built No, village cannot be built
Boatherds _course
20161213Description Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on their way down to the lowlands they gradually join and finally the single resulting river flows to the sea. Moreover, the Trabantian villages are exactly at the rivers' springs, junctions and at the mouth of the largest river. Please note that more than 2 rivers can join at a junction. However, the rivers always form a tree (with villages as vertices). The pricing policy of the Boatherds is very simple: each segment of each river between two villages is assigned a price (the price is same in both directions), so if a tourist requests a journey between any two villages, the ticket office clerks just add the prices of the segments along the only path between the villages. One day, a very strange tourist appeared. She told the clerks that she returns to her country on the next day and she wants to spend all the remaining money on a boat trip, so they should find a route with exactly this cost. Being just poor (ahem) businessmen, they have asked the Abacus Calculator Makers for help. You are given a description of the river network with costs of river segments and a sequence of integers x1,..., xk. For each xi, you should determine if there is a pair of cities (a, b) in the river network such that the cost of the trip between a and b is exactly xi. Input The input consists of several instances. Each instance is described by (in the following order): A single line containing a single integer: the number of villages N (1 <= N <= 10 000). N lines describing the villages. The ith of these lines (1 <= i <= N) describes the village with number i. It contains space separated integers d1, c1, d2, c2, , dki, cki, 0. The dj's are numbers of villages from which the rivers flow directly to the village i (with no other villages in between), each cj is the price of the journey between villages i and dj. Moreover, 2 <= dj <= N and 0 <= cj <= 1 000. Village 1 always corresponds to the mouth of the largest river, therefore no di can ever be equal to 1. M <= 100 lines describing the queries. The ith of these lines corresponds to the ith query and contains a single integer xi (1 <= xi <= 10 000 000). The instance is finished by a single line containing the number 0. The whole input is ended by a single line containing the number 0. Output For each instance you should produce a sequence of M lines (where M is the number of queries in the particular instance). The ith of these lines contains the word "AYE" if there exists a pair of cities in the river network which is connected by a path of cost xi, or the word "NAY" otherwise. Output for each instance must be followed by a single line containing just the dot character. Sample Input 6 2 5 3 7 4 1 0 0 5 2 6 3 0 0 0 0 1 8 13 14 0 0 Sample Output AYE AYE NAY AYE .
Galactic Breakup _course
20171011Description After ruling a large chunk of the Milky Way for millennia, the Cosmic OBsolescent OLigarchy is finally breaking up into a collection of independent monarchies. COBOL is a very organized empire and takes the shape of a gigantic cube with dimensions n by m by k parsecs. (COBOL is also very secretive, so only a few know the exact values of n, m and k.) To facilitate the control of the empire it is partitioned into nmk smaller dominions, each 1 cubic parsec in size. These dominions are numbered as follows: ![](http://poj.org/images/1235_1.jpg) Each independent monarchy is a connected collection of one or more dominions (a dominion is connected to another if they share a face) and over a period of several imperial months, one monarchy per month will secede from the empire. Each secession begins at the first day of the month. One concern of COBOL is that during the breakup, various parts of the remaining empire may become disconnected from one another, which could hamper the administration of what's left of the empire. Your job is to determine the number of months of the breakup during which the empire is disconnected. Input Input will consist of multiple problem instances. The first line will contain a positive integer indicating the number of problem instances to follow. The first line of each problem instance will contain four integers: n m k l, where n, m and k are as described above, with 1 <= n, m, k <= 30, and l is the number of independent monarchies which the empire is being divided into. Following this will be l lines defining the monarchies. Each will have the form p d1 d2 d3 . . . dp, where p is the number of dominions making up the monarchy (1 <= p <= 20), and d1, . . . , dp are the dominions. The monarchies are listed in the order in which they will secede from the empire. Output Output for each problem instance should consist of a single integer on a line, indicating the number of months which the empire was disconnected. Sample Input 2 2 2 3 9 2 4 5 3 6 8 10 1 7 1 2 1 11 1 9 1 1 1 0 1 3 2 2 3 3 4 0 1 2 3 4 4 5 6 7 4 8 9 10 11 Sample Output 4 0
Electricity _course
20170901Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them supplying a small area that surrounds it. This organization brings a lot of problems  it often happens that there is not enough power in one area, while there is a large surplus in the rest of the country. ACM++ has therefore decided to connect the networks of some of the plants together. At least in the first stage, there is no need to connect all plants to a single network, but on the other hand it may pay up to create redundant connections on critical places  i.e. the network may contain cycles. Various plans for the connections were proposed, and the complicated phase of evaluation of them has begun. One of the criteria that has to be taken into account is the reliability of the created network. To evaluate it, we assume that the worst event that can happen is a malfunction in one of the joining points at the power plants, which might cause the network to split into several parts. While each of these parts could still work, each of them would have to cope with the problems, so it is essential to minimize the number of parts into which the network will split due to removal of one of the joining points. Your task is to write a software that would help evaluating this risk. Your program is given a description of the network, and it should determine the maximum number of nonconnected parts from that the network may consist after removal of one of the joining points (not counting the removed joining point itself). Input The input consists of several instances. The first line of each instance contains two integers 1 <= P <= 10 000 and C >= 0 separated by a single space. P is the number of power plants. The power plants have assigned integers between 0 and P  1. C is the number of connections. The following C lines of the instance describe the connections. Each of the lines contains two integers 0 <= p1, p2 < P separated by a single space, meaning that plants with numbers p1 and p2 are connected. Each connection is described exactly once and there is at most one connection between every two plants. The instances follow each other immediately, without any separator. The input is terminated by a line containing two zeros. Output The output consists of several lines. The ith line of the output corresponds to the ith input instance. Each line of the output consists of a single integer C. C is the maximum number of the connected parts of the network that can be obtained by removing one of the joining points at power plants in the instance. Sample Input 3 3 0 1 0 2 2 1 4 2 0 1 2 3 3 1 1 0 0 0 Sample Output 1 2 2
Molecular Formula _course
20161215Description Your mission in this problem is to write a computer program that manipulates molecular formulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality. The following are the definitions of atomic symbols and molecular formulae you should consider. An atom in a molecule is represented by an atomic symbol, which is either a single capital letter or a capital letter followed by a small letter. For instance H and He are atomic symbols. A molecular formula is a nonempty sequence of atomic symbols. For instance, HHHeHHHe is a molecular formula, and represents a molecule consisting of four H's and two He's. For convenience, a repetition of the same subformula X...X, where n is an integer between 2 and 99 inclusive, can be abbreviated to (X)n. Parentheses can be omitted if X is an atomic symbol. For instance, HHHeHHHe is also written as H2HeH2He, (HHHe)2, (H2He)2, or even ((H)2He)2. The set of all molecular formulae can be viewed as a formal language. Summarizing the above description, the syntax of molecular formulae is defined as follows. Molecule > Atom  Atom Number  ( Molecule ) Number  Molecule Molecule Atom > CapitalLetter  CapitalLetter SmallLetter Number > 2  3  4  . . .  97  98  99 CapitalLetter > A  B  C  . . .  X  Y  Z SmallLetter > a  b  c  . . .  x  y  z Each atom in our virtual chemistry has its own atomic weight. Given the weights of atoms, your program should calculate the weight of a molecule represented by a molecular formula. The molecular weight is defined by the sum of the weights of the constituent atoms. For instance, assuming that the atomic weights of the atoms whose symbols are H and He are 1 and 4, respectively, the total weight of a molecule represented by (H2He)2 is 12. Input The input consists of two parts. The first part, the Atomic Table, is composed of a number of lines, each line including an atomic symbol, one or more spaces, and its atomic weight which is a positive integer no more than 1000. No two lines include the same atomic symbol. The first part ends with a line containing only the string END_OF_FIRST_PART. The second part of the input is a sequence of lines. Each line is a molecular formula, not exceeding 80 characters, and contains no spaces. A molecule contains at most 10^5 atoms. Some atomic symbols in a molecular formula may not appear in the Atomic Table. The sequence is followed by a line containing a single zero, indicating the end of the input. Output The output is a sequence of lines, one for each line of the second part of the input. Each line contains either an integer, the molecular weight for a given molecular formula in the corresponding input line if all its atomic symbols appear in the Atomic Table, or UNKNOWN otherwise. No extra characters are allowed. Sample Input H 1 He 4 C 12 O 16 F 19 Ne 20 Cu 64 Cc 333 END_OF_FIRST_PART H2C (MgF)2As Cu(OH)2 H((CO)2F)99 0 Sample Output 14 UNKNOWN 98 7426
Mr. Young's Picture Permutations _course
20171015Description Mr. Young wishes to take a picture of his class. The students will stand in rows with each row no longer than the row behind it and the left ends of the rows aligned. For instance, 12 students could be arranged in rows (from back to front) of 5, 3, 3 and 1 students. X X X X X X X X X X X X In addition, Mr. Young wants the students in each row arranged so that heights decrease from left to right. Also, student heights should decrease from the back to the front. Thinking about it, Mr. Young sees that for the 12student example, there are at least two ways to arrange the students (with 1 as the tallest etc.): 1 2 3 4 5 1 5 8 11 12 6 7 8 2 6 9 9 10 11 3 7 10 12 4 Mr. Young wonders how many different arrangements of the students there might be for a given arrangement of rows. He tries counting by hand starting with rows of 3, 2 and 1 and counts 16 arrangements: 123 123 124 124 125 125 126 126 134 134 135 135 136 136 145 146 45 46 35 36 34 36 34 35 25 26 24 26 24 25 26 25 6 5 6 5 6 4 5 4 6 5 6 4 5 4 3 3 Mr. Young sees that counting by hand is not going to be very effective for any reasonable number of students so he asks you to help out by writing a computer program to determine the number of different arrangements of students for a given set of rows. Input The input for each problem instance will consist of two lines. The first line gives the number of rows, k, as a decimal integer. The second line contains the lengths of the rows from back to front (n1, n2,..., nk) as decimal integers separated by a single space. The problem set ends with a line with a row count of 0. There will never be more than 5 rows and the total number of students, N, (sum of the row lengths) will be at most 30. Output The output for each problem instance shall be the number of arrangements of the N students into the given rows so that the heights decrease along each row from left to right and along each column from back to front as a decimal integer. (Assume all heights are distinct.) The result of each problem instance should be on a separate line. The input data will be chosen so that the result will always fit in an unsigned 32 bit integer. Sample Input 1 30 5 1 1 1 1 1 3 3 2 1 4 5 3 3 1 5 6 5 4 3 2 2 15 15 0 Sample Output 1 1 16 4158 141892608 9694845
Translations _course
20170906Bob Roberts is in charge of performing translations of documents between various languages. To aid him in this endeavor his bosses have provided him with translation files. These files come in twos  one containing sample phrases in one of the languages and the other containing their translations into the other language. However, some overzealous underling, attempting to curry favor with the higherups with his initiative, decided to alphabetically sort the contents of all of the files, losing the connections between the phrases and their translations. Fortunately, the lists are comprehensive enough that the original translations can be reconstructed from these sorted lists. Bob has found this is most usually the case when the phrases all consist of two words. For example, given the following two lists: Language 1 Phrases Language 2 Phrases arlo zym bus seat flub pleve bus stop pleve dourm hot seat pleve zym school bus Bob is able to determine that arlo means hot, zym means seat, flub means school, pleve means bus, and dourm means stop. After doing several of these reconstructions by hand, Bob has decided to automate the process. And if Bob can do it, then so can you. Input Input will consist of multiple input sets. Each input set starts with a positive integer n <= 250, indicating the number of twoword phrases in each language. This is followed by 2n lines, each containing one twoword phrase: the first n lines are an alphabetical list of phrases in the first language, and the remaining n lines are an alphabetical list of their translations into the second language. Only upper and lower case alphabetic characters are used in the words. No input set will involve more than 25 distinct words. No word appears as the first word in more than 10 phrases for any given language; likewise, no word appears as the last word in more than 10 phrases. A line containing a single 0 follows the last problem instance, indicating end of input. Output For each input set, output lines of the form word1/word2 where word1 is a word in the first language and word2 is the translation of word1 into the second language, and a slash separates the two. The output lines should be sorted according to the first language words, and every first language word should occur exactly once. There should be no white space in the output, apart from a single blank line separating the outputs from different input sets. Imitate the format of the sample output, below. There is guaranteed to be a unique correct translation corresponding to each input instance. Sample Input 4 arlo zym flub pleve pleve dourm pleve zym bus seat bus stop hot seat school bus 2 iv otas otas re ec t eg ec 0 Sample Output arlo/hot dourm/stop flub/school pleve/bus zym/seat iv/eg otas/ec re/t
Ticket to Ride _course
20170523Problem Description Ticket to Ride is a board game for up to 5 players. The goal of the game is to set up train lines (and to thwart the opponents’ attempts at setting up their train lines). At the beginning of play, each player is assigned four train lines. A player may choose to discard as many of these four assignments as she likes. Each assignment has a score, corresponding to its difficulty (so, typically, a train line between e.g. Stockholm and Tokyo would be worth more than a train line between e.g. Stockholm and Utrecht). At the end of the game, each player gets points for the assignments that they have successfully completed, and penalty points for the assignments that they have failed to complete. An assignment consists of a pair of cities that are to be connected by a series of shorter railway routes. A route can be claimed (for a certain cost associated with the route), but things are complicated by the fact that there is only a limited number of routes, and once a player claims a route, none of the other players can claim it. A player has successfully set up a train line between two cities if there is a path between the two cities using only routes that have been claimed by this player. For simplicity, we will ignore all additional aspects of the game (including the actual process of claiming routes and additional ways to score points). For instance, if your assignment is to connect Stockholm and Amsterdam in the Figure above, you would probably want to claim the routes between Stockholm and Copenhagen, and between Copenhagen and Amsterdam. But if another player manages to claim the route between Copenhagen and Stockholm before you, your train line would have to use some other routes, e.g. by going to Copenhagen via Oslo. In this problem, we will consider the rather bold strategy of trying to complete all four assignments (typically, this will be quite hard). As a preliminary assessment of the difficulty of achieving this, we would like to calculate the minimum cost of setting up all four lines assuming that none of the other players interfere with our plans. Your job is to write a program to determine this minimum cost. Input The input consists of several (at most 20) games to be analyzed. Each game starts with two integers 1 <= n <= 30, 0 <= m <= 1 000, giving the number of cities and railway routes in the map, respectively. Then follow n lines, giving the names of the n cities. City names are at most 20 characters long and consist solely of lower case letters (’a’’z’). After this follow m lines, each containing the names of two different cities and an integer 1 <= c <= 10 000, indicating that there is a railway route with cost c between the two cities. Note that there may be several railway routes between the same pair of cities. You may assume that it is always possible to set up a train line from any city to any other city. Finally, there will be four lines, each containing the names of two cities, giving the four train line assignments. The input is terminated by a case where n = m = 0. This case should not be processed. Output For each game, output a single line containing a single integer, the minimum possible cost to set up all four train lines. Sample Input 10 15 stockholm amsterdam london berlin copenhagen oslo helsinki dublin reykjavik brussels oslo stockholm 415 stockholm helsinki 396 oslo london 1153 oslo copenhagen 485 stockholm copenhagen 522 copenhagen berlin 354 copenhagen amsterdam 622 helsinki berlin 1107 london amsterdam 356 berlin amsterdam 575 london dublin 463 reykjavik dublin 1498 reykjavik oslo 1748 london brussels 318 brussels amsterdam 173 stockholm amsterdam oslo london reykjavik dublin brussels helsinki 2 1 first second first second 10 first first first first second first first first 0 0 Sample Output 3907 10
Spark提交作业为什么一定要conf.setJars()，它的具体作用到底是什么?_course
20181014代码如下： ``` package wordcount import org.apache.spark.SparkContext import org.apache.spark.SparkConf import org.apache.spark.sql.SparkSession import org.apache.spark.rdd.RDD object WordCount extends App { val conf = new SparkConf() //就是这里，为什必须要有它，它的具体作用到底是啥？ .set("spark.jars", "src/main/resources/sparkcore.jar,") .set("spark.app.name", "WordCount") .set("spark.master", "spark://master:7077") .set("spark.driver.host", "win") .set("spark.executor.memory", "512M") .set("spark.eventLog.enabled", "true") .set("spark.eventLog.dir", "hdfs://master:9000/spark/history") val sc=new SparkContext(conf) val lines:RDD[String]=sc.textFile("hdfs://master:9000/user/dsf/wordcount_input") val words:RDD[String]=lines.flatMap(_.split(" ")) val wordAndOne:RDD[(String,Int)]=words.map((_,1)) val reduce:RDD[(String,Int)]=wordAndOne.reduceByKey(_+_) val sorted:RDD[(String,Int)]=reduce.sortBy(_._2, ascending=false,numPartitions=1) sorted.saveAsTextFile("hdfs://master:9000/user/dsf/wordcount_output") println("\ntextFile: "+lines.collect().toBuffer) println("flatMap: "+words.collect().toBuffer) println("map: "+wordAndOne.collect().toBuffer) println("reduceByKey: "+reduce.collect().toBuffer) println("sortBy: "+sorted.collect().toBuffer) sc.stop() } /** 在Linux终端运行此应用的命令行: sparksubmit \ master spark://master:7077 \ class wordcount.WordCount \ sparkcore.jar */ ``` 如果没有.set("spark.jars", "src/main/resources/sparkcore.jar,")这段代码，它会报这个异常： ``` Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 4 times, most recent failure: Lost task 0.3 in stage 0.0 (TID 6, 192.168.1.15, executor 0): java.lang.ClassCastException: cannot assign instance of scala.collection.immutable.List$SerializationProxy to field org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$dependencies_ of type scala.collection.Seq in instance of org.apache.spark.rdd.MapPartitionsRDD ``` ![这是我在Spark官网找到的：](https://imgask.csdn.net/upload/201810/14/1539507421_95226.jpg) 翻译过来是： spark.jars: 以逗号分隔的本地jar列表，包含在驱动程序和执行程序类路径中。 按照官网的意思，是Driver和Excutor都应该有程序的jar包，可我不明白它的具体原理，哪位好心人给讲解一下，谢谢！
 24.39MB
c++学习资料汇总
20130801包括： 高质量C++_C编程指南.pdf C+++Primer中文非扫描版.pdf C++程序员必备常识.pdf Effective C++.chm More+Exceptional+C++.chm
C++语言基础视频教程
20150301C++语言基础视频培训课程：本课与主讲者在大学开出的程序设计课程直接对接，准确把握知识点，注重教学视频与实践体系的结合，帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识；主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础（可以利用本人开出的《C语言与程序设计》系列课学习）。学习者能够通过实践的方式，学会利用C++语言解决问题，具备进一步学习利用C++开发应用程序的基础。
 上次挂在了京东Java二面不服气， 三月之期已到，这次终于拿下offer！ 680620201020前言 这话要从三个月前说起：当时一名水友告诉我想要跳槽去京东，然后我就本着推波助澜，为粉丝打气的心态（也可能是看热闹不嫌事儿大？）就支持他一定要去，梦想一定要有，没准儿就实现了呢？ 没想到直接凉凉！ 以下为第一次京东二面凉经 京东一面凉经 object的方法，7大方法 synchronized方法讲解 synchronized方法实现原理 volatile关键字的原理 锁的分类 偏向锁讲解 NoClassDefFoundError和ClassNotFoundException的区别 追问，ClassN
 11KB
北航计组P0Logisim简单部件与状态机
20181231使用Logisim搭建一个除数为四位，原数据帧为8位的CRC校验码计算电路；一个四位运算单元ALU；一个GRF；一个Melay型有限状态机 检测串行输入字符串中的能匹配正则表达式b{1,2}{2}的子
 153.58MB
2020HW工具包.zip
20200923各位亲觉得工具包怎么样
 117B
Keil5安装包
20190523Keil5安装包，附带STM31F1、STM32F4支持包以及破解软件。
Java进阶高手课Java基础编程提升
20200427课程聚焦Java基础编程提升的核心知识点，以真实场景项目实战为导向，循序渐进，深入浅出的了解Java基础编程，讲解Java这门使用广泛的编程语言，助你能够游刃有余地游走在这些技术之中。
 38.68MB
2019数学建模历年题目及优秀论文
201904022019数学建模历年题目及优秀论文 ，好资源与大家分享！！
Java8零基础入门视频教程
20160929这门课程基于主流的java8平台，由浅入深的详细讲解了java SE的开发技术，可以使java方向的入门学员，快速扎实的掌握java开发技术！
 65.8MB
java源码包java 源码 大量 实例
20130418Applet钢琴模拟程序java源码 2个目标文件，提供基本的音乐编辑功能。编辑音乐软件的朋友，这款实例会对你有所帮助。 Calendar万年历 1个目标文件 EJB 模拟银行ATM流程及操作源代码
21天通关Python（仅视频课）
20190521本页面购买不发书！！！仅为视频课购买！！！ 请务必到https://edu.csdn.net/bundled/detail/49下单购买课+书。 本页面，仅为观看视频页面，如需一并购买图书，请务必到https://edu.csdn.net/bundled/detail/49下单购买课程+图书！！！ 疯狂Python精讲课程覆盖《疯狂Python讲义》全书的主体内容。 内容包括Python基本数据类型、Python列表、元组和字典、流程控制、函数式编程、面向对象编程、文件读写、异常控制、数据库编程、并发编程与网络编程、数据可视化分析、Python爬虫等。 全套课程从Python基础开始介绍，逐步步入当前就业热点。将会带着大家从Python基础语法开始学习，为每个知识点都提供对应的代码实操、代码练习，逐步过渡到文件IO、数据库编程、并发编程、网络编程、数据分 析和网络爬虫等内容，本课程会从小案例起，至爬虫、数据分析案例终、以Python知识体系作为内在逻辑，以Python案例作为学习方式，最终达到“知行合一”。
 12.91MB
2020双十一淘宝自动领喵币
202010212020最新双十一自动领喵币 1、打开Auto.js（该软件的相关用法就不细说了，无障碍，悬浮窗权限这些），右下角导入脚本 2、打开淘宝，进入活动页面，点开任务列表界面 3、点击Auto.js悬浮窗，
MySQL基础入门视频课程
20181127本课程从零开始，以通俗易懂的方式讲解MySQL技术，手把手教你掌握每一个知识点。课程中使用的所有英文单词都会逐一查询并记录，真正做到零基础入门学习，适合初学者的教程！ 课程内容包括： 1.MySQL简介、安装MySQL 2.查询操作 3.聚合函数和分组统计 4.更新操作 5.表和库的管理 6.约束 7.用户和权限管理 8.事务处理 教学全程采用笔记+代码案例的形式讲解，通俗易懂！！！
 下载 浅谈轻量级js模板引擎simplite
 下载 jQuery EasyUI datagrid实现本地分页的方法
 学院 SkyEye智慧眼系统搭建 一
 学院 JavaWeb家具家居购物商城毕业设计 大学生毕业设计教学视频
 下载 现场总线在电力远程监测管理系统中的应用
 学院 轻松学习单片机
 学院 saprk大数据分析与实战zookeeper
 下载 nodejs事件的监听与触发的理解分析
 学院 C#之面向对象
 下载 单芯片DCDC变换器在CPU电源控制系统中的应用
 学院 PowerDesigner数据库设计与建模
 博客 #1024程序员节#之最近感想....
 下载 jQuery向后台传入json格式数据的方法
 学院 JVM从入门到入魔
 学院 Spring核心原理面试训练营（停止报名）
 下载 javascript转换日期字符串为Date日期对象的方法
 下载 Hf荧光灯电子镇流器的评价
 博客 Bone Collector II HDU  2639
 博客 2020.10.24日记
 下载 linux下实现定时执行php脚本
 博客 View的工作流程onMeasure
 下载 VRS51L3074与串行FRAM在LED显示屏中的应用
 博客 yum安装nginx
 下载 PHP实现获取FLV文件的时间
 学院 STM32智能浇花系统从0到1开发实战
 博客 20201024小记
 下载 浅析javascript中函数声明和函数表达式的区别
 博客 03Java核心类库_枚举、注解与反射
 下载 节能型视频监控终端的设计
 博客 浙江农林大学第十九届程序设计竞赛暨天梯赛选拔赛（同步赛）训练记录