0分,但不知道哪里有问题
查看原帖
0分,但不知道哪里有问题
1102460
fruian楼主2023/12/23 12:50

样例能过,自己写的样例也能过,但是全WA,QAQ

检测点

#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
#define ll long long

const int N = 5010;

struct word
{
	string name;
	string zhi;
}a[N];

int main(void)
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		string hc;
		cin >> hc >> a[i].zhi;
		a[i].name = '{' + hc + '}';
	}
	int cnt = 0;
	while (cnt < k)
	{
		string hc;
		cin >> hc;
		while (hc.find('{') != -1)
		{
			string b, c, d;
			b = hc.substr(hc.find('{'), hc.find('}') - hc.find('{') + 1);
			c = hc.substr(0, hc.find('{'));
			d = hc.substr(hc.find('}') + 1, hc.length() - hc.find('}'));
			for (int j = 0; j < n; j++)
			{
				if (a[j].name == b)
				{
					hc = c + a[j].zhi + d;
					break;
				}
			}
		}
		cout << hc << " ";
		if (hc[hc.length() - 1] == '.')
		{
			cout << endl;
			cnt++;
		}
	}
}

2023/12/23 12:50
加载中...