Language: C++

#include<iostream>
using namespace std;

int F[102][102];

bool DFS(int X, int Y, int Xg, int Yg, int c){
	if(F[Y][X] != c){
		return false;
	}else if(F[Y][X] == c && X == Xg && Y == Yg){
		return true;
	}
	F[Y][X] = -1;
	if(DFS(X, Y - 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X + 1, Y, Xg, Yg, c)){
		return true;
	}else if(DFS(X, Y + 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X - 1, Y, Xg, Yg, c)){
		return true;
	}
	
	return false;
}

int main(){

while(true){
	int w, h;
	cin >> w >> h;
	if(w == 0 && h == 0){
		break;
	}
	int xs, ys, xg, yg;
	cin >> xs >> ys >> xg >> yg;
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int c, d, x, y;
		cin >> c >> d >> x >> y;
		if(d == 0){
			for(int X = x; X < x + 4; X++){
				for(int Y = y; Y < y + 2; Y++){
					F[Y][X] = c;
				}
			}
		}else if(d == 1){
			for(int X = x; X < x + 2; X++){
				for(int Y = y; Y < y + 4; Y++){
					F[Y][X] = c;
				}
			}
		}
	}
	if(DFS(xs, ys, xg, yg, F[xg][yg])){
		cout << "OK" << "\n";
	}else{
		cout << "NG" << "\n";#include<iostream>
using namespace std;

int F[102][102];

bool DFS(int X, int Y, int Xg, int Yg, int c){
	if(F[Y][X] != c){
		return false;
	}else if(F[Y][X] == c && X == Xg && Y == Yg){
		return true;
	}
	F[Y][X] = -1;
	if(DFS(X, Y - 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X + 1, Y, Xg, Yg, c)){
		return true;
	}else if(DFS(X, Y + 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X - 1, Y, Xg, Yg, c)){
		return true;
	}
	
	return false;
}

int main(){
bool isfirst = true;
while(true){
	if(isfirst){
		isfirst = false;
	}else{
		cout << endl;
	}
	int w, h;
	cin >> w >> h;
	if(w == 0 && h == 0){
		break;
	}
	int xs, ys, xg, yg;
	cin >> xs >> ys >> xg >> yg;
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int c, d, x, y;
		cin >> c >> d >> x >> y;
		if(d == 0){
			for(int X = x; X < x + 4; X++){
				for(int Y = y; Y < y + 2; Y++){
					F[Y][X] = c;
				}
			}
		}else if(d == 1){
			for(int X = x; X < x + 2; X++){
				for(int Y = y; Y < y + 4; Y++){
					F[Y][X] = c;
				}
			}
		}
	}
	if(DFS(xs, ys, xg, yg, F[xg][yg])){
		cout << "OK";
	}else{
		cout << "NG";
	}
}
	return 0;
}
	}
}
	return 0;
}

Compiler output:
a.cc:59:38: error: stray '#' in program
   59 |                 cout << "NG" << "\n";#include<iostream>
      |                                      ^
a.cc: In function 'int main()':
a.cc:59:39: error: 'include' was not declared in this scope
   59 |                 cout << "NG" << "\n";#include<iostream>
      |                                       ^~~~~~~
a.cc:59:55: error: expected primary-expression before '>' token
   59 |                 cout << "NG" << "\n";#include<iostream>
      |                                                       ^
a.cc:60:1: error: expected primary-expression before 'using'
   60 | using namespace std;
      | ^~~~~
a.cc:64:46: error: a function-definition is not allowed here before '{' token
   64 | bool DFS(int X, int Y, int Xg, int Yg, int c){
      |                                              ^
a.cc:84:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   84 | int main(){
      |         ^~
a.cc:84:9: note: remove parentheses to default-initialize a variable
   84 | int main(){
      |         ^~
      |         --
a.cc:84:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:84:11: error: a function-definition is not allowed here before '{' token
   84 | int main(){
      |           ^