Submission #472758

# Submission time Handle Problem Language Result Execution time Memory
472758 2021-09-14T09:39:45 Z Ahmed_Solyman Tetris (COCI17_tetris) C++14
80 / 80
1 ms 204 KB
#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++;
                }
            }
            /// st 5
            if(valid(i+1,j) && valid(i+1,j-1) && valid(i+1,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+1][j+1] && arr[i][j]!='.'){
                    vis[{i,j}]=1;
                    vis[{i+1,j}]=1;
                    vis[{i+1,j-1}]=1;
                    vis[{i+1,j+1}]=1;
                    e++;
                }
            }
            if(valid(i+1,j) && valid(i+1,j+1) && valid(i+2,j)){
                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] && arr[i][j]!='.'){
                    vis[{i,j}]=1;
                    vis[{i+1,j}]=1;
                    vis[{i+1,j+1}]=1;
                    vis[{i+2,j}]=1;
                    e++;
                }
            }
            if(valid(i,j-1) && valid(i,j+1) && valid(i+1,j)){
                if(arr[i][j]==arr[i][j-1] && arr[i][j-1]==arr[i][j+1] && arr[i][j+1]==arr[i+1][j] && arr[i][j]!='.'){
                    vis[{i,j}]=1;
                    vis[{i,j-1}]=1;
                    vis[{i,j+1}]=1;
                    vis[{i+1,j}]=1;
                    e++;
                }
            }
            if(valid(i+1,j) && valid(i+1,j-1) && valid(i+2,j)){
                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] && arr[i][j]!='.'){
                    vis[{i,j}]=1;
                    vis[{i+1,j}]=1;
                    vis[{i+1,j-1}]=1;
                    vis[{i+2,j}]=1;
                    e++;
                }
            }
        }
    }
    cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl<<e<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct