#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && (n != 0 || m != 0)) {
// 讀取所有單字並連接成一個長字串
string concatenated;
for (int i = 0; i < n; ++i) {
string word;
cin >> word;
concatenated += word;
}
// 讀取查詢位置
vector<int> positions(m);
for (int i = 0; i < m; ++i) {
cin >> positions[i];
}
// 構建結果字串
string result;
for (int pos : positions) {
// 注意題目中的位置是從1開始的
result += concatenated[pos - 1];
}
cout << result << endl;
}
return 0;
}
#include
#include
#include
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && (n != 0 || m != 0)) {
// 讀取所有單字並連接成一個長字串
string concatenated;
for (int i = 0; i < n; ++i) {
string word;
cin >> word;
concatenated += word;
}
// 讀取查詢位置
vector positions(m);
for (int i = 0; i < m; ++i) {
cin >> positions[i];
}
// 構建結果字串
string result;
for (int pos : positions) {
// 注意題目中的位置是從1開始的
result += concatenated[pos - 1];
}
cout << result << endl;
}
return 0;
}
are you using ai
#include #include #include using namespace std; int main() { int n, m; while (cin >> n >> m && (n != 0 || m != 0)) { // 讀取所有單字並連接成一個長字串 string concatenated; for (int i = 0; i < n; ++i) { string word; cin >> word; concatenated += word; } // 讀取查詢位置 vector positions(m); for (int i = 0; i < m; ++i) { cin >> positions[i]; } // 構建結果字串 string result; for (int pos : positions) { // 注意題目中的位置是從1開始的 result += concatenated[pos - 1]; } cout << result << endl; } return 0; }are you using ai
yes
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && (n != 0 || m != 0)) {
// 讀取所有單字並連接成一個長字串
string concatenated;
for (int i = 0; i < n; ++i) {
string word;
cin >> word;
concatenated += word;
}
// 讀取查詢位置
vector positions(m);
for (int i = 0; i < m; ++i) {
cin >> positions[i];
}
// 構建結果字串
string result;
for (int pos : positions) {
// 注意題目中的位置是從1開始的
result += concatenated[pos - 1];
}
cout << result << endl;
}
return 0;
}