Submission #1870166


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
 
ll n;
string s, t, ans;
 
string num (int x, bool w)
{
	if (!x)
		return "";
	string tmp = num (x/2, w);

	tmp += tmp;
	if (x & 1)
		tmp += (w ? s : t);
	return tmp;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> t;
	ll ss = s.size(), tt = t.size();
	ans = "#";
	for (ll i = 0; i * ss <= n; i++)
		if ( (n - i * ss) % tt == 0)
		{
			string t1 = num (i, 1), t2 = num ( (n - i*ss) / tt , 0);
			if (ans == "#")
				ans = min (t1 + t2, t2 + t1);
			else
				ans = min (ans, min (t1 + t2, t2 + t1));
		}
	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 717 Byte
Status TLE
Exec Time 2103 ms
Memory 1776 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 4
AC × 36
TLE × 18
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 1300 KB
b07 TLE 2103 ms 1156 KB
b08 TLE 2103 ms 1664 KB
b09 TLE 2103 ms 1200 KB
b10 AC 2 ms 1104 KB
b11 AC 2 ms 1104 KB
b12 AC 2 ms 1172 KB
b13 AC 2 ms 1104 KB
b14 AC 3 ms 1104 KB
b15 AC 2 ms 1172 KB
b16 AC 3 ms 1172 KB
b17 TLE 2103 ms 1408 KB
b18 TLE 2103 ms 1372 KB
b19 AC 202 ms 1596 KB
b20 AC 1341 ms 1368 KB
b21 TLE 2103 ms 1156 KB
b22 TLE 2103 ms 1352 KB
b23 AC 1170 ms 1676 KB
b24 AC 718 ms 1408 KB
b25 TLE 2103 ms 1372 KB
b26 TLE 2103 ms 1144 KB
b27 TLE 2103 ms 1440 KB
b28 TLE 2103 ms 1372 KB
b29 TLE 2103 ms 1412 KB
b30 TLE 2103 ms 1372 KB
b31 TLE 2103 ms 1408 KB
b32 AC 1037 ms 1776 KB
b33 AC 936 ms 1572 KB
b34 TLE 2103 ms 1348 KB
b35 AC 997 ms 1408 KB
b36 AC 338 ms 1576 KB
b37 AC 248 ms 1760 KB
b38 AC 2 ms 1288 KB
b39 AC 2 ms 976 KB
b40 AC 2 ms 1008 KB
b41 AC 2 ms 1232 KB
b42 TLE 2103 ms 1200 KB
b43 TLE 2103 ms 1352 KB
b44 TLE 2103 ms 1348 KB
b45 AC 3 ms 1104 KB
b46 AC 2 ms 1232 KB
b47 AC 2 ms 1172 KB
b48 AC 2 ms 1104 KB
b49 AC 2 ms 1104 KB
b50 AC 933 ms 1452 KB
b51 AC 2 ms 1000 KB
b52 AC 2 ms 768 KB
b53 AC 2 ms 1036 KB
b54 AC 2 ms 796 KB