Submission #472755

#TimeUsernameProblemLanguageResultExecution timeMemory
472755Ahmed_SolymanTetris (COCI17_tetris)C++14
64 / 80
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,m; bool valid(ll i,ll j){ if(i>=0 && j>=0 && i<n && j<m)return 1; return 0; } int main() { cin>>n>>m; vector<string>arr(n); for(auto &i:arr)cin>>i; ll a=0,b=0,c=0,d=0,e=0; map<pair<ll,ll>,bool>vis; for(ll i=0;i<n;i++){ for(ll j=0;j<m;j++){ if(vis[{i,j}])continue; /// st 2 if(valid(i,j+1) && valid(i+1,j) && valid(i+1,j+1)){ if(arr[i][j]==arr[i][j+1] && arr[i][j+1]==arr[i+1][j] && arr[i+1][j]==arr[i+1][j+1] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i,j+1}]=1; vis[{i+1,j}]=1; vis[{i+1,j+1}]=1; a++; } } /// st 2 if(valid(i,j+1) && valid(i,j+2) && valid(i,j+3)){ if(arr[i][j]==arr[i][j+1] && arr[i][j+1]==arr[i][j+2] && arr[i][j+2]==arr[i][j+3] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i,j+1}]=1; vis[{i,j+2}]=1; vis[{i,j+3}]=1; b++; } } if(valid(i+1,j) && valid(i+2,j) && valid(i+3,j)){ if(arr[i][j]==arr[i+1][j] && arr[i+1][j]==arr[i+2][j] && arr[i+2][j]==arr[i+3][j] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i+1,j}]=1; vis[{i+2,j}]=1; vis[{i+3,j}]=1; b++; } } /// st 3 if(valid(i,j+1) && valid(i-1,j+1) && valid(i-1,j+2)){ if(arr[i][j]==arr[i][j+1] && arr[i][j+1]==arr[i-1][j+1] && arr[i-1][j+1]==arr[i-1][j+2] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i,j+1}]=1; vis[{i-1,j+1}]=1; vis[{i-1,j+2}]=1; c++; } } if(valid(i+1,j) && valid(i+1,j+1) && valid(i+2,j+1)){ if(arr[i][j]==arr[i+1][j] && arr[i+1][j]==arr[i+1][j+1] && arr[i+1][j+1]==arr[i+2][j+1] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i+1,j}]=1; vis[{i+1,j+1}]=1; vis[{i+2,j+1}]=1; c++; } } /// st 4 if(valid(i,j+1) && valid(i+1,j+1) && valid(i+1,j+2)){ if(arr[i][j]==arr[i][j+1] && arr[i][j+1]==arr[i+1][j+1] && arr[i+1][j+1]==arr[i+1][j+2] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i,j+1}]=1; vis[{i+1,j+1}]=1; vis[{i+1,j+2}]=1; d++; } } if(valid(i+1,j) && valid(i+1,j-1) && valid(i+2,j-1)){ if(arr[i][j]==arr[i+1][j] && arr[i+1][j]==arr[i+1][j-1] && arr[i+1][j-1]==arr[i+2][j-1] && arr[i][j]!='.'){ vis[{i,j}]=1; vis[{i+1,j}]=1; vis[{i+1,j-1}]=1; vis[{i+2,j-1}]=1; d++; } } } } cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl<<e<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...