P11395 喵喵喵幼儿园 题解

· · 个人记录

P11395 喵喵喵幼儿园 题解

按题意模拟即可。

核心变量

string a,b;
string s;
$b$代表第二个单词(包含```?```,处理方法后面讲解)。 $s$代表中间的连接单词。 --- ### 思路 分类讨论即可。 1. 如果$a,b$都为```eat```,输出```or```。 2. 如果$a$为```eat```,输出$b$。 3. 如果$b$为```eat```,输出$a$。 4. 如果$a,b$都不为```eat```,输出$a$。 但要注意,$b$包含```?```,所以需要删除```?```。 ``` b.erase(b.size()-1); ``` --- #### AC code ``` #include <bits/stdc++.h> #define lowbit(x) (x&(-x)) using namespace std; typedef long long ll; const ll N=5e5+5,M=1e2+5; ll t; int main() { ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>t; while(t--){ string a,b; string s; cin>>a>>s>>b; b.erase(b.size()-1); if(a=="eat"&&b=="eat") cout<<"or\n"; else if(a=="eat") cout<<b<<endl; else if(b=="eat") cout<<a<<endl; else cout<<a<<endl; } return 0; } ```