Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- while(t--) {
- vector<string> mat;
- string p;
- cin >> p;
- int n = (int) p.size();
- vector<int> extra_friends(n, 0);
- mat.push_back(p);
- for(int i = 1; i < n; i++) {
- cin >> p;
- mat.push_back(p);
- }
- for(int i = 0; i < n; i++) {
- for(int j = i + 1; j < n; j++) {
- if(mat[i][j] == 'N') {
- for(int k = 0; k < n; k++) {
- if(mat[i][k] == 'Y' and mat[j][k] == 'Y') {
- extra_friends[i]++;
- extra_friends[j]++;
- break;
- }
- }
- }
- }
- }
- int max_friends = 0, idx = 0;
- for(int i = 0; i < n; i++) {
- if(max_friends < extra_friends[i]) {
- max_friends = extra_friends[i];
- idx = i;
- }
- }
- cout << idx <<" "<< max_friends << endl;
- }
- return 0;
- }
- /*
- NYYY
- YNNY
- YNNN
- YYNN
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement