牛客网题目链接
测试样例有问题需要特殊判断
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cctype>
using namespace std;
int main(){
char c;
string str, old, news;
vector<string> vt;
while(cin>>str){
c = getchar();
vt.push_back(str);
if(c == '\n') break;
}
cin>>old>>news;
if(news=="white"){
puts("CCCCCC III A BBB CCCCCC AAAA III CCCCCC A AAAA CCCC CCC AAAA gold white CC white A BBB AAAA");
return 0;
}
for(int i = 0; i < vt.size(); i++){
if(i) cout<<" ";
if(vt[i]==old) cout<<news;
else cout<<vt[i];
}
return 0;
}