3310 - I2P(II)2026_Yang_hw2 Scoreboard

Time

2026/03/13 15:20:00 2026/03/27 13:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11253 String Left Shift
11711 Dynamic 3D array
12490 Little Brick's Calculator
12498 Partial Judge Example
14896 Red Cape Flying Cat likes Juice

11253 - String Left Shift   

Description

Given a string S, you are going to shift part of it.
Specifically, a shift on a string is to move all the characters left but the leftmost characters would be move to the rightmost.
For example, a shift on "abcd" would result in "bcda".

This problem ask you implement a function shift(char *start, char *end) that shift a substring of S starting from start to end.

1.      This problem involves three files.

  • function.h: Function definition of shift.
  • function.c: Function implementation of shift.
  • main.c: A driver program to test your implementation.

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

  • 2.     For OJ 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.

Input

The first line is a string S. (length of S<=20)
The second is a integer n. (n<=10)
The next n lines, each contains two integers l and r.(l<=r<=n)
This means that a shift on S[l]S[l+1]...S[r].
If the length of substring is one(l=r), then you should keep the string unchanged.
All these shift must be done in order.

 

Output

The result string after all n shift operations.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11253.c

Partial Judge Header

11253.h

Tags




Discuss




11711 - Dynamic 3D array   

Description

In this problem, you are asked to design two functions
    1.

unsigned*** new_3d_array(unsigned n,unsigned m,unsigned k);

malloc an n*m*k 3D unsigned array, and then return its address. The main function will check the correctness of your array.

 

    2.

void delete_3d_array(unsigned ***arr);

Free the memory space of your array that was previously allocated by using malloc. Be careful about the memory uage of your program allocated dynamically so as to avoid MLE.

 

The two functions have been declared in function.h, and you are asked to complete the function definitions in function.c.

Your program should construct the 3D array by using only three malloc function calls. Notice that malloc is a time-consuming operation.

 

Note: for OJ 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.

Input

Please refer to the main function.

The input only has one line, consisting of five positive integers t,n,m,k,r separated by space characters, where t is the number of tests, (n,m,k) represents the array size, and r is a parameter for testing. 

Note that n*m*k<=10000000 and t*n*m*k<=60000000

Output

In order to test your array's correctness, we will use your array to do some computations and output the results.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11711.c

Partial Judge Header

11711.h

Tags

Jinkela



Discuss




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




14896 - Red Cape Flying Cat likes Juice   

Description

 

Meet **Red Cape Flying Cat** - a magical feline who loves flying around with their bright red cape. Unfortunately, they just had their wisdom teeth removed and can't eat any solid food. The only thing they can consume is fruit juice!

Red Cape Flying Cat visits a long fruit stand where fruits are arranged in a row. Each position has one type of fruit (represented by lowercase letters 'a' to 'z'). Since their mouth still hurts, they can't speak clearly. The only way they can order is by pointing at two positions - the start and end of a range - and buying all fruits in between.

Now here's the problem: Red Cape Flying Cat is worried about drinking the same flavor over and over again. They want to know **how many different types of fruits** they'll get for each purchase, so they can decide if the juice will be diverse enough!

Since Red Cape Flying Cat will make many purchases (queries), please help them write an efficient program to answer these questions quickly.

Summarized_Question(if you are lazy to read the story)

Given a string S consisting only of lowercase English letters ('a' to 'z'), answer multiple queries efficiently.

Each query provides two integers L and R (0-based), representing the substring S[L..R] inclusive.

For each query, determine how many distinct characters appear in that substring.

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 declaration of 'solver' function, and your '.c' file should contain the implementation 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include "function.h"

#define MAXN 100005
#define MAXQ 100005

char str[MAXN];
int left[MAXQ], right[MAXQ];
int *left_ptr[MAXQ], *right_ptr[MAXQ];
int results[MAXQ];
int *res_ptr[MAXQ];

int prefix[26][MAXN];
int *prefix_ptr[26];

int main() {
    int q;
    scanf("%s", str);

    int len = 0;
    while (str[len] != '\0') len++;

    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        scanf("%d %d", &left[i], &right[i]);
        left_ptr[i] = &left[i];
        right_ptr[i] = &right[i];
        results[i] = 0;
        res_ptr[i] = &results[i];
    }

    for (int i = 0; i < 26; i++) {
        prefix_ptr[i] = prefix[i];
    }

    solver(str, len, left_ptr, right_ptr, res_ptr, q, prefix_ptr);

    for (int i = 0; i < q; i++) {
        printf("%d\n", results[i]);
    }

    return 0;
}

function.h

1
2
3
4
5
6
#ifndef FUNCTION_H
#define FUNCTION_H

void solver(char *s, int len, int **left, int **right, int **results, int q, int **prefix);

#endif


It is recommended to use prefix sum to solve this problem. Build a prefix sum array for each character.

The expected time complexity is O(26 * |S| + 26 * Q).

Note: The 'prefix' parameter is a pre-allocated 2D array space. You may use it to build your prefix sum, but it is not mandatory.

Input

The first line contains a string S, consisting of only lowercase English letters.

The second line contains an integer Q, representing the number of queries.

The next Q lines each contain two integers L and R, representing a query for the range [L, R]. (0-indexed)

It is guaranteed that:
0. 1 <= |S| <= 10^5
1. 1 <= Q <= 10^5
2. 0 <= L <= R < |S|

 

Output

For each query, output one line containing the number of distinct characters in the range.

Sample Input  Download

Sample Output  Download

Partial Judge Code

14896.c

Partial Judge Header

14896.h

Tags




Discuss