Submission #2120442


Source Code Expand

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int L;
string S, T;
string repeat(string &pat, int num) {
  string o = "";
  rep(_, num) o += pat;
  return o;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> L >> S >> T;
  vector<P> cand;
  for (int x=0; x*S.length()<=L; x++) {
    int y = L-x*S.length();
    if (y % T.length()) continue;
    y /= T.length();
    cand.pb(P(x, y));
  }
  assert(cand.size());
  string s = "~";
  s = min(s, repeat(S, cand.front()._1) + repeat(T, cand.front()._2));
  s = min(s, repeat(T, cand.front()._2) + repeat(S, cand.front()._1));
  s = min(s, repeat(S, cand.back()._1) + repeat(T, cand.back()._2));
  s = min(s, repeat(T, cand.back()._2) + repeat(S, cand.back()._1));
  cout << s << "\n";
  return 0;
}

Submission Info

Submission Time
Task G - Coinage
User funcsr
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1354 Byte
Status AC
Exec Time 11 ms
Memory 2672 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 1232 KB
b07 AC 9 ms 1908 KB
b08 AC 6 ms 1528 KB
b09 AC 8 ms 1652 KB
b10 AC 2 ms 1232 KB
b11 AC 2 ms 1232 KB
b12 AC 2 ms 1112 KB
b13 AC 5 ms 1104 KB
b14 AC 5 ms 1164 KB
b15 AC 2 ms 1104 KB
b16 AC 3 ms 1104 KB
b17 AC 6 ms 1080 KB
b18 AC 5 ms 1020 KB
b19 AC 3 ms 1080 KB
b20 AC 3 ms 956 KB
b21 AC 9 ms 1908 KB
b22 AC 4 ms 1400 KB
b23 AC 5 ms 1276 KB
b24 AC 3 ms 980 KB
b25 AC 4 ms 1088 KB
b26 AC 11 ms 2672 KB
b27 AC 7 ms 1908 KB
b28 AC 5 ms 1088 KB
b29 AC 4 ms 1080 KB
b30 AC 5 ms 1088 KB
b31 AC 5 ms 1080 KB
b32 AC 4 ms 1272 KB
b33 AC 5 ms 1272 KB
b34 AC 6 ms 1528 KB
b35 AC 3 ms 956 KB
b36 AC 3 ms 1144 KB
b37 AC 3 ms 1080 KB
b38 AC 3 ms 1112 KB
b39 AC 3 ms 980 KB
b40 AC 2 ms 1024 KB
b41 AC 2 ms 980 KB
b42 AC 6 ms 1400 KB
b43 AC 6 ms 1652 KB
b44 AC 5 ms 1528 KB
b45 AC 5 ms 1164 KB
b46 AC 2 ms 1232 KB
b47 AC 2 ms 1112 KB
b48 AC 2 ms 1232 KB
b49 AC 2 ms 1232 KB
b50 AC 3 ms 956 KB
b51 AC 2 ms 1020 KB
b52 AC 2 ms 776 KB
b53 AC 2 ms 1164 KB
b54 AC 2 ms 964 KB