1488 - I2P (II) 2018_make up (Fri.) Scoreboard

Time

2018/06/29 09:30:00 2018/06/29 12:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11335 Josephus Problem using doubly circular linked list
11388 Evaluate expression
11485 Use std::set
11935 double-end-queue

11335 - Josephus Problem using doubly circular linked list   

Description

Based on the original Josephus Problem introduced in class, an additional rule of this problem is to change

direction of counting after killing a person.  For example, there are 8 people, numbered 1 to 8, in a circle

and arranged in clockwise.  The step to kill is 3. 

The sequence of killing people is

1, 2, 3 (kill 3, change the direction to counter-clockwise)

2, 1, 8 (kill 8, change the direction to clockwise)

1, 2, 4 (kill 4, change the direction to counter-clockwise)

2, 1, 7 (kill 7, change the direction to clockwise)

1, 2, 5 (kill 5, change the direction to counter-clockwise)

2, 1, 6 (kill 6, change the direction to clockwise)

1, 2, 1 (kill 1)

 

So the person numbered 2 is the survivor.

 

You're asked to solve this problem using circular linked list.

You will be provided with main.c and function.h, and you need to implement function.c.

 

Note there is a time limit to solve this problem: 3 seconds.

Input

The input has two integers, n and m, where n is the number of total people, and m is the step to kill.

Output

The output is an integer: the survivor's number.  There is a newline after that.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11335.c

Partial Judge Header

11335.h

Tags




Discuss




11388 - Evaluate expression   

Description

Given a prefix Boolean expression, which only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. Also given the values of ‘A’, ‘B’, ‘C’, and ‘D’. Please evaluate the value of the prefix Boolean expression.

For example, if the expression is "|&AC|AB" and, A, B, C, D are 0, 1, 0, 1 then the result will be 1.

Input

The input contains 2 lines.

The first line contains a prefix Boolean expression. It only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. The length of the prefix expression is shorter than 30.

The second line contains 4 values of 1 or 0, representing the values of A, B, C, D respectively. Each is separated by a space.

Output

Print out the value of the prefix Boolean expression. There should be no trailing newline character at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11485 - Use std::set   

Description

This problem will help you understand how to use std::set and comparator.

e.g., std::set<std::vector<int>>

http://en.cppreference.com/w/cpp/container/set

Input

How to compare the integer sequence (calculate the key of an integer sequence):

  • get the length of integer sequence (size)
  • key value=[first element]*(size)+[second element]*(size-1)+[third element]*(size-2)+...+[last element]*1
  • compare the key value. Small key value is smaller.
  • if the length of a integer sequence is 0, the key value is 0.
  • e.g., the key of an integer sequence "3 9 -1 3 -6" is 48 (3*5+9*4+(-1)*3+3*2+(-6)*1)

 

The input consist of series of command. Each commands is insert, range_out or output.

​insert: inserts an integer sequence (each value is greater than -6 and smaller than 11, stop reading from cin when value is 0). If the key has already existed, then

  • output "exist\n"
  • erase the integer sequence from set
  • reverse the integer sequence (from input)
  • insert the reversed integer sequence

For example,

insert 3 9 -1 3 -6 0

The set should contain 3 9 -1 3 -6.

insert 9 -2 6 6 0

The set should contain 6 6 -2 9.


range_out: outputs all integer sequences from the integer sequence (first key) to the integer sequence (second key) of set (including the second key). First key and second key are read from input (each value is greater than -6 and smaller than 11, stop reading from cin when value is 0).

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

insert 10 10 10 2 0

range_out -5 0 10 9 2 0

It should output

3 9 -1 3 -6

7 6 1 2

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

insert 10 10 10 2 0

range_out -5 0 10 10 10 0

It should output

3 9 -1 3 -6

7 6 1 2

 

output: outputs all integer sequences from the smallest key to the biggest key of set. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing all elements of a key.

Output

Complete insert, range output and output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11935 - double-end-queue   

Description

There's a dequeue already define in "function.h" and stack , queue inherit from the _dequeue.

Please implement those function below:

stack::

        void push(const _node N);
        void pop();
        _node* get_data();

queue::

        void push(const _node N);
        void pop();
        _node* get_data();

 

Good luck.

 

 

Input

There will be few instruction in input [cont] [inst] [data].

cont and inst will be string

cont will be "stack" or "queue"

inst will be "push", "pop", "front" for queue only and "top" for stack only.

data will be optional (only when push inst , it will give the data ")


"exit" means exit

 

Output

In every "get_data"(top or front) commands , it will be single line with the data.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11935.cpp

Partial Judge Header

11935.h

Tags




Discuss