Submission #1869808


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

int n;
string s, t, nums[maxn], numt[maxn], ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> t;
	if (s > t)
		swap (s, t);
	int ss = s.size(), tt = t.size();

	for (int i = 1; i * ss <= n; i++)
		nums[i] = nums[i-1] + s;
	for (int i = 1; i * tt <= n; i++)
		numt[i] = numt[i-1] + t;
	ans = "#";
	for (int i = 0; i * ss <= n; i++)
		if ( (n - i * ss) % tt == 0)
			if (ans == "#")
				ans = nums[i] + numt[ (n - i*ss) / tt ];
			else
				ans = min (ans, (nums[i] + numt[ (n - i*ss) / tt ] ));
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task G - Coinage
User mahan_sh
Language C++14 (GCC 5.4.1)
Score 0
Code Size 699 Byte
Status RE
Exec Time 3603 ms
Memory 1883252 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 4
AC × 18
WA × 1
TLE × 17
MLE × 1
RE × 17
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 3 ms 3328 KB
a02 AC 3 ms 3328 KB
a03 AC 3 ms 3328 KB
a04 AC 3 ms 3328 KB
b05 AC 3 ms 3328 KB
b06 AC 4 ms 4628 KB
b07 TLE 3200 ms -602532 KB
b08 TLE 2547 ms -601604 KB
b09 TLE 2468 ms -601900 KB
b10 AC 15 ms 5896 KB
b11 AC 4 ms 4372 KB
b12 AC 4 ms 4440 KB
b13 TLE 2497 ms -601724 KB
b14 RE 1756 ms -601860 KB
b15 TLE 2521 ms -601772 KB
b16 TLE 2468 ms -602652 KB
b17 TLE 2520 ms -601812 KB
b18 TLE 2502 ms -602188 KB
b19 RE 1680 ms -602292 KB
b20 RE 1788 ms -602248 KB
b21 RE 1762 ms -602172 KB
b22 RE 2048 ms -602132 KB
b23 RE 1760 ms -602144 KB
b24 RE 1809 ms -602964 KB
b25 RE 1801 ms -602096 KB
b26 RE 1747 ms -602044 KB
b27 TLE 2820 ms -602140 KB
b28 TLE 2527 ms -601924 KB
b29 RE 1786 ms -602272 KB
b30 RE 1864 ms -602184 KB
b31 TLE 2593 ms -601900 KB
b32 TLE 2527 ms -601784 KB
b33 TLE 2551 ms -602052 KB
b34 TLE 2557 ms -601736 KB
b35 TLE 3603 ms -601772 KB
b36 RE 1820 ms -602072 KB
b37 RE 1887 ms -602632 KB
b38 TLE 2363 ms -603836 KB
b39 MLE 870 ms 1883252 KB
b40 WA 4 ms 4736 KB
b41 AC 64 ms 132608 KB
b42 RE 1745 ms -602092 KB
b43 RE 1693 ms -602132 KB
b44 RE 1801 ms -602244 KB
b45 RE 1776 ms -602480 KB
b46 AC 14 ms 5828 KB
b47 AC 4 ms 4568 KB
b48 AC 4 ms 4372 KB
b49 AC 4 ms 4372 KB
b50 TLE 2405 ms -601948 KB
b51 AC 94 ms 168692 KB
b52 AC 5 ms 7168 KB
b53 AC 4 ms 4432 KB
b54 AC 46 ms 92544 KB