Example #1
0
int main() {
    Solution solution;
    std::vector<std::vector<char>> test
    {
        {
            'O', 'X', 'X', 'X'
        },
        {
            'X', 'O', 'O', 'X'
        },
        {
            'X', 'X', 'O', 'X'
        },
        {
            'X', 'O', 'X', 'X'
        }
    };

    solution.solve(test);
    for (int i = 0; i < test.size(); i++) {
        for (int j = 0; j < test[i].size(); j++) {
            std::cout << test[i][j] << " ";
        }
        std::cout << std::endl;
    }

    return 0;
}
int LEET_SURROUNDED_REGIONS()
{
    Solution solution;
    vector<vector<char> > board;
    vector<char> row1;
    vector<char> row2;
    vector<char> row3;
    char* boardData = "XOXOXOXOX";
    row1.assign(boardData, boardData + 3);
    row2.assign(boardData + 3, boardData + 6);
    row3.assign(boardData + 6, boardData + 9);
    board.push_back(row1);
    board.push_back(row2);
    board.push_back(row3);
    solution.solve(board);
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cout << board[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}
int main(){
    
    vector<vector<char> > board;
    /*
    vector<char> tmp={'X','X','X','X'};
    vector<char> tmp1={'X','O','O','X'};
    vector<char> tmp2={'X','X','O','X'};

    board.push_back(tmp2);
    board.push_back(tmp1);
    board.push_back(tmp1);
    board.push_back(tmp);
    */

    Solution s;
    s.solve(board);

    /*
    for(int i=0;i<board.size();i++){
        for(int j=0;j<board[0].size();j++){
            cout<<board[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
	*/
    return 0;
}
int main()
{
    Solution slt;
    int i = 0; 
    vector<vector<char> > board;
    for(int i = 0; test_case[i]; ++i)
    {
        vector<char> v;
        for(int k = 0 ; test_case[i][k] != 0; ++k)
        {
            v.push_back(test_case[i][k]); 
        }
        board.push_back(v);
    }
    for(int i = 0 ; test_case[i]; ++i)
    {
        for(int k = 0 ; test_case[i][k] != 0; ++k)
        {
            cout << board[i][k];
        }
        cout << endl;
    }
    cout   << endl;
    slt.solve(board); 
    for(int i = 0 ; test_case[i]; ++i)
    {
        for(int k = 0 ; test_case[i][k] != 0; ++k)
        {
            cout << board[i][k];
        }
        cout << endl;
    }
}
Example #5
0
int main()
{
    vector<vector<char> > board;
//    vector<char> x1 = {'O', 'O', 'O', 'O', 'X', 'X'};
//    vector<char> x2 = {'O', 'O', 'O', 'O', 'O', 'O'};
//    vector<char> x3 = {'O', 'X', 'O', 'X', 'O', 'O'};
//    vector<char> x4 = {'O', 'X', 'O', 'O', 'X', 'O'};
//    vector<char> x5 = {'O', 'X', 'O', 'X', 'O', 'O'};
//    vector<char> x6 = {'O', 'X', 'O', 'O', 'O', 'O'};
    vector<char> x1 = {'X', 'X', 'X'};
    vector<char> x2 = {'X', 'O', 'X'};
    vector<char> x3 = {'X', 'X', 'X'};
    //vector<char> x1 = {};
    board.push_back(x1);
    board.push_back(x2);
    board.push_back(x3);
//    board.push_back(x4);
//    board.push_back(x5);
//    board.push_back(x6);
    Solution solution;
    solution.solve(board);
    for (auto x = board.begin(); x != board.end(); x++)
    {
        for (auto y = (*x).begin(); y != (*x).end(); y++)
        {
            cout << *y << " ";
        }
        cout << endl;
    }
    return 0;
}
void TEST()
{
	/*vector<vector<char>>v {
		{'X', 'X', 'X', 'X'},
		{'X', 'O', 'O', 'X'},
		{'X', 'X', 'O', 'X'},
		{'X', 'O', 'X', 'X'}
	};*/
	vector<vector<char>>v{
		{ 'X', 'O', 'X', 'X' },
		{ 'O', 'X', 'O', 'X' },
		{ 'X', 'O', 'X', 'O' },
		{ 'O', 'X', 'O', 'X' },
		{ 'X', 'O', 'X', 'O' },
		{ 'O', 'X', 'O', 'X' }
	};
	Solution sol;

	sol.solve(v);

	for (auto vec : v)
	{
		for (auto ch : vec)
			cout << ch << " ";
		cout << endl;
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	ifstream fin("f:\\OJ\\uva_in.txt");
	streambuf* back = std::cin.rdbuf(fin.rdbuf());
#endif
		
	int n;
	while (cin >> n)
	{
		if (n == 0) break;
		solution.init();
		solution.setn(n);
		string s;
		getline(cin, s);
		for (int i = 0; i < n; i++)
		{
			getline(cin, s);
			vector<int> v = sepstr(const_cast<char*>(s.c_str()), ": ");
			solution.addEdge(v);
		}
		
		int res = solution.solve();
		cout << res << endl;
	}

#ifndef ONLINE_JUDGE
	cin.rdbuf(back);
#endif
	return 0;
}
int
main()
{
  Solution solution;
  vector<vector<char> > board(4, vector<char>(6, 'X'));
  board[0][1] = board[0][3] = board[0][5] = 'O';
  board[1][0] = board[1][2] = board[1][4] = 'O';
  board[2][1] = board[2][3] = board[2][5] = 'O';
  board[3][0] = board[3][2] = board[3][4] = 'O';

  for (int i = 0; i < board.size(); i++) {
    for (int j = 0; j < board[i].size(); j++) {
      cout << board[i][j] << " ";
    }
    cout << endl;
  }

  cout << endl;
  solution.solve(board);
  for (int i = 0; i < board.size(); i++) {
    for (int j = 0; j < board[i].size(); j++) {
      cout << board[i][j] << " ";
    }
    cout << endl;
  }

}
int main(int argc , char** argv)
{
    int m,n;
    while(cin>>m>>n){
        vector<vector<char>> board(m, vector<char>(n));
        for(int i=0;i<m;i++)
            for( int j=0 ; j<n; j++)
                cin>>board[i][j];
			


    Solution sol;
    sol.solve(board);
	
	
	for( int i=0;i<m;i++){
			for( int j=0;j<m;j++)
				cout<<board[i][j]<<" ";
        cout<<endl;
        }
	}
    

    return 0;

}
int main()
{
    Solution s;
    vector<vector<char> > b;
    vector<char> bb;
    vector<char>().swap(bb);
    for (int i = 0; i<4;i++)
      bb.push_back('X');
    vector<char> bbb;
    vector<char>().swap(bbb);
    for (int i = 0; i<4;i++)
      bbb.push_back('O');

    for (int i = 0; i<4;i++)
      //    if (i%2==1)
      b.push_back(bbb);
    //  else
    //  b.push_back(bbb);  
      for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                  cout << b[i][j];
                cout << endl;
            }  
    s.solve(b);
    return 0;
}
Example #11
0
TEST(largestXTest, Positive01){
    Solution s;

    const int rows = 7, cols = 7;
    char arr[][cols] = {
        {'1', '0', '1', '1', '1', '0', '1'},
        {'0', '1', '0', '1', '1', '1', '0'},
        {'1', '0', '1', '0', '1', '0', '1'},
        {'1', '1', '1', '1', '0', '1', '1'},
        {'1', '1', '1', '0', '1', '1', '0'},
        {'1', '0', '1', '1', '0', '1', '1'},
        {'1', '1', '1', '1', '1', '0', '1'}};

    vector<vector<char> > board;
    for(int i = 0; i < rows; i++){
        board.push_back(vector<char>(arr[i], arr[i] + cols));
    }

    int expected = 2;
    EXPECT_EQ(expected, s.solve(board));

    for(int i = 0; i < rows; i++){
        board[i].clear();
    }
    board.clear();
}
/*
 *  x x x
 *  x 0 x
 *  x x x
 * */
TEST(surroundedRegionsTest, Positive01){
    Solution s;

    const int rows = 3, cols = 3;

    char A[][cols] = {
        {'x', 'x', 'x'},
        {'x', '0', 'x'},
        {'x', 'x', 'x'}};

    vector<vector<char> > board;
    for(int i = 0; i < rows; i++){
        board.push_back(vector<char>(A[i], A[i] + cols));
    }

    s.solve(board);  // board turns to result

    char B[][cols] = {
        {'x', 'x', 'x'},
        {'x', '@', 'x'},
        {'x', 'x', 'x'}};

    vector<vector<char> > expected;
    for(int i = 0; i < rows; i++){
        expected.push_back(vector<char>(B[i], B[i] + cols));
    }

    assertMatrix(expected, board);

    expected.clear();
    board.clear();
}
int main(int argc, char *argv[])
{
	Solution s;
	vector<vector<char> > vec;
	for (int i = 0; i < 5; i++) {
		vector<char> v1;	
		v1.push_back('X');
		if (i == 1 || i == 3) {
			v1.push_back('O');
		} else {
			v1.push_back('X');
		}
		if (i == 1 || i == 2) {
			v1.push_back('O');
		} else {
			v1.push_back('X');
		}
		v1.push_back('X');
		vec.push_back(v1);
	}
	
	for (int i = 0; i < vec.size(); i++) {
        for (int j = 0; j < vec[i].size(); j++) {
        	cout << vec[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
	
	s.solve(vec);
	
	return 0;
}
Example #14
0
int main()
{
	vector<vector<char> > board(4);
	board[0].push_back('X');
	board[0].push_back('X');
	board[0].push_back('X');
	board[0].push_back('X');

	board[1].push_back('X');
	board[1].push_back('O');
	board[1].push_back('O');
	board[1].push_back('X');

	board[2].push_back('X');
	board[2].push_back('X');
	board[2].push_back('O');
	board[2].push_back('X');

	board[3].push_back('X');
	board[3].push_back('O');
	board[3].push_back('X');
	board[3].push_back('X');

	Solution s;
	s.solve(board);

	for (ssize_t i = 0; i < board.size(); ++i) {
		for (ssize_t j = 0; j < board[i].size(); ++j) {
			cout << board[i][j];
		}
		cout << endl;
	}

	return 0;
}
Example #15
0
int main(int argc, char *argv[])
{
	int i, j;
	Solution sol;
	vector<vector<char> > v;
	vector<char> v1;

	for (j = 0; j < 5; j++)
		v1.push_back('#');

	for (i = 0; i < 4; i++)
		v.push_back(v1);

	v[1][1] = v[1][2] = v[2][2] = v[3][1] = 'O';

	sol.solve(v);

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 5; j++)
			cout << v[i][j];
		cout << endl;
	}

	return 0;
}
int main()
{
	Solution sol;
	vector<int> res = { 3,0,6,1,5 };
	vector<vector<char>> board;
	board = {
		{ 'X', 'X', 'X', 'X' },
		{ 'X', 'O', 'O', 'X' },
		{ 'X', 'X', 'O', 'X' },
		{ 'X', 'O', 'X', 'X' },
	};
	sol.solve(board);
	for (int i = 0; i < board.size(); i++)
	{
		for (int j = 0; j < board[0].size(); j++)
		{
			cout<<board[i][j] << " ";
		}
		cout<<endl;
	}

	system("pause");
	return 0;

}
int main(){
    Solution solution;
    fstream f("input.txt", fstream::in);
    int n_row, n_col;
    f >> n_row >> n_col;
    vector<vector<char> > board;
    int i, j;
    char ch;
    for(i=0; i<n_row; i++){
        vector<char> tmp;
        for(j=0; j<n_col; j++){
            f >> ch;
            tmp.push_back(ch);
        }
        board.push_back(tmp);
    }

    print_board(board);

    solution.solve(board);

    cout << "After flipping..." << endl;
    print_board(board);

}
Example #18
0
int main()
{
    int i, j, n;
    n = 5;
    char a[][10] = {"OXXOX",
                    "XOOXO",
                    "XOXOX",
                    "OXOOO",
                    "XXOXO"};
    vector<vector<char> > v(n);
    for (i = 0; i < n; ++i)
        v[i].assign(a[i], a[i] + n);
    // char a[][10] = {"OOO", "OOO", "OOO"};
    // vector<vector<char> > v(3);
    // for (i = 0; i < 3; ++i)
    //     v[i].assign(a[i], a[i] + 3);
    Solution s;
    s.solve(v);
    for (i = 0; i < n; ++i)
    {
        for (j = 0; j < n; ++j)
            cout<<v[i][j];
        cout<<endl;
    }
}
Example #19
0
int main(int argc, char *argv[]) {
  int result = 0;
  Solution obj;
  int num = atoi(argv[1]);
  result = obj.solve(num);
  cout << result << endl;
  return 0;
}
Example #20
0
// BEGIN CUT HERE
int main(int argc, char *argv[]) {
  ll result = 0;
  Solution obj;
  ll num = atoll(argv[1]);
  result = obj.solve(num);
  cout << result << endl;
  return 0;
}
Example #21
0
int main(int argc, char *argv[]) {
  ll result = 0;
  Solution obj;
  int num1 = atoi(argv[1]);
  int num2 = atoi(argv[2]);
  result = obj.solve(num1, num2);
  cout << result << endl;
  return 0;
}
Example #22
0
int main() {
    ofstream fout("sol.out");
    ifstream fin("sol.in");

    Solution sol;
    vector<vector<char> > board(1, vector<char>(1, 'O'));
    sol.solve(board);
    return 0;
}
Example #23
0
int main() {
    Solution s;
    vector<vector<char>> v ={ {'O'} };
    s.solve(v);
    for (auto& vv : v) {
        for (auto& c : vv) {
            cout << c;
        }
        cout << endl;
    }
    return 0;
}
int main()
{
	Solution s;
	{
		vector<vector<char>> board{ { 'X', 'O', 'X' }, { 'X', 'O', 'X' }, { 'X', 'O', 'X' } };
		s.solve(board);
		print_board(board);
	}

	std::cin.get();
	return 0;
}
int main()
{
    Solution s;
    vector<vector<char> > vec={{'X','X','X','X'},{'X','O','O','X'},{'X','X','O','X'},{'X','O','X','X'}};
    //vector<vector<char> > vec={{'O','O','O','O'},{'O','O','O','O'},{'O','O','O','O'},{'O','O','O','O'}};
    s.solve(vec);
    for(auto a:vec)
    {
        for(auto v:a)
            cout<<v<<" ";
        cout<<endl;
    }
}
int _tmain(int argc, _TCHAR* argv[])
{
    vector<vector<char>> array;
    const char* fileName = "D:\\test.txt";

    ReadFileToConstructArray(array, fileName, 250, 250);

    Solution solution;
    solution.solve(array);

    system("PAUSE");
    return 0;
}
Example #27
0
int main()
{
    Solution s;
    {
        std::vector<std::vector<char> > board(4, std::vector<char>(4, 0));
        board[0][0]='X'; board[0][1]='X'; board[0][2]='X'; board[0][3]='X';
        board[1][0]='X'; board[1][1]='O'; board[1][2]='O'; board[1][3]='X';
        board[2][0]='X'; board[2][1]='X'; board[2][2]='O'; board[2][3]='X';
        board[3][0]='X'; board[3][1]='O'; board[3][2]='X'; board[3][3]='X';
        s.solve(board);
        print(board);
    }
    return 0;
}
int main(int argc, char *argv[]) {
    Solution sol;
    {
        vector<vector<char>> board{
            {'X', 'X', 'X', 'X',},
            {'X', 'O', 'O', 'X',},
            {'X', 'X', 'O', 'X',},
            {'X', 'O', 'X', 'X',},
        };

        sol.solve(board);
        for (auto ct : board) {
            for (auto i : ct){
                cout << i << " ";
            }
            cout <<endl;
        }
    }  

    {
        vector<vector<char>> board{
            {'O','O','O',},
            {'O','O','O',},
            {'O','O','O',},
        };

        sol.solve(board);
        for (auto ct : board) {
            for (auto i : ct){
                cout << i << " ";
            }
            cout <<endl;
        }
    }
    return 0;
}
void honglei(const char * s, int m) {
    vector<vector<char> > board;
    for (int k=0; s[k] == 'X' || s[k] == 'O'; k+=m) {
        vector<char> line;
        for (int i=0; i<m; ++i)
            line.push_back(s[k+i]);
        board.push_back(line);
    }

    UIO<char>::pr(board);
    static Solution engine;
    engine.solve(board);
    UIO<char>::pr(board);
    cout << endl;
}
Example #30
0
int main()
{
    freopen("C:\\Users\\crazyacking\\Downloads\\B-large.in","r",stdin);
    freopen("C:\\Users\\crazyacking\\Downloads\\out.txt","w",stdout);
    int T;
    cin>>T;
    for(int Cas=1;Cas<=T;++Cas)
    {
        string s;
        cin>>s;
        Solution solution;
        int ans=solution.solve(s);
        cout<<"Case #"<<Cas<<": "<<ans<<endl;
    }
    return 0;
}