| Task: | Lehmät |
| Sender: | Samiismail |
| Submission time: | 2022-10-31 15:19:34 +0200 |
| Language: | C++ (C++17) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'void dfs(int, int)':
input/code.cpp:13:5: error: 'i' was not declared in this scope
13 | vis[i][j]=1;
| ^
input/code.cpp:13:8: error: 'j' was not declared in this scope
13 | vis[i][j]=1;
| ^
input/code.cpp:24:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
24 | int main(){
| ^~
input/code.cpp:24:9: note: remove parentheses to default-initialize a variable
24 | int main(){
| ^~
| --
input/code.cpp:24:9: note: or replace parentheses with braces to value-initialize a variable
input/code.cpp:24:11: error: a function-definition is not allowed here before '{' token
24 | int main(){
| ^
input/code.cpp:43:2: error: expected '}' at end of input
43 | }
| ^
input/code.cpp:12:23: note: to match this '{'
12 | void dfs(int x, int y){
| ^Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, cnt=0, cnt2=0;
vector<vector<char>>g;
int vis[100][100];
int hori[]={1,-1,0,0}, vert[]={0,0,1,-1};
void dfs(int x, int y){
vis[i][j]=1;
for(int i=0; i<4; ++i){
int dx=x+hori[i], dy=y+vert[i];
if(g[x][y]=='@'){
cnt2++;
if(0<=dx && dx<n && 0<=dy && dy< m && !vis[dx][dy]) dfs(dx, dy);
}
cout << cnt2 << "\n";
}
int main(){
cin>>n>>m;
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
if(cnt==0 || cnt==2)vis[i][j]=1;
cin>>g[i][j];
if(g[i][j]=='*'){cnt++; vis[i][j]=1;
}
}
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
if(!vis[i][j]) dfs(i,j);
}
}
}
}
