For this Question: Given a dictionary, a method to do lookup in dictionary and a M x N board where every cell has one character. Find all possible words that can be formed by a sequence of adjacent characters. Note that we can move to any of 8 adjacent characters, but a word should not have multiple instances of same cell.

Example:

Input: dictionary[] = {"GEEKS", "FOR", "QUIZ", "GO"};
       boggle[][]   = {{'G','I','Z'}, {'U','E','K'}, {'Q','S','E'}};

Output:  Following words of the dictionary are present
         GEEKS, QUIZFirst line contains an integer X denoting the no of words in the dictionary. Then in the next line are X space separated strings denoting the contents of the dictionary. In the next line are two integers N and M denoting the size of the boggle. Next N lines each contains M characters denoting the contents of the boggle.

Constraints:
1 < = X < = 10
1 < = N, M < = 4
1 < = |String| < = 10
All input strings are made up of uppercase characters of the English alphabets.Print in a single line and in a sorted order all the words of the dictionary which could be formed from the boggle. If no word can be formed print -1.Sample Input:
4
GEEKS FOR QUIZ GO
3 3
G I Z 
U E K 
Q S E

Sample Output:
GEEKS QUIZ, I have written this Solution Code: // C++ program for Boggle game 
#include <bits/stdc++.h>
using namespace std; 

// Let the given dictionary be following 
string dictionary[100]; 
int n; 
int M, N;
bool flag;
set<string> res;

bool isWord(string& str) 
{ 
	// Linearly search all words 
	for (int i = 0; i < n; i++) 
		if (str.compare(dictionary[i]) == 0) 
			return true; 
	return false; 
} 

// A recursive function to print all words present on boggle 
void findWordsUtil(vector<vector<char> > boggle, vector<vector<bool> > visited, int i, 
				int j, string& str) 
{ 
	// Mark current cell as visited and append current character 
	// to str 
	visited[i][j] = true; 
	str = str + boggle[i][j]; 

	// If str is present in dictionary, then print it 
	if (isWord(str)) {
		res.insert(str);
	}

	// Traverse 8 adjacent cells of boggle[i][j] 
	for (int row = i - 1; row <= i + 1 && row < M; row++) 
		for (int col = j - 1; col <= j + 1 && col < N; col++) 
			if (row >= 0 && col >= 0 && !visited[row][col]) 
				findWordsUtil(boggle, visited, row, col, str); 

	// Erase current character from string and mark visited 
	// of current cell as false 
	str.erase(str.length() - 1); 
	visited[i][j] = false; 
} 

// Prints all words present in dictionary. 
void findWords(vector<vector<char> > boggle) 
{ 
	// Mark all characters as not visited 
	vector<vector<bool> > visited(M, vector<bool>(N, 0));

	// Initialize current string 
	string str = ""; 

	// Consider every character and look for all words 
	// starting with this character 
	for (int i = 0; i < M; i++) 
		for (int j = 0; j < N; j++) 
			findWordsUtil(boggle, visited, i, j, str); 
} 

// Driver program to test above function 
int main() 
{ 
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> dictionary[i];
	sort(dictionary, dictionary + n);
	cin >> M >> N;
	vector<vector<char> > boggle(M, vector<char>(N, '\0'));
	for(int i = 0; i < M; i++)
		for(int j = 0; j < N; j++)
			cin >> boggle[i][j];
	findWords(boggle);
	if(res.size() == 0)
		cout << -1 << endl;
	else{
		for(auto i: res)
			cout << i << " ";
	}
	return 0; 
} 
, In this Programming Language: C++, Now tell me if this Code is compilable or not?