Submission #3729995


Source Code Expand

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

bool check(string S, string T) {
    while (!S.empty && !T.empty) {
        if (S.length > T.length) {
            swap(S, T);
        }
        if (T.startsWith(S)) {
            T = T[S.length..$];
        } else {
            return false;
        }
    }
    return true;
}

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto T = readln.chomp;

    bool loop = check(S, T);

    for (int i = 0, j = 0; !loop; i = (i + 1) % S.length.to!int, j = (j + 1) % T.length.to!int) {
        if (S[i] < T[j]) {
            break;
        } else if (S[i] > T[j]) {
            swap(S, T);
            break;
        }
    }

    int X = (N - 1) / S.length.to!int + 1;
    X = X * S.length.to!int;
    while (X > N || (N - X) % T.length != 0) {
        X -= S.length.to!int;
    }

    string ans = "";
    while (ans.length < X) ans ~= S;
    while (ans.length < N) ans ~= T;

    ans.writeln;
}

Submission Info

Submission Time
Task G - Coinage
User nebukuro09
Language D (LDC 0.17.0)
Score 100
Code Size 1165 Byte
Status AC
Exec Time 12 ms
Memory 3256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 54
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 2 ms 1208 KB
b07 AC 5 ms 636 KB
b08 AC 4 ms 636 KB
b09 AC 4 ms 2556 KB
b10 AC 2 ms 1208 KB
b11 AC 2 ms 3256 KB
b12 AC 3 ms 1080 KB
b13 AC 12 ms 1020 KB
b14 AC 5 ms 2940 KB
b15 AC 4 ms 1020 KB
b16 AC 5 ms 1020 KB
b17 AC 3 ms 636 KB
b18 AC 5 ms 636 KB
b19 AC 2 ms 636 KB
b20 AC 2 ms 636 KB
b21 AC 9 ms 636 KB
b22 AC 3 ms 636 KB
b23 AC 4 ms 636 KB
b24 AC 2 ms 636 KB
b25 AC 3 ms 636 KB
b26 AC 9 ms 636 KB
b27 AC 5 ms 636 KB
b28 AC 3 ms 636 KB
b29 AC 3 ms 636 KB
b30 AC 3 ms 636 KB
b31 AC 4 ms 636 KB
b32 AC 3 ms 636 KB
b33 AC 4 ms 636 KB
b34 AC 3 ms 636 KB
b35 AC 3 ms 636 KB
b36 AC 3 ms 2556 KB
b37 AC 2 ms 636 KB
b38 AC 2 ms 764 KB
b39 AC 2 ms 764 KB
b40 AC 2 ms 764 KB
b41 AC 2 ms 2684 KB
b42 AC 5 ms 636 KB
b43 AC 4 ms 636 KB
b44 AC 6 ms 2684 KB
b45 AC 6 ms 1020 KB
b46 AC 4 ms 2940 KB
b47 AC 3 ms 1080 KB
b48 AC 4 ms 2812 KB
b49 AC 4 ms 2812 KB
b50 AC 2 ms 636 KB
b51 AC 1 ms 508 KB
b52 AC 1 ms 636 KB
b53 AC 2 ms 2684 KB
b54 AC 1 ms 636 KB