P1321 单词覆盖还原 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题解 P1321 【单词覆盖还原】 - 又菜又烂,没救了 - 洛谷博客 (luogu.com.cn)
ps.naozishigehaodongxikexiwomeiyou
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; int boy,girl,len; string str; int main(){ cin>>str; len=str.length(); rep(i,0,len-3){ if(str[i]=='b'||str[i+1]=='o'||str[i+2]=='y') boy++; if(str[i]=='g'||str[i+1]=='i'||str[i+2]=='r'||str[i+3]=='l') girl++; } cout<<boy<<endl<<girl; return 0; }