Submission #41038017


Source Code Expand

/* InTheBloom_Template v1.04 (BETA) Last updated: 2023/4/25 */
/* Repository: https://github.com/InTheBloom/InTheBloom_Library */

/* Originally includes 'in_out.c', 'debug.c' */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define EPRINT_INT(x) {\
    long long Z = x;\
    fprintf(stderr, "Line %d: %s = %lld\n", __LINE__, #x, Z);\
}
#define EPRINT_STR(x) {\
    fprintf(stderr, "Line %d: %s = %s\n", __LINE__, #x, x);\
}
#define EPRINT_INT_ARRAY(x, n) do {\
    if (n > 0) {\
        fprintf(stderr, "Line %d: %s = [", __LINE__, #x);\
        for (int qq = 0; qq < n - 1; qq++) {\
            long long Z = x[qq];\
            fprintf(stderr, "%lld, ", Z);\
        }\
    long long Z = x[n - 1];\
    fprintf(stderr, "%lld]\n", Z);\
    } else {\
        fprintf(stderr, "[]\n");\
    }\
} while (0)

#define NEWLINE fprintf(stderr, "\n")

int read_int (void) {
    int x;
    scanf("%d", &x);
    return x;
}

double read_double (void) {
    double x;
    scanf("%lf", &x);
    return x;
}

long long read_long_long (void) {
    long long x;
    scanf("%lld", &x);
    return x;
}

void read_str (char *x) {
    scanf("%s", x);
}

void read_int_array (int *x, int n) {
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
}

void read_long_long_array (long long *x, int n) {
    for (int i = 0; i < n; i++) {
        scanf("%lld", &x[i]);
    }
}

// Defined with macros to support multiple types.

#define print_int_array_with_space(x, n) do {\
    for (int i = 0; i < n; i++) {\
        long long Z = x[i];\
        printf("%lld ", Z);\
    }\
    printf("\n");\
} while (0)

#define print_int_array_with_newlines(x, n) do {\
    for (int i = 0; i < n; i++) {\
        long long Z = x[i];\
        printf("%lld\n", Z);\
    }\
} while (0)

#define print_int(x) do {\
    long long Z = x;\
    printf("%lld\n", Z);\
} while (0)

_Bool is_samemap (int H, int W, char A[H][W + 1], char B[H][W + 1]) {
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != B[i][j]) {
                return 0;
            }
        }
    }

    return 1;
}

void side_shift (int H, int W, char A[H][W + 1]) {
    char tmp[H][W + 1];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            tmp[i][(j + 1) % W] = A[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            A[i][j] = tmp[i][j];
        }
    }
}

void vertical_shift (int H, int W, char A[H][W + 1]) {
    char tmp[H][W + 1];
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            tmp[(i + 1) % H][j] = A[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            A[i][j] = tmp[i][j];
        }
    }
}

void solve (int H, int W, char A[H][W + 1], char B[H][W + 1]) {
    _Bool is_ok = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            side_shift(H, W, A);
            if (is_samemap(H, W, A, B)) {
                is_ok = 1;
                i = H;
                break;
            }
        }
        vertical_shift(H, W, A);
    }

    if (is_ok) {
        puts("Yes");
    } else {
        puts("No");
    }
}

int main (void) {
    int H = read_int(), W = read_int();
    char A[H][W + 1], B[H][W + 1];

    for (int j = 0; j < H; j++) {
        read_str(A[j]);
    }

    for (int j = 0; j < H; j++) {
        read_str(B[j]);
    }
    solve(H, W, A, B);

    return 0;
}

Submission Info

Submission Time
Task B - Same Map in the RPG World
User InTheBloom
Language C (Clang 10.0.0)
Score 200
Code Size 3666 Byte
Status AC
Exec Time 4 ms
Memory 2040 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 38
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 02_h_eq_2_w_eq_2_00.txt, 02_h_eq_2_w_eq_2_01.txt, 02_h_eq_2_w_eq_2_02.txt, 02_h_eq_2_w_eq_2_03.txt, 02_h_eq_2_w_eq_2_04.txt, 02_h_eq_2_w_eq_2_05.txt, 02_h_eq_2_w_eq_2_06.txt, 02_h_eq_2_w_eq_2_07.txt, 02_h_eq_2_w_eq_2_08.txt, 02_h_eq_2_w_eq_2_09.txt, 02_h_eq_2_w_eq_2_10.txt, 02_h_eq_2_w_eq_2_11.txt, 02_h_eq_2_w_eq_2_12.txt, 02_h_eq_2_w_eq_2_13.txt, 02_h_eq_2_w_eq_2_14.txt, 02_h_eq_2_w_eq_2_15.txt, 03_corner1_00.txt, 03_corner1_01.txt, 03_corner1_02.txt, 03_corner1_03.txt, 03_corner1_04.txt, 03_corner1_05.txt, 03_corner1_06.txt, 04_corner2_00.txt, 04_corner2_01.txt, 04_corner2_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 4 ms 1896 KiB
00_sample_01.txt AC 1 ms 2016 KiB
00_sample_02.txt AC 1 ms 2004 KiB
00_sample_03.txt AC 1 ms 1988 KiB
01_random_00.txt AC 1 ms 1984 KiB
01_random_01.txt AC 1 ms 1960 KiB
01_random_02.txt AC 2 ms 2004 KiB
01_random_03.txt AC 2 ms 2016 KiB
01_random_04.txt AC 2 ms 2000 KiB
01_random_05.txt AC 1 ms 2040 KiB
01_random_06.txt AC 1 ms 2036 KiB
01_random_07.txt AC 1 ms 1980 KiB
02_h_eq_2_w_eq_2_00.txt AC 1 ms 1876 KiB
02_h_eq_2_w_eq_2_01.txt AC 1 ms 1976 KiB
02_h_eq_2_w_eq_2_02.txt AC 1 ms 1956 KiB
02_h_eq_2_w_eq_2_03.txt AC 1 ms 1984 KiB
02_h_eq_2_w_eq_2_04.txt AC 1 ms 1960 KiB
02_h_eq_2_w_eq_2_05.txt AC 1 ms 1868 KiB
02_h_eq_2_w_eq_2_06.txt AC 1 ms 1868 KiB
02_h_eq_2_w_eq_2_07.txt AC 1 ms 1980 KiB
02_h_eq_2_w_eq_2_08.txt AC 2 ms 1980 KiB
02_h_eq_2_w_eq_2_09.txt AC 1 ms 1872 KiB
02_h_eq_2_w_eq_2_10.txt AC 1 ms 2000 KiB
02_h_eq_2_w_eq_2_11.txt AC 2 ms 1960 KiB
02_h_eq_2_w_eq_2_12.txt AC 2 ms 2040 KiB
02_h_eq_2_w_eq_2_13.txt AC 1 ms 2004 KiB
02_h_eq_2_w_eq_2_14.txt AC 1 ms 2004 KiB
02_h_eq_2_w_eq_2_15.txt AC 1 ms 2004 KiB
03_corner1_00.txt AC 2 ms 1980 KiB
03_corner1_01.txt AC 1 ms 1980 KiB
03_corner1_02.txt AC 1 ms 1980 KiB
03_corner1_03.txt AC 1 ms 1964 KiB
03_corner1_04.txt AC 2 ms 1984 KiB
03_corner1_05.txt AC 1 ms 1880 KiB
03_corner1_06.txt AC 1 ms 2036 KiB
04_corner2_00.txt AC 1 ms 1876 KiB
04_corner2_01.txt AC 2 ms 2032 KiB
04_corner2_02.txt AC 2 ms 1976 KiB