1052. 卖个萌 (20)
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
萌萌哒表情符号通常由“手”、“眼”、“口”三个主要部分组成。简单起见,我们假设一个表情符号是按下列格式输出的:
[左手]([左眼][口][右眼])[右手]
现给出可选用的符号集合,请你按用户的要求输出表情。
输入格式:
输入首先在前三行顺序对应给出手、眼、口的可选符号集。每个符号括在一对方括号[]内。题目保证每个集合都至少有一个符号,并不超过10个符号;每个符号包含1到4个非空字符。
之后一行给出一个正整数K,为用户请求的个数。随后K行,每行给出一个用户的符号选择,顺序为左手、左眼、口、右眼、右手——这里只给出符号在相应集合中的序号(从1开始),数字间以空格分隔。
输出格式:
对每个用户请求,在一行中输出生成的表情。若用户选择的序号不存在,则输出“Are you kidding me? @\/@”。
输入样例:[╮][╭][o][~\][/~] [<][>] [╯][╰][^][-][=][>][<][@][⊙] [Д][▽][_][ε][^] ... 4 1 1 2 2 2 6 8 1 5 5 3 3 4 3 3 2 10 3 9 3输出样例:
╮(╯▽╰)╭ <(@Д=)/~ o(^ε^)o Are you kidding me? @\/@
/*#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;
int main()
{
string hand, eye, mouth;
getline(cin, hand);
getline(cin, eye);
getline(cin, mouth);
int K;
int i = 0; int
pos1 = 0, pos2 = 0;
int c1, c2, c3;
c1 = c2 = c3 = 0;
int pos = 0;
do {
pos = hand.find('[', pos);
if (pos >= 0)
{
c1++; pos++;
}
else
break;
} while (pos >= 0);
pos = 0;
do {
pos = eye.find('[', pos);
if (pos >= 0)
{
c2++; pos++;
}
else
break;
} while (pos >= 0);
pos = 0;
do {
pos = mouth.find('[', pos);
if (pos >= 0)
{
c3++; pos++;
}
else
break;
} while (pos >= 0);
cin >> K;
vector<int> v; int t;
while (K--)
{
for (int i = 0; i < 5; i++)
{
cin >> t;
v.push_back(t);
}
if (v[0] > c1 || v[1] > c2 || v[2] > c3 || v[3] > c2 || v[4] > c1)
{
cout << "Are you kidding me? @\\/@" << endl;
continue;
}
i = v[0];
pos1 = 0, pos2 = 0;
while (i--)
{
pos1 = hand.find('[', pos1++);
pos2 = hand.find(']', pos2++);
}
if (pos1 >= 0 && pos2 >= 0)
{
pos2--;
cout << hand.substr(pos1, pos2 - pos1) << "(";
}
i = v[1];
pos1 = 0, pos2 = 0;
while (i--)
{
pos1 = eye.find('[', pos1++);
pos2 = eye.find(']', pos2++);
}
if (pos1 >= 0 && pos2 >= 0)
{
pos2--;
cout << eye.substr(pos1, pos2 - pos1);
}
i = v[2];
pos1 = 0, pos2 = 0;
while (i--)
{
pos1 = mouth.find('[', pos1++);
pos2 = mouth.find(']', pos2++);
}
if (pos1 >= 0 && pos2 >= 0)
{
pos2--;
cout << mouth.substr(pos1, pos2 - pos1);
}
i = v[3];
pos1 = 0, pos2 = 0;
while (i--)
{
pos1 = eye.find('[', pos1++);
pos2 = eye.find(']', pos2++);
}
if (pos1 >= 0 && pos2 >= 0)
{
pos2--;
cout << eye.substr(pos1, pos2 - pos1) << ")";
}
i = v[4];
pos1 = 0, pos2 = 0;
while (i--)
{
pos1 = hand.find('[', pos1++);
pos2 = hand.find(']', pos2++);
}
if (pos1 >= 0 && pos2 >= 0)
{
pos2--;
cout << hand.substr(pos1, pos2 - pos1) << endl;
}
v.clear();
}
return 0;
}*/
#include<string>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<vector<string> > v;
for (int i = 0; i < 3; i++) {
string s;
getline(cin, s);
vector<string> row;
int j = 0, k = 0;
while (j < s.length()) {
if (s[j] == '[') {
while (k++ < s.length()) {
if (s[k] == ']') {
row.push_back(s.substr(j + 1, k - j - 1));
break;
}
}
}
j++;
}
v.push_back(row);
}
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
if (a > v[0].size() || b > v[1].size() || c > v[2].size() || d > v[1].size() || e > v[0].size() || a < 1 || b < 1 || c < 1 || d < 1 || e < 1) {
cout << "Are you kidding me? @\\/@" << endl;
continue;
}
cout << v[0][a - 1] << "(" << v[1][b - 1] << v[2][c - 1] << v[1][d - 1] << ")" << v[0][e - 1] << endl;
}
return 0;
}
不知道为啥我的(注释部分)过不了,样例一模一样,但一个点都过不了,很无奈,上述代码是看到别人比较好的代码