2039 - I2P(II)2020_Lee_Mid2_Makeup Scoreboard

Time

2020/05/26 13:20:00 2020/05/26 15:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12799 Weak Palindromes 2
12800 Vector for Numbers

12799 - Weak Palindromes 2   

Description

In this problem, you're asked to sort some strings by how close it is to a palindrome (a string that reads the same from left and right). A string has greater distance (to becoming a palindrome) if it requires more changes:  replacing a character in the string with any other character.
 
For example: string "gggg" is already a palindrome, thus the distance is 0, while string "ow" has distance 1 (you can replace the 'o' with 'w' to make it a palindrome), and "ggy" also has distance 1.  
 
Given N strings, sort them by their distances ascendingly. If two strings have the same distances, compare them alphabetically. It is guaranteed that all strings in one input file are distinct.
 
weakpal is a class which has two member data: str (of type c++ std::string, the original string), dis (the distance). The container to store the "weakpal"s is a doubly linked list (List), in which each node contains a pointer to a weakpal object.
 
You need to implement the following functions in class weakpal:
1.  weakpal(const std::string & _str): the constructor that made from a string.
2. operator<(weakpal): comparing two weakpal objects, needed for sorting. 
 
You also need to implement the function List::insertNode(string), which inserts a weakpal to the List based on the input string.
 
*Alphabetical order (by Wikipedia's explanation): To determine which of two strings of characters comes first when arranging in alphabetical order, their first letters are compared. If they differ, then the string whose first letter comes earlier in the alphabet comes before the other string. If the first letters are the same, then the second letters are compared, and so on. If a position is reached where one string has no more letters to compare while the other does, then the first (shorter) string is deemed to come first in alphabetical order.

Input

Input format:

N
S_1
S_2
...
S_N

Input constraints:

1 <= N <= 1000
The length of every string will not exceed 20. Every string is distinct.

Output

S_sorted_1
S_sorted_2
...
S_sorted_N

(Print the strings in separate lines, sorted as requested in the problem description.)

Sample Input  Download

Sample Output  Download

Partial Judge Code

12799.cpp

Partial Judge Header

12799.h

Tags




Discuss




12800 - Vector for Numbers   

Description

Vectors are sequence containers representing arrays that can change in size.  The storage of the vector is handled automatically, being expanded and contracted as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additional memory is exhausted.

You need to implement the following functions for the vector of Numbers.  

void Vector::pop_back();
void Vector::push_back(std::string str);
void Vector::reserve(int new_capacity);
void Vector::resize(int new_size);
 
Number is an abstract class which has two derived classes: Integer and Float.  The input of push_back is a string, which may be an Integer or a floating point number, depending on whether there is a "." in the string.  For example, "123", "-345", "0" are Integers, and "3.14", "1.0", "0.01" are floating point numbers.  

If the value of size is equal to the value of capacity, and you need to change the value of capacity (reallocate memory) when you push_back a new element. The rule of increasing capacity is: new capacity = max(old capacity + 1, old capacity * 3).

The constructor of vector will not create an array (which means size and capacity is 0).

 

Input

There are six kinds of commands:

  • pop_back: removes the last element
  • push_back: adds an element to the end
  • capacity: returns the number of elements that can be held in currently allocated storage
  • size: returns the number of elements
  • reserve: reserves storage (Increase the capacity of the container to a value that's equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.)
  • resize: changes the number of elements stored (If the value of new size is greater than the value of old size, the value of new elements will be 0. If the value of new size is greater than the value of old capacity, the value of new capacity will be new size.)

Each commands is followed by a new line character ('\n').

Output

For commend "push_back", "pop_back", "reserve", and "resize", the contents of the Vector, which are either "I" or "F", will be printed.  For command "size", the size of the vector will be printed; and for "capacity", the capacity of the vector will be printed.  Before the termination of the entire program, the contents of the vector will be printed also. 

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

12800.cpp

Partial Judge Header

12800.h

Tags




Discuss