Submission #340089

#TimeUsernameProblemLanguageResultExecution timeMemory
340089HazemEmacs (COCI20_emacs)C++14
50 / 50
1 ms876 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 3e3 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; string s[N]; bool vis[N][N]; int x[]={1,-1,0,0}; int y[]={0,0,1,-1}; int n,m; int dfs(int i,int j){ if(vis[i][j]||s[i][j]=='.')return 0; vis[i][j] = 1; for(int k=0;k<4;k++){ int i1 = i+x[k],j1 = j+y[k]; if(i1>=1&&j1>=0&&i1<=n&&j1<m) dfs(i1,j1); } return 1; } int main() { //freopen("out.txt","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) cin>>s[i]; int ans = 0; for(int i=1;i<=n;i++) for(int j=0;j<m;j++) ans += dfs(i,j); printf("%d\n",ans); }

Compilation message (stderr)

emacs.cpp: In function 'int main()':
emacs.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...