結果

問題 No.2947 Sing a Song
コンテスト
ユーザー AwashAmityOak
提出日時 2024-10-25 21:58:44
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 2,804 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,627 ms
コンパイル使用メモリ 380,336 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-05 20:50:33
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In instantiation of 'void print(std::vector<_Tp>&) [with T = std::__cxx11::basic_string<char>]':
main.cpp:37:60:   required from 'void println(std::vector<_Tp>&) [with T = std::__cxx11::basic_string<char>]'
   37 | template<class T> inline void println(vector<T>& A) { print(A); cout << endl; }
      |                                                       ~~~~~^~~
main.cpp:82:13:   required from here
   82 |         println(ans);
      |         ~~~~~~~^~~~~
main.cpp:36:82: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   36 | template<class T> inline void print(vector<T>& A) { rep(i, A.size()) if (i) print("", A[i]); else print(A[i]); }
      |                                                                             ~~~~~^~~~~~~~~~
main.cpp:33:43: note: candidate 1: 'void print(const T&, const U& ...) [with T = char [1]; U = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]'
   33 | template<class T, class... U> inline void print(const T& a, const U&... b) { cout << a; ((cout << " " << b), ...); }
      |                                           ^~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:231,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/print:117:5: note: candidate 2: 'void std::print(format_string<_Args ...>, _Args&& ...) [with _Args = {__cxx11::basic_string<char, char_traits<char>, allocator<char> >&}; format_string<_Args ...> = basic_format_string<char, __cxx11::basic_string<char, char_traits<char>, allocator<char> >&>]'
  117 |     print(format_string<_Args...> __fmt, _Args&&... __args)
      |     ^~~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;
istream& operator>> (istream& is, mint& x) { long long _x; is >> _x; x = _x; return is; }
ostream& operator<< (ostream& os, const mint& x) { return os << x.val(); }
template<class T, class U>
ostream& operator<< (ostream& os, const pair<T, U>& x) { return os << "{" << x.first << ", " << x.second << "}"; }
#define int ll
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP2(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define REP1(i, n) REP2(i, 0, n)
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define RREP2(i, r, l) for (int i = (int)(r)-1; i >= (int)(l); --i)
#define RREP1(i, n) RREP2(i, n, 0)
#define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back
#define mp make_pair
#define mt make_tuple
const int INF = 4e18;
const int MOD = 998244353;
const int MOD1 = 1e9 + 7;
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> T pow(T a, T b, T m) { return b ? b&1 ? a*pow(a, b^1, m)%m : pow(a*a%m, b>>1, m)%m : 1; }
template<class T> T pow(T a, T b) { return b ? b&1 ? pow(a, b^1)*a : pow(a*a, b>>1) : 1; }
template<class... T> inline void input(T&... a) { ((cin >> a), ...); }
template<class T, class... U> inline void print(const T& a, const U&... b) { cout << a; ((cout << " " << b), ...); }
template<class T, class... U> inline void println(const T& a, const U&... b) { print(a, b...); cout << endl; }
inline void println() { cout << endl; }
template<class T> inline void print(vector<T>& A) { rep(i, A.size()) if (i) print("", A[i]); else print(A[i]); }
template<class T> inline void println(vector<T>& A) { print(A); cout << endl; }
const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int extgcd(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	int d = extgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    input(N);
    string S, T;
    input(S, T);
    int L = S.size();
    int M = T.size();
    int G = gcd(L, M);
    int lcm = L * M / G;
    vector<int> A(N);
    rep(i, N) input(A[i]);
    
    rep(i, N) {
    	vector<string> ans;
    	
    	rep(j, L+1) {
    		if ((A[i] - M * j) % L == 0) {
    			rep(k, (A[i] - M * j) / L) ans.pb(S);
    			rep(k, j) ans.pb(T);
    			break;
    		}
    	}
    	
    	println(ans);
    }
}
0