Submission #3729976


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;

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

    if (S.front == T.front && S.map!(s => s == S.front).all && T.map!(t => t == T.front).all) {
        S.front.repeat.take(N).writeln;
        return;
    }

    if (S == T) {
        string ans = "";
        while (ans.length < N) ans ~= S;
        ans.writeln;
        return;
    }

    for (int i = 0, j = 0; ; 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 0
Code Size 1134 Byte
Status TLE
Exec Time 2103 ms
Memory 2812 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 4
AC × 50
TLE × 4
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 8 ms 1080 KB
b07 AC 5 ms 636 KB
b08 AC 4 ms 636 KB
b09 AC 4 ms 636 KB
b10 AC 2 ms 1208 KB
b11 AC 2 ms 1208 KB
b12 AC 3 ms 2812 KB
b13 AC 13 ms 1020 KB
b14 AC 3 ms 1020 KB
b15 AC 4 ms 2812 KB
b16 AC 4 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 2 ms 508 KB
b22 TLE 2103 ms 256 KB
b23 AC 4 ms 636 KB
b24 AC 3 ms 636 KB
b25 TLE 2103 ms 256 KB
b26 AC 10 ms 2684 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 TLE 2103 ms 256 KB
b35 AC 3 ms 636 KB
b36 AC 3 ms 2684 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 1 ms 636 KB
b42 AC 2 ms 508 KB
b43 AC 4 ms 2556 KB
b44 AC 5 ms 636 KB
b45 TLE 2103 ms 636 KB
b46 AC 4 ms 2812 KB
b47 AC 3 ms 1080 KB
b48 AC 3 ms 1148 KB
b49 AC 3 ms 1148 KB
b50 AC 2 ms 636 KB
b51 AC 1 ms 508 KB
b52 AC 2 ms 508 KB
b53 AC 2 ms 1020 KB
b54 AC 1 ms 636 KB