Submission #472885

#TimeUsernameProblemLanguageResultExecution timeMemory
472885AbdoMoTetris (COCI17_tetris)C++17
80 / 80
1 ms204 KiB
#include<bits/stdc++.h> #define int long long #define ll long long #define pb push_back const int mod = 1e9+7; using namespace std; bool comp(string a,string b) { if(a.size()==b.size()) { return a<b; } return a.size()<b.size(); } char mat[20][20]; bool vis[20][20]; bool f1(int i,int j) { char x=mat[i][j]; if(mat[i+1][j]==x && mat[i][j+1]==x && mat[i+1][j+1]==x) { if((vis[i+1][j]==0 && vis[i][j+1]==0 && vis[i+1][j+1]==0)) { vis[i][j]=1; vis[i+1][j]=1; vis[i][j+1]=1; vis[i+1][j+1]=1; return 1; } } return 0; } bool f2(int i,int j) { char x=mat[i][j]; if(mat[i+1][j]==x && mat[i+2][j]==x && mat[i+3][j]==x) { if((vis[i+1][j]==0 && vis[i+2][j]==0 && vis[i+3][j]==0)) { vis[i][j]=1; vis[i+1][j]=1; vis[i+2][j]=1; vis[i+3][j]=1; return 1; } } if(mat[i][j+1]==x && mat[i][j+2]==x && mat[i][j+3]==x) { if((vis[i][j+1]==0 && vis[i][j+2]==0 && vis[i][j+3]==0)) { vis[i][j]=1; vis[i][j+1]=1; vis[i][j+2]=1; vis[i][j+3]=1; return 1; } } return 0; } bool f3(int i,int j) { char x=mat[i][j]; if(mat[i+1][j]==x && mat[i][j-1]==x && mat[i-1][j-1]==x) { if((vis[i+1][j]==0 && vis[i][j-1]==0 && vis[i-1][j-1]==0)) { vis[i][j]=1; vis[i+1][j]=1; vis[i][j-1]=1; vis[i-1][j-1]=1; return 1; } } if(mat[i][j-1]==x && mat[i-1][j]==x && mat[i-1][j+1]==x) { if((vis[i][j-1]==0 && vis[i-1][j]==0 && vis[i-1][j+1]==0)) { vis[i][j]=1; vis[i][j-1]=1; vis[i-1][j]=1; vis[i-1][j+1]=1; return 1; } } return 0; } bool f4(int i,int j) { char x=mat[i][j]; if(mat[i+1][j]==x && mat[i][j+1]==x && mat[i-1][j+1]==x) { if((vis[i+1][j]==0 && vis[i][j+1]==0 && vis[i-1][j+1]==0)) { vis[i][j]=1; vis[i+1][j]=1; vis[i][j+1]=1; vis[i-1][j+1]=1; return 1; } } if(mat[i][j+1]==x && mat[i-1][j]==x && mat[i-1][j-1]==x) { if((vis[i][j+1]==0 && vis[i-1][j]==0 && vis[i-1][j-1]==0)) { vis[i][j]=1; vis[i][j+1]=1; vis[i-1][j]=1; vis[i-1][j-1]=1; return 1; } } return 0; } bool f5(int i,int j) { char x=mat[i][j]; if(mat[i][j+1]==x && mat[i][j-1]==x && mat[i-1][j]==x) { if((vis[i][j+1]==0 && vis[i][j-1]==0 && vis[i-1][j]==0)) { vis[i][j]=1; vis[i][j+1]=1; vis[i][j-1]=1; vis[i-1][j]=1; return 1; } } if(mat[i][j+1]==x && mat[i][j-1]==x && mat[i+1][j]==x) { if((vis[i][j+1]==0 && vis[i][j-1]==0 && vis[i+1][j]==0)) { vis[i][j]=1; vis[i][j+1]=1; vis[i][j-1]=1; vis[i+1][j]=1; return 1; } } if(mat[i][j-1]==x && mat[i-1][j]==x && mat[i+1][j]==x) { if((vis[i][j-1]==0 && vis[i-1][j]==0 && vis[i+1][j]==0)) { vis[i][j]=1; vis[i][j-1]=1; vis[i-1][j]=1; vis[i+1][j]=1; return 1; } } if(mat[i][j+1]==x && mat[i-1][j]==x && mat[i+1][j]==x) { if((vis[i][j+1]==0 && vis[i-1][j]==0 && vis[i+1][j]==0)) { vis[i][j]=1; vis[i][j+1]=1; vis[i-1][j]=1; vis[i+1][j]=1; return 1; } } return 0; } void solve(){ int n,m; cin>>n>>m; memset(vis,0,sizeof(vis)); for(int i=0;i<=n+2;i++) { for(int j=0;j<=m+2;j++) { vis[i][j]=0; mat[i][j]='0'; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>mat[i][j]; } } int fg1=0,fg2=0,fg3=0,fg4=0,fg5=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(vis[i][j])continue; if(mat[i][j]!='.') { fg1+=f1(i,j); fg2+=f2(i,j); fg3+=f3(i,j); fg4+=f4(i,j); fg5+=f5(i,j); } } } cout<<fg1<<endl<<fg2<<endl<<fg3<<endl<<fg4<<endl<<fg5; /* */ } int32_t main(){ int t=1; ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //cin>>t; while(t--){solve();} return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...