Artifact 4c32e38aec559696fb47bba06d04ece434994215
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class NetworkSecurity { public:
int secureNetwork(vector <string> clientCable, vector <string> serverCable)
{
int N = clientCable.size();
int M = serverCable[0].size();
vector< vector<int> > cd(N, vector<int>(N));
for(int i=0; i<N; ++i)
for(int j=0; j<N; ++j)
if( clientCable[i][j]=='Y' )
cd[i][j] = 1;
for(int k=0; k<N; ++k)
for(int i=0; i<N; ++i)
for(int j=0; j<N; ++j)
cd[i][j] |= cd[i][k] & cd[k][j];
int cnt = 0;
for(int i=0; i<N; ++i)
for(int j=0; j<M; ++j)
{
if( serverCable[i][j]=='Y' )
{
for(int k=0; k<N; ++k)
if( cd[i][k]==1 && serverCable[k][j]=='Y' )
goto next;
++cnt;
next:;
}
}
return cnt;
}
};
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003] : <cafelier&naoya_t>-custom
// Powered by CodeProcessor