結果
| 問題 | No.2947 Sing a Song |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-23 15:42:03 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 32 ms / 2,000 ms |
| + 895µs | |
| コード長 | 739 bytes |
| 記録 | |
| コンパイル時間 | 3,323 ms |
| コンパイル使用メモリ | 360,716 KB |
| 実行使用メモリ | 9,912 KB |
| 最終ジャッジ日時 | 2026-09-23 15:42:10 |
| 合計ジャッジ時間 | 6,655 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M = 200010;
string S, T;
cin >> N >> S >> T;
int s = S.size(), t = T.size();
vector<bool> dp(M, false);
dp[0] = true;
for (int i = 0; i < M; i++){
if (!dp[i]) continue;
if (i+s < M) dp[i+s] = true;
if (i+t < M) dp[i+t] = true;
}
while (N--){
int x;
cin >> x;
vector<string> ans;
while (x > 0){
if (x-s >= 0 && dp[x-s]){
ans.push_back(S);
x -= s;
}
else{
ans.push_back(T);
x -= t;
}
}
for (auto s : ans) cout << s << ' ';
cout << endl;
}
}