int main() { freopen("test.txt", "r", stdin); vector<char> v1; v1.push_back('A'); v1.push_back('B'); v1.push_back('C'); v1.push_back('E'); vector<char> v2; v2.push_back('S'); v2.push_back('F'); v2.push_back('E'); v2.push_back('S'); vector<char> v3; v3.push_back('A'); v3.push_back('D'); v3.push_back('E'); v3.push_back('E'); vector<vector<char> > maze; maze.push_back(v1); maze.push_back(v2); maze.push_back(v3); Solution s; cout << s.exist(maze, "ABCESEEEFS") << endl; cout << s.exist(maze, "SEE") << endl; cout << s.exist(maze, "ABCB") << endl; return 0; }
int main() { vector <vector <char> > input_mat = {{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}}; Solution solution = Solution(); cout << solution.exist(input_mat, "ABCCED") << endl; cout << solution.exist(input_mat, "SEE") << endl; cout << solution.exist(input_mat, "ABCB") << endl; return 0; }
int main(int argc, char *argv[]) { vector<vector<char>> tmp = { {'A','B','C','E'}, {'S','F','C','S'}, {'A','D','E','E'}}; Solution s; cout << "Test1: " << s.exist(tmp, "ABCCED") << endl; cout << "Test2: " << s.exist(tmp, "ABCB") << endl; return 0; }
int main() { Solution sol; vector<vector<char>> board = {{'a','b','c','e'}, {'s','f','c','s'}, {'a','d','e','e'}}; cout << (true == sol.exist(board, "abcced")) << endl; cout << (true == sol.exist(board, "see")) << endl; cout << (false == sol.exist(board, "abcb")) << endl; cout << (false == sol.exist(board, "esfc")) << endl; vector<vector<char>> b2 = {{'A','B','C','E'}, {'S','F','E','S'}, {'A','D','E','E'}}; cout << (true == sol.exist(b2, "ABCESEEEFS")) << endl; cout << endl; }
int main() { Solution s; vector<vector<char> > board; char a[][10] = {"ABCE", "SFCS", "ADEE"}; int i, j; for (i = 0; i < 3; ++i) board.push_back(vector<char>(a[i], a[i] + 4)); cout<<s.exist(board, "ABCCED")<<endl; cout<<s.exist(board, "ABCB")<<endl; }
int main(){ Solution sol; vector<vector<char> > board; char arr[] = {'A','B','C','E'}; char arr2[] = {'S','F','E','S'}; char arr3[] = {'A','D','E','E'}; board.push_back(vector<char>(arr,arr+sizeof(arr)/sizeof(char))); board.push_back(vector<char>(arr2,arr2+sizeof(arr2)/sizeof(char))); board.push_back(vector<char>(arr3,arr3+sizeof(arr3)/sizeof(char))); cout<<sol.exist(board,"ABCCED")<<endl; cout<<sol.exist(board, "ABCESEEEFS")<<endl; //char arr[] = {'A','A'}; //board.push_back(vector<char>(arr,arr+sizeof(arr)/sizeof(char))); cout<<sol.exist(board,"AAA")<<endl; }
int main(int argc, char const *argv[]) { Solution solution; int n, m; vector<vector<char> > b; string w; char c; cin >> w; cin >> n >> m; for (int i = 0; i < m; ++i) { vector<char> v; for (int j = 0; j < n; ++j) { cin >> c; v.push_back(c); } b.push_back(v); } cout << solution.exist(b, w) << endl; return 0; }
int main(){ char a[] = {'A','B','C','E'}; char b[] = {'S','F','C','S'}; char c[] = {'A','D','E','E'}; vector<char> A(a,a+4); vector<char> B(b,b+4); vector<char> C(c,c+4); vector<vector<char> > board; board.push_back(A); board.push_back(B); board.push_back(C); Solution soln; cout<<soln.exist(board,"ABCCED")<<" "<<soln.exist(board,"SEE")<<" "<<soln.exist(board,"ABCB")<<endl; }
int main() { Solution s; vector<vector<char> > vec={{'A','B','C','E'},{'S','F','C','S'},{'A','D','E','E'}}; string str="AB"; cout<<s.exist(vec,str)<<endl; }
int main() { Solution sol; vector<string> data { "ABCE", "SFCS", "ADEE" }; vector<vector<char> > board(data.size()); for (int i = 0; i < data.size(); ++i) { board[i].assign(data[i].begin(), data[i].end()); } print_2D<char>(board); vector<string> words { "ABCCED", "SEE", "ABCB", "ASADFBCCEESE", "ESECBASADECF", "SFCSECBA", "SFCSECBAE", }; for (auto s : words) { cout << sol.exist(board, s) << endl; } return 0; }
int main() { Solution s; vector<vector<char>> board = {{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}}; bool ret = s.exist(board, "ABCCED"); cout << ret << endl; return 0; }
int main(){ Solution sol; vector<vector<char>> a = { { 'a', 'a', 'a' }, { 'a', 'a', 'a' }, {'a','a','b'} }; string word = "aaaaaaaab"; if (sol.exist(a, word)) cout << 111 << endl; system("pause"); }
int main() { Solution object; vector<vector<char> > board; vector<char> row1; row1.push_back('A'); row1.push_back('B'); row1.push_back('C'); row1.push_back('E'); vector<char> row2; row2.push_back('S'); row2.push_back('F'); row2.push_back('C'); row2.push_back('S'); vector<char> row3; row3.push_back('A'); row3.push_back('D'); row3.push_back('E'); row3.push_back('E'); board.push_back(row1); board.push_back(row2); board.push_back(row3); cout<<object.exist(board,"ESECCFDASA")<<endl; return 0; }
int main( int argc, char **argv ) { Solution sln; int n_row, n_test; string str; cin >> n_row >> n_test; vector< vector<char> > board(n_row); for( int i = 0; i < n_row; ++i ) { cin >> str; board[i].assign( str.begin(), str.end() ); // copy( board[i].begin(), board[i].end(), ostream_iterator<char>(cout, "") ); // cout << endl; } // for while( n_test-- ) { cin >> str; // cout << str << endl; bool ret = sln.exist( board, str ); string result = ( ret ? "true" : "false" ); cout << result << endl; } // while return 0; }
int main() { vector<vector<char>> board = {{'a', 'b', 'c','d'}}; string word = "ab"; Solution sol; cout << sol.exist(board, word) <<endl; }
int main() { vector<vector<char> >test; vector<char> temp; temp.push_back('C'); temp.push_back('A'); temp.push_back('A'); // temp.push_back('E'); test.push_back(temp); temp.clear(); temp.push_back('A'); temp.push_back('A'); temp.push_back('A'); // temp.push_back('S'); test.push_back(temp); temp.clear(); temp.push_back('B'); temp.push_back('C'); temp.push_back('D'); // temp.push_back('E'); test.push_back(temp); temp.clear(); string word="AAAAADB"; Solution s; cout<<s.exist(test,word)<<endl; return 0; }
int main() { // std::string w = "ABCCED"; // std::vector<std::vector<char>> b = { // {'A', 'B', 'C', 'E'}, // {'S', 'F', 'C', 'S'}, // {'A', 'D', 'E', 'E'} // }; std::string w = "a"; std::vector<std::vector<char>> b = { {'a'} }; // std::string w = "aaa"; // std::vector<std::vector<char>> b = { // {'a', 'a'} // }; // std::string w = "AAB"; // std::vector<std::vector<char>> b = { // {'C', 'A', 'A'}, // {'A', 'A', 'A'}, // {'B', 'C', 'D'}, // }; Solution s; printf("%s\n", s.exist(b, w) ? "true" : "false"); return 0; }
int main() { Solution solution; vector<vector<char>> vecs; for (int i=0;i<3;i++) { vector<char> vec; for (int j=0;j<4;j++) { char c; cin>>c; vec.push_back(c); } vecs.push_back(vec); } while (true) { string str; cin>>str; cout<<solution.exist(vecs,str); } }
int main(int argc, char *argv[]) { Solution sol; /* { vector<vector<char>> board{ {'A','B','C','E',}, {'S','F','C','S',}, {'A','D','E','E',}, }; string word = "ABCCED"; cout << boolalpha << sol.exist(board, word) <<endl; } { vector<vector<char>> board{ {'a', 'b'}, {'c', 'd'}, }; string word = "abcd"; cout << boolalpha << sol.exist(board, word) <<endl; } */ { vector<vector<char>> board{ {'A','B','C','E',}, {'S','F','E','S',}, {'A','D','E','E',} }; string word = "ABCESEEEFS"; cout << boolalpha << sol.exist(board, word) <<endl; } return 0; }
int main() { Solution s; vector<vector<char> > board{{'A','B','C','E'}, {'S','F','C','S'}, {'A','D','E','E'} }; cout << s.exist(board,"ADEESECC") << endl; }
int main(){ vector<vector<char>> input; input.push_back(vector<char>()); input[0].push_back('b'); input[0].push_back('a'); Solution s; cout << s.exist(input, "ab") << endl; return 0; }
int main(){ vector<vector<char> > board = { {'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}}; Solution s; cout << s.exist(board, "ABCB") << endl; return 0; }
int main() { // Start typing your code here... cout << "Hello world!" << endl; Solution s; vector<vector<char> > board; vector<char> first; first.push_back('a'), first.push_back('b'); vector<char> second; second.push_back('c'), second.push_back('d'); board.push_back(first), board.push_back(second); string word = "abcd"; cout << s.exist(board, word) << endl; return 0; }
int main() { cout << "Please input the number of rows: "; int m; cin >> m; cout << "Please input the number of cols: "; int n; cin >> n; vector<vector<char> > board(m, vector<char>(n, '.')); cout << "Please input a 2D board: "; for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { char val; cin >> val; board[i][j] = val; } } for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { cout << board[i][j] << " "; } cout << endl; } while(1) { cout << "Please input a word: "; string word; cin.clear(); getline(cin, word); // getline属于string流,与cin.getline不同 cin >> word; Solution s; int result = s.exist(board, word); if (result) cout << "True! " << endl; else cout << "False! " << endl; } system("pause"); return 0; }
int main() { Solution sol; vector<vector<char>> board { {'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}, }; bool exist = sol.exist(board, "ABCCED"); printf("Exist: %c\n", exist ? 't' : 'f'); }
int main() { vector<char> a = { 'A', 'B', 'C', 'D' }; vector<char> b = { 'S', 'F', 'C', 'S' }; vector<char> c = { 'A', 'D', 'E', 'E' }; vector<vector<char>> board = { a, b, c }; Solution s; //cout << s.exist(board, "ABCCED") << endl; //cout << s.exist(board, "SEE") << endl; cout << s.exist(board, "ABCB") << endl; return 0; }
int main() { vector<vector<char> > board; vector<char> row; /* row.push_back('A'); row.push_back('B'); row.push_back('C'); row.push_back('E'); board.push_back(row); row.clear(); row.push_back('S'); row.push_back('F'); row.push_back('C'); row.push_back('S'); board.push_back(row); row.clear(); row.push_back('A'); row.push_back('D'); row.push_back('E'); row.push_back('E'); board.push_back(row); */ row.push_back('A'); row.push_back('B'); row.push_back('C'); row.push_back('E'); board.push_back(row); row.clear(); row.push_back('S'); row.push_back('F'); row.push_back('E'); row.push_back('S'); board.push_back(row); row.clear(); row.push_back('A'); row.push_back('D'); row.push_back('E'); row.push_back('E'); board.push_back(row); //string word = "SEE"; //string word = "ABCB"; string word = "ABCEFSADEESE"; Solution s; cout << s.exist(board, word) << endl; }
int main(void) { Solution so; vector<vector<char>> board; char ch[][5] = { "ABCE", "SFCS", "ADEE" };// ABCE for (int i = 0; i < 3; i++) { vector<char> v(ch[i], ch[i] + 4); board.push_back(v); } cout << so.exist(board, "") << endl; return 0; }
int main() { vector<char> row1({'A', 'B', 'C', 'E'}); vector<char> row2({'S', 'F', 'C', 'S'}); vector<char> row3({'A', 'D', 'E', 'E'}); vector<vector<char> > board; board.push_back(row1); board.push_back(row2); board.push_back(row3); Solution sln; cout<<sln.exist(board, "ABCCED")<<endl; return 0; }
int main() { Solution solution; //Test cases { char a[][4] = { {'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'} }; vector<vector<char> > v; arr_of_arr_to_vec(v, a[0], 3, 4); cout << solution.exist(v, "ABCCED") << endl; cout << solution.exist(v, "SEE") << endl; cout << solution.exist(v, "ABCB") << endl; } //Error test cases from leetcode.com return 0; }