답안 #472754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472754 2021-09-14T09:30:00 Z Mr_Ph Tetris (COCI17_tetris) C++14
80 / 80
1 ms 204 KB
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int dx[4] = {0, 0, 1, -1};
//int dy[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<vector<char>>arr(n,vector<char>(m));
    int cnt=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0;
    for(int i=0; i<n; i++)
        for(int k=0; k<m; k++)
            cin>>arr[i][k];
    for(int i=0; i<n; i++)
        for(int k=0; k<m; k++)
        {
            if(arr[i][k]!='.')
            {
                if(k+3<m&&arr[i][k]==arr[i][k+1]&&arr[i][k+1]==arr[i][k+2]&&arr[i][k+2]==arr[i][k+3])
                    cnt2++;
                else if(i+3<n&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+2][k]&&arr[i+2][k]==arr[i+3][k])
                    cnt2++;
                else if(i+1<n&&k+1<m&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i][k+1]&&arr[i][k+1]==arr[i+1][k+1])
                    cnt++;
                else if(i+1<n&&k+1<m&&k-1>=0&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i][k+1]&&arr[i][k+1]==arr[i+1][k-1])
                    cnt3++;
                else if(i+2<n&&k+1<m&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+1][k+1]&&arr[i+1][k+1]==arr[i+2][k+1])
                    cnt3++;
                else if(i+1<n&&k+2<m&&arr[i][k]==arr[i][k+1]&&arr[i][k+1]==arr[i+1][k+1]&&arr[i+1][k+1]==arr[i+1][k+2])
                    cnt4++;
                else if(i+2<n&&k-1>=0&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+1][k-1]&&arr[i+1][k-1]==arr[i+2][k-1])
                    cnt4++;
                else if(i+1<n&&k+1<m&&k-1>=0&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+1][k+1]&&arr[i+1][k+1]==arr[i+1][k-1])
                    cnt5++;
                else if(i+2<n&&k-1>=0&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+1][k-1]&&arr[i+1][k-1]==arr[i+2][k])
                    cnt5++;
                else if(k+2<m&&i+1<n&&arr[i][k]==arr[i+1][k+1]&&arr[i+1][k+1]==arr[i][k+1]&&arr[i][k+1]==arr[i][k+2])
                    cnt5++;
                else if(i+2<n&&k+1<m&&arr[i][k]==arr[i+1][k]&&arr[i+1][k]==arr[i+1][k+1]&&arr[i+1][k+1]==arr[i+2][k])
                    cnt5++;

            }
        }
            cout<<cnt<<endl<<cnt2<<endl<<cnt3<<endl<<cnt4<<endl<<cnt5;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    //freopen("window.in","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;//int st;
    //cin>>t;//cin>>st;
    while(t--)
        solve();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct