# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884299 | vjudge1 | Tetris (COCI17_tetris) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
const int lim=2e5+100;
#else
const int lim=2e3+100;
#endif
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define pb push_back
const int mod=1e9+7;
using pii=pair<int,int>;
inline void solve(){
int n,m;
cin>>n>>m;
string g[n];
for(int i=0;i<n;i++){
cin>>g[i];
}
int ans=0;
for(int i=0;i<n-1;i++){
for(int j=0;j<m-1;j++){
if(g[i][j]=='.')continue;
if(g[i][j]==g[i][j+1]&&
g[i][j]==g[i+1][j]&&
g[i][j]==g[i+1][j+1]){
ans++;
}
}
}
cout<<ans<<"\n";
ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m-4;j++){
if(g[i][j]=='.')continue;
if(g[i][j]==g[i][j+1]&&
g[i][j]==g[i][j+2]&&
g[i][j]==g[i][j+3]){
ans++;
}
}
}
for(int i=0;i<n-4;i++){
for(int j=0;j<m;j++){
if(g[i][j]=='.')continue;
if(g[i][j]==g[i+1][j]&&
g[i][j]==g[i+2][j]&&
g[i][j]==g[i+3][j]){
ans++;
}
}
}
cout<<ans<<"\n";
int ans1=0,ans2=0;
for(int i=0;i<n-1;i++){
for(int j=1;j<m-1;j++){
if(g[i][j]=='.')continue;
if(g[i][j]==g[i+1][j]){
if(g[i][j]==g[i][j-1]&&
g[i][j]==g[i+1][j+1]){
ans2++;
}
else if(g[i][j]==g[i][j+1]&&
g[i][j]==g[i+1][j-1]){
ans1++;
}
}
}
}
for(int i=1;i<n-1;i++){
for(int j=0;j<m-1;j++){
if(g[i][j]=='.')continue;
if(g[i][j]==g[i][j+1]){
if(g[i][j]==g[i-1][j]&&
g[i][j]==g[i+1][j+1]){
ans1++;
}
else if(g[i][j]==g[i+1][j]&&
g[i][j]==g[i-1][j+1]){
ans2++;
}
}
}
}
cout<<ans1<<"\n"<<ans2<<"\n";
ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(g[i][j]=='.')continue;
int count=
(i+1<n&&g[i][j]==g[i+1][j])+
(j+1<m&&g[i][j]==g[i][j+1])+
(i&&g[i][j]==g[i-1][j])+
(j&&g[i][j]==g[i][j-1]);
if(count==3){
ans++;
}
}
}
cout<<ans<<"\n";
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#else
//freopen("grass.in","r",stdin);
//freopen("grass.out","w",stdout);
#endif
int t=1;
//cin>>t;
while (t--)
{
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |