B站头图景深对焦效果

请在图片上左右移动鼠标查看效果

关于 Maritozzo 问题的思考

来源于ac contest 219 B

------------------------------------------------------------

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200200 points

===================================

Problem Statement

You are given three strings S_1, S_2, S_3S1,S2,S3 consisting of lowercase English letters, and a string TT consisting of 123.

Concatenate the three strings according to the characters in TT and print the resulting string. Formally, conform to the following instructions.

  • For each integer ii such that 1 \leq i \leq |T|1iT, let the string s_isi be defined as follows:
    • S_1S1, if the ii-th character of TT is 1;
    • S_2S2, if the ii-th character of TT is 2;
    • S_3S3, if the ii-th character of TT is 3.
  • Concatenate the strings s_1, s_2, \dots, s_{|T|}s1,s2,,sT in this order and print the resulting string.

---------------------------------------------------------------

Constraints

  • 1 \leq |S_1|, |S_2|, |S_3| \leq 101S1,S2,S310
  • 1 \leq |T| \leq 10001T1000
  • S_1S1S_2S2, and S_3S3 consist of lowercase English letters.
  • TT consists of 12, and 3.

---------------------------------------------------------------

Input

Input is given from Standard Input in the following format:S_1S1

S_2S2
S_3S3
TT

--------------------------------------------

Output

Print the answer.

 ----------------------------------------------------------------

Sample Input 1 

mari
to
zzo
1321
---------------------------------------------

Sample Output 1 

marizzotomari

We have s_1 =s1= maris_2 =s2= zzos_3 =s3= tos_4 =s4= mari. Concatenate these and print the resulting string:

 marizzotomari.

-----------------------------------------------------------------------------

Sample Input 2 

abra
cad
abra
123

 ------------------------------------------------------

Sample Output 2 

abracadabra

 -------------------------------------------------------

Sample Input 3 

a
b
c
1
------------------------------------------

Sample Output 3 

a
-------------------------------------------

AC

#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<string> s(4);
    for (int i = 1; i <= 3;i++)
        cin >> s.at(i);
    string t;
    cin >> t;
    for (auto i = 0; i < t.length();i++){
        int j = t.at(i) - '0';
        cout << s.at(j);
    }
    cout << endl;
}

 

对于这题,我i自己写的很是复杂。

结果呢?WA/TLE

在此就不展示自己的繁冗代码了。

这么简单的方法当然是借鉴过来的啦 <:

有个地方不是很清楚,

在于那个 at

不知道是不是 C++ 的特殊方法

我的 VScode 告诉我那是重载函数

如果可以这么使用的话

与 C 的 sprintf 大为相似

实现了 数组 与 字符串之间的转换

----------------------------------------------------------------------

希望有大佬出来指点一下,

鄙人必将感激不尽!

 
posted @ 2021-09-22 16:38  acmWang  阅读(74)  评论(0)    收藏  举报
返回顶端

2021-09-22 (星期三)
09:08:39 +08:00