美团3月12日太难了吧
五道题,做了两道题,一个过了45%,一个过了15%,其余问题都没看懂,就不能说的清楚点么。
我觉得自己第一题也没问题阿,为什么才45%
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int main(){ int n; cin >> n; string line1, line2; cin >> line1 >> line2; vector<int> path1(n); //path1表示第一行 vector<int> path2(n); //path2表示第二行 if(line1[0] == '.') path1[0] = 1; else if(line1[0] == 'X'||line1[0]=='x') path1[0] = 0; path2[0] = 0; for(int i = 1; i < n; i++){ if(line1[i] == 'X'||line1[0]=='x') path1[i] = 0; else path1[i] = path1[i-1] + path2[i-1]; if(line2[i] == 'X'||line1[0]=='x') path2[i] = 0; else path2[i] =path1[i-1] + path2[i-1]; } if(path2[n-1] == 0) cout << -1; else cout << path2[n-1]; }