Submission #472723

#TimeUsernameProblemLanguageResultExecution timeMemory
472723BidoTeimaTetris (COCI17_tetris)C++17
16 / 80
1 ms204 KiB
/// isA AC #include <bits/stdc++.h> using namespace std; using ll = long long; void ACPLS(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } #define tc int tttttt;cin>>tttttt;while(tttttt--) #define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1]) int dx[8]={0,1,0,-1,1,-1,1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; int n,m; vector<vector<char>>grid; vector<vector<bool>>vis; bool valid(int x, int y, char c){ return x>=1&&x<=n&&y>=1&&y<=m&&vis[x][y]==0&&grid[x][y]==c; } void dfs(int x, int y){ if(vis[x][y]) return; vis[x][y]=1; for(int i = 0; i < 8; i++){ if(valid(x+dx[i],y+dy[i],grid[x][y])){ dfs(x+dx[i],y+dy[i]); } } } int main(){ ACPLS(); cin>>n>>m; grid=vector<vector<char>>(n+5,vector<char>(m+5)); vis=vector<vector<bool>>(n+5,vector<bool>(m+5,0)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin>>grid[i][j]; } } int ans=0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(!vis[i][j]&&grid[i][j]!='.'){ dfs(i,j); ++ans; } } } cout<<ans<<'\n'; for(int i = 0; i < 4; i++) cout<<"0\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...