結果

問題 No.2947 Sing a Song
ユーザー forest3
提出日時 2025-02-04 22:33:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 162,704 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-02-04 22:33:10
合計ジャッジ時間 6,967 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:36: warning: ‘e’ may be used uninitialized [-Wmaybe-uninitialized]
    4 | #define rep(i, n) for(int i = 0; i < n; i++ )
      |                                    ^
main.cpp:25:17: note: in expansion of macro ‘rep’
   25 |                 rep(j, e) {
      |                 ^~~
main.cpp:16:34: note: ‘e’ was declared here
   16 |                 int d = l / szs, e;
      |                                  ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++ )
using ll = long long;

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	int szs = s.size(), szt = t.size();
	rep(i, N) {
		int l = a[i];
		int d = l / szs, e;
		for(; d >= 0; d--) {
			int st = l - szs * d;
			if(st % szt == 0) {
				e = st / szt;
				break;
			}
		}
		rep(j, d) cout << s << " ";
		rep(j, e) {
			cout << t;
			if(j  + 1 < e) cout << " ";
		}
		cout << endl;
	}
}
0