2666 - I2P(I)2022_Yang_hw10 Scoreboard

Time

2022/11/22 21:00:00 2022/11/29 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12490 Little Brick's Calculator
12498 Partial Judge Example
12987 Let's build a hacker script

12490 - Little Brick's Calculator   

Description

Little Bricks(小磚頭) has a very brilliant calculator,
it can parse the numbers from a sentense and sum up all the numbers in the sentense.

One day, he broke the calculator,
but the calculator cannot be bought anymore,
so he ask you to make a new one for him.

ouo.

Hint:
This is a Partial Judge Problem:
0. You will be provided 2 files below: 'main.c', 'function.h'. You should only upload your 'solver' function inside your '.c' file.
1. The 'main.c' file contains input, output, and function call, the 'function.h' file contains the defination of 'solver' function, and your '.c' file should contain the implement of 'solver' function.
2. You can compile multiple files by command, ex: 'gcc main.c function.h your_code.c', or create a project in your IDE.
3. Remember to include 'function.h'.

 

main.c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include "function.h"

#define maxn 1000

char input[1000010];

int main() {
    int sum = 0;
    int a[maxn];
    int *ptr[maxn];

    for (int i = 0; i < maxn; i++) {
        a[i] = 0;
        ptr[i] = &a[i];
    }

    scanf("%s", input);
    int n = solver(ptr, &sum, input);
    printf("%d", a[0]);
    for (int i = 1; i < n; i++)
        printf(" %d", a[i]);
    printf("\n%d\n", sum);
    return 0;
}

function.h

1
2
3
4
5
#ifndef FUNCTION_H
#define FUNCTION_H

int solver(int **ptr, int *sum, char *s);
#endif


For example, if the sentense is 'Now:12/31,23:59',
then you should parse the 4 numbers: 12, 31, 23, 59 out,
and calculate the sum of these numbers, which is 12+31+23+59=129

The numbers should be separate by a space, after a newline character, output the sum of numbers.
Note that your calculator should be able to handle negative number.

Input

Input contain only 1 line, a string S.

It is guarantee that:
0. 1<= |S| <= 10^6
1. Numbers in S will be in the range [-10^5, 10^5]
2. The ammount of number in S will be in the range [1, 1000]

Output

Output contains 2 lines.

The first line should output all numbers appear in the input string S, separate with a space character,
the next line should be the sum of numbers at the first line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12490.c

Partial Judge Header

12490.h

Tags




Discuss




12498 - Partial Judge Example   

Description

This is the partial judge example (another method for online judge), you are asked to design a function below:

int call_add(int a, int b);

(implement a function to add two pass value togeter)

Note: for OJ partial judge submission:

       Step 1. Submit only your function.c into the submission block. (Please choose C compiler) 

       Step 2. Check the results and debug your program if necessary.

/* the content below is what you need to copy and submit to oj*/

int call_add(int a, int b){

        return a + b;

}

More information about the different of partial judge and normal judge

Input

Please refer to the main function.

The input only one line, contain two number a and b  (1 < a < 10, 1< b < 10)

Output

Output a + b. 

Sample Input  Download

Sample Output  Download

Partial Judge Code

12498.c

Partial Judge Header

12498.h

Tags




Discuss




12987 - Let's build a hacker script   

Description

As a student studying in computer science,

your parents and your friends always think of you as a hacker.

 

To impress them, you want to build a hacker script.

After several days of scripting, you finally got the system's administration password.

 

But the system has a protection mechanism,

which replace some consecutive letters into a '#' character as the system settings.

After that, there may be one or more '#' character,

and each '#' character represent one to many arbitary letters.

 

To get the whole control of the system,

you must know the exactly characters replaced by each '#' character.

 

Now, your goal is to print all possible combinations of each '#' character.

For the output order, please refer to the sample I/O.

 

The output order is also formally defined as follows.

Assume that the password you get is a string S,

and S[L, R] represent the substring from Lth character to the Rth character of string S.

For any 2 possible combinations A and B,

if the ith '#' in combination A replaced S[ALi, ARi] to '#',

the ith '#' in combination B replaced S[BLi, BRi] to '#',

and for the smallest i that ALi ≠ BLi and ARi ≠ BRi,

if ALi < BLi or (ALi = BLi and ARi < BRi),

then combination A should be output before combination B,

otherwise the combination B should be output before combination A.

If there is no any possible combinations,

output "What the hack!?" (without quotes).

 

ouo.

Input

Input contains 2 lines.

There first line contains a string S, represent the password of the system.

The second line contains a string P, represent the string you get after the protection mechanism replaced some character from S to '#'.

 

It is guaranteed that:

1 <= |S| <= 20, and S contains only lowercase letters,

1 <= |P| <= 20, and P contains only lowercase letters and at least 1 character '#'.

Output

If there is any possibles combination,

output one line per combination,

and separate the representation of each '#' by spaces.

Notice that the output order of combinations should follow the rules in the description.

 

If there is no any possible combination,

output "What the hack!?" (Without quotes)

Sample Input  Download

Sample Output  Download

Tags




Discuss