結果
| 問題 |
No.2947 Sing a Song
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-25 21:56:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 1,233 bytes |
| コンパイル時間 | 6,427 ms |
| コンパイル使用メモリ | 337,736 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-25 21:56:25 |
| 合計ジャッジ時間 | 9,453 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
random_device rnd;
mt19937 mt(rnd());
int RandInt(int a, int b) {
return a + mt() % (b - a + 1);
}
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int n;
string s,t;
int s_sz,t_sz;
pair<int, int> f(int x) {
int s_cnt = x / s_sz;
int nokori = x % s_sz;
if (nokori % t_sz == 0) {
int t_cnt = nokori / t_sz;
return {s_cnt, t_cnt};
}else{
while (s_cnt > 0) {
s_cnt--;
nokori += s_sz;
if (nokori % t_sz == 0) {
int t_cnt = nokori / t_sz;
return {s_cnt, t_cnt};
}
}
}
return {-1, -1};
}
int main(){
cin>>n>>s>>t;
s_sz=s.size();
t_sz=t.size();
rep(i,n){
int x;
cin>>x;
pair<int,int>p=f(x);
//cerr<<p.first<<" "<<p.second<<endl;
rep(i,p.first){
cout<<s<<" ";
}
rep(i,p.second){
cout<<t<<" ";
}
cout<<endl;
}
return 0;
}