9.13百度
第一题
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s.size() < 5){
cout<<0;
return 0;
}
int count = 0;
unordered_set<char> set1{'a','e','i','o','u','A','E','I','O','U'};
for(int i = 0 ; i <= s.size()-5;i++){
string ss = s.substr(i,5);
vector<int> vec(26,0);
bool flag = true;
for(int j = 0 ; j < 5;j++){
vec[ss[j]-'a']++;
if(vec[ss[j]-'a'] > 1){
flag = false;
break;
}
}
if(!flag){
continue;
}
if(set1.count(ss[0])||!set1.count(ss[1])||!set1.count(ss[2])||set1.count(ss[3])||!set1.count(ss[4])){
continue;
}
count++;
}
cout<<count;
return 0;
} 第二题 #include <bits/stdc++.h>
using namespace std;
int main(){
int number;
cin>>number;
for(int i = 0 ; i < number;i++){
string s;
cin>>s;
int zeronum = 0;
int onenum = 0;
for(int i = 0 ; i < s.size();i++){
if(s[i] == '0'){
zeronum++;
}else{
onenum++;
}
}
if(onenum%2 == 0 ||zeronum %2 == 0){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
} 第三题 #include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
if(n == 0 && m == 0){
cout<<0;
return 0;
}
vector<string> vec;
string temp;
for(int i = 0 ; i < n;i++){
cin>>temp;
vec.push_back(temp);
}
bool success = false;
queue<pair<int,int>> que;
que.push({0,0});
vector<vector<bool>> visited(n,vector<bool>(m,false));
visited[0][0] = true;
vector<vector<int>> moved{{-1,0},{1,0},{0,-1},{0,1}};
int count = 0;
while(!que.empty()){
int size = que.size();
for(int i = 0 ; i < size ;i++){
auto item = que.front();
que.pop();
char d = vec[item.first][item.second];
if(item.first == n-1 && item.second == m-1){
cout<<count;
return 0;
}
visited[item.first][item.second] = true;
for(int j = 0 ; j < 4 ; j++){
int newx = item.first + moved[j][0];
int newy = item.second + moved[j][1];
if(newx >= 0 && newx < n && newy >= 0 && newy < n && visited[newx][newy] == false){
if(vec[item.first][item.second] == 'r'){
if(vec[newx][newy] == 'r'||vec[newx][newy] == 'e'){
que.push({newx,newy});
visited[newx][newy] = true;
}
}else if(vec[item.first][item.second] == 'e'){
if(vec[newx][newy] == 'e'||vec[newx][newy] == 'd'){
que.push({newx,newy});
visited[newx][newy] = true;
}
}else if(vec[item.first][item.second] == 'd'){
if(vec[newx][newy] == 'd'||vec[newx][newy] == 'r'){
que.push({newx,newy});
visited[newx][newy] = true;
}
}
}
}
}
count++;
}
if(!success){
cout<<-1;
}
return 0;
} 百度共享中突然笔试,笔试还这难度,感觉不缺人啊,随便吧。菜鸡躺平了