#include <vector> #include <string> using namespace std; class FriendScore { public: int highestScore(vectore <string> friends) { int ans = 0; int n=friends[0].length(); for (int i=0; i<n; i++) { int cnt = 0; for(int j=0; j<n; j++) { if(i == j) continue; } if(friends[i][j] == 'Y') { cnt++; } else { for(int k=0; k<n; k++){ if (friends[j][k] == 'Y' && friends[k][i] == 'Y'){ cnt++; break; } } } } ans = max(ans, cnt); } return ans; }
再帰関数
int fib(int a){ if(a <= 1) return 1; return fib(a - 1) + fib(a- 2); }