975 - I2P(II)2016_Lee_Final Scoreboard

Time

2016/06/14 12:10:00 2016/06/14 15:10:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11055 Vector Intersection
11070 Move
11071 Simply Fractions (multiplication)
11072 I2P(II)2020 final exam Cheatsheet
11075 Binary Addition
11077 Queueing

11055 - Vector Intersection   

Description

Given two vectors of numbers, output their intersection set.

Note: the numbers of vectors need not to be unique.

Input

There are multiple test cases. Each case contains four lines. The first line begins with an integer N. The second line contains N integers, representing the numbers in the first set. The third line has one integer M, and the fourth line contains M integers, represent the numbers in the second set. All the numbers are 32 bit signed integers. The input is terminated if N = 0.

For case 1, 1 <= N, M <= 103
For case 2, 1 <= N, M <= 104
For case 3, 1 <= N, M <= 105
For case 4, 1 <= N, M <= 106

Output

For each test case, print the intersection of the two sets. Output them in ascending order. If the intersection of the two sets is an empty set, print “empty” (without quotes).

 

Note: There's a newline character at the end of each output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11070 - Move   

Description

There are N numbers in a queue.  The origin sequence is from 1 to N. (1 is the head). The operation “Move a ” means to move the first two numbers to the back of a without changing order. Note that if "a" is the first two numbers then you don't need to do anything. Given several such operations and output the final status of the sequence.

For example:N = 5,then the sequence will be 1 2 3 4 5.  If Move 3, the sequence will be 3 1 2 4 5. Since that the first two numbers is 1 2,you have to move 1 2 in the back of 3.

 

Input

There will be only one test case. The test case begins with an integer N indicating the number of people.  There are several operations followed.  The format is “Move a” (without quote).  The test case is terminated by “Exit” (without quote).

subtask 1 : 1<=N<=100, you can use O(N) algo for each operation.

subtask 2 : 1<=N<=100, you can use O(N) algo for each operation.

subtask 3 : 1<=N<=100000, you need use O(1) algo for each operation.

subtask 4 : 1<=N<=1000000, you need use O(1) algo for each operation.

Output

Output the numbers from the first one to the last one, and separate two consecutive numbers by a space. You DON'T need to print "\n" or space at the end of the line.

Sample Input  Download

Sample Output  Download

Tags

包柏



Discuss




11071 - Simply Fractions (multiplication)   

Description

Given several fractions, compute their product (multiplies all fractions) and express the answer in the simplest fraction form.

Input

There are many test cases in one subtask.

The first line of each test case contains an integer t, which indicates the number of fractions in the input. Each of the following t lines contains two integers a and b, which represent the numerator and the denominator of a fraction.

subtask 1 : t<=2. 1<=a,b<=10.
subtask 2 : t<=5. 1<=a,b<=10.
subtask 3 : t<=5. 1<=a,b<=50.
subtask 4 : t<=10. 1<=a,b<=100.

Output

Each test case outputs one line.

The output is the product reduced to the simplest fraction form. You need to print a '/' between the numerator and the denominator.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11072 - I2P(II)2020 final exam Cheatsheet   

Description

1. How to make cin faster?

std::ios_base::sync_with_stdio(false);

use '\n' instead of endl

2. An example of using <vector>

#include <iostream>

#include <vector>

#include <algorithm> // sort

int main ()

{

     std::vector<int> V;

     int x;

     while (std::cin>>x) {

          V.push_back(x);

     }

     for (auto t : V) std::cout<<" "<< t;

     std::cout << "\n";

     std::sort(V.begin(), V.end());

     for (auto t : V) std::cout<<" "<< t;

     std::cout << "\n";

}

 

3. An example of using <stringstream>

#include <string>
#include <iostream>
#include <sstream> // std::stringstream
int main () {

     std::stringstream ss;
     ss << "Hello " << 123;
     std::string s = ss.str();
     std::cout << s << '\n';
}

 

4. An example of using <set>
#include <iostream>
#include <set>
int main()
{
     std::set<int> S = {1, 2, 3, 4};
     auto search = S.find(2);
     if(search != S.end()) {
          std::cout << (*search) << '\n';
     }
     else {
          std::cout << "Not found\n";
     }

}

 

5. An example of using <stack>

#include <stack>
#include <iostream>
int main()
{
     std::stack<int> s;
     s.push( 3 ); s.push( 6 );
     s.push( 18 );
     std::cout<<s.size()<<" elements\n";
     std::cout<<"Top: "<< s.top()<< "\n";
     s.pop();
     std::cout<<s.size()<<" elements\n";
}

6. An example of getline()

#include <string>
#include <iostream>
int main()
{
     std::string name;
     std::cout << "What is your name? ";
     std::getline(std::cin, name);
     std::cout << "Hello "<< name<< "\n";
}

 

7. An example of using <map>

#include <iostream>
#include <string>
#include <map>
#include <utility> // make_pair
int main()
{
     std::map<std::string, int> ID;
     ID.insert(std::make_pair("Tom", 123));
     std::cout << ID["Tom"] << "\n";
}

Input

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss




11075 - Binary Addition   

Description

Compute the sum of two given N-bit binary numbers.

Input

The first line of the input file contains a positive integer T indicating the number of test cases. The first line of each test case is a positive integer N denoting the length of bits. The second and third lines are the two N-bit binary numbers. The first bit of each binary number is always 0, which guarantees that the sum of the two binary numbers can still be expressed as an N-bit binary number.

Level 1 : T<=100, N<=100
Level 2 : T<=200, N<=1000
Level 3 : T<=300, N<=5000
Level 4 : T<=400, N<=10000

Output

For each test case, your program should print the sum in the same format as the binary numbers given in input.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11077 - Queueing   

Description

You need to write a program to simulate a queue of names.  Each name is a string consisting of English letters only.  There are three operations:

1.         “Push [name]”, which means to enque name in the queue.

2.         “Pop”, which means to deque. If the queue is empty, this operation takes no effect.

3.         “Front”, which means to print out the name in the front of queue. If the queue is empty, print "empty" (without quotes).

 

Case1 : #operation <= 10^2, There will be no "Pop" and "Front" command when queue is empty.
Case2 : #operation <= 10^3. There will be no "Pop" and "Front" command when queue is empty.
Case3 : #operation <= 10^4.
Case4 : #operation <= 10^6.

Input

Each line contains one of the following operations. “Push [name]” (without quotes), “Pop” (without quotes), “Front”(without quotes). The length of each name is at most 10.

Output

For each “Front” operation, print out the name in the front of the queue. Note that you NEED to add a "\n" at the end. 

Sample Input  Download

Sample Output  Download

Tags




Discuss