ამოხსნების სტატუსი

ამ გვერდზე თქვენ იხილავთ გაგზავნილი ამოხსნების სტატუსს.


გაგზავნის თარიღი: 27.03.2020 01:56:49

ამოცანა: რეგიონების დათვლა

მომხმარებელი: david

ვერდიქტი: ამოუხსნელი

შეფასება: 0 ქულა







#include <iostream>
using namespace std;
int n,ans,i,j;
void rf(int x, int y){
	if(m[x][y]=='v') return;
	m[x][y]='v';
	if(m[x][y-1]=='R') rf(m[x][y-1]);
	if(m[x][y+1]=='R') rf(m[x][y+1]);
	if(m[x-1][y]=='R') rf(m[x-1][y]);
	if(m[x+1][y]=='R') rf(m[x+1][y]);
}
void bf(int x, int y){
	if(m[x][y]=='v') return;
	m[x][y]='v';
	if(m[x][y-1]=='B') bf(m[x][y-1]);
	if(m[x][y+1]=='B') bf(m[x][y+1]);
	if(m[x-1][y]=='B') bf(m[x-1][y]);
	if(m[x+1][y]=='B') bf(m[x+1][y]);
void gf(int x, int y){
	if(m[x][y]=='v') return;
	m[x][y]='v';
	if(m[x][y-1]=='G') gf(m[x][y-1]);
	if(m[x][y+1]=='G') gf(m[x][y+1]);
	if(m[x-1][y]=='G') gf(m[x-1][y]);
	if(m[x+1][y]=='G') gf(m[x+1][y]);
}
}
int main(){
	cin>>n;
	char m[n][n];
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>m[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(m[i][j]=='R') {rf(i,j);ans++}
			if(m[i][j]=='B') {bf(i,j);ans++}
			if(m[i][j]=='G') {gf(i,j);ans++}
		}
	}
	cout<<ans;
}
PROB_cpp_UID778PID278_1495a0/main.cpp: In function 'void rf(int, int)':
PROB_cpp_UID778PID278_1495a0/main.cpp:5:5: error: 'm' was not declared in this scope
  if(m[x][y]=='v') return;
     ^
PROB_cpp_UID778PID278_1495a0/main.cpp:6:2: error: 'm' was not declared in this scope
  m[x][y]='v';
  ^
PROB_cpp_UID778PID278_1495a0/main.cpp: In function 'void bf(int, int)':
PROB_cpp_UID778PID278_1495a0/main.cpp:13:5: error: 'm' was not declared in this scope
  if(m[x][y]=='v') return;
     ^
PROB_cpp_UID778PID278_1495a0/main.cpp:14:2: error: 'm' was not declared in this scope
  m[x][y]='v';
  ^
PROB_cpp_UID778PID278_1495a0/main.cpp:19:22: error: a function-definition is not allowed here before '{' token
 void gf(int x, int y){
                      ^
PROB_cpp_UID778PID278_1495a0/main.cpp: In function 'int main()':
PROB_cpp_UID778PID278_1495a0/main.cpp:38:35: error: expected ';' before '}' token
    if(m[i][j]=='R') {rf(i,j);ans++}
                                   ^
PROB_cpp_UID778PID278_1495a0/main.cpp:39:35: error: expected ';' before '}' token
    if(m[i][j]=='B') {bf(i,j);ans++}
                                   ^
PROB_cpp_UID778PID278_1495a0/main.cpp:40:28: error: 'gf' was not declared in this scope
    if(m[i][j]=='G') {gf(i,j);ans++}
                            ^
PROB_cpp_UID778PID278_1495a0/main.cpp:40:35: error: expected ';' before '}' token
    if(m[i][j]=='G') {gf(i,j);ans++}
                                   ^