답안 #510192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510192 2022-01-14T18:50:11 Z khaled_whebe Tetris (COCI17_tetris) C++17
64 / 80
1 ms 204 KB
#include<bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
const int N=555555;
ll n,m,first,sec,thrd,frth,ffth;
char a[100][100];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (ll i=0;i<n;i++)
    {
        for (ll j=0;j<m;j++)
            cin>>a[i][j];
    }
    for (ll i=0;i<n;i++)
    {
        for (ll j=0;j<m;j++)
        {
            if (a[i][j]>=97&&a[i][j]<=122&&a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&i<n-1&&j<m-1)
                first++;
            else if (a[i][j]>=97&&a[i][j]<=122&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i][j+3]&&j<m-3)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+3][j]&&i<n-3))
                sec++;
            else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j-1]&&i<n-1&&j<m-1&&j>0)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+2][j+1]&&i<n-2&&j<m-1))
                thrd++;
            else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+1][j+2]&&j<m-2&&i<n-1)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j-1]&&a[i][j]==a[i+2][j-1]&&i<n-2&&j>0))
                frth++;
            else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+1][j-1])||(a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i+1][j+1])||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+1][j+1])||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+1][j-1]))
                ffth++;

        }
    }
    cout<<first<<endl<<sec<<endl<<thrd<<endl<<frth<<endl<<ffth<<endl;
    return 0;
}

Compilation message

tetris.cpp: In function 'int main()':
tetris.cpp:23:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |             else if (a[i][j]>=97&&a[i][j]<=122&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i][j+3]&&j<m-3)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+3][j]&&i<n-3))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tetris.cpp:25:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   25 |             else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j-1]&&i<n-1&&j<m-1&&j>0)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+2][j+1]&&i<n-2&&j<m-1))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tetris.cpp:27:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |             else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+1][j+2]&&j<m-2&&i<n-1)||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j-1]&&a[i][j]==a[i+2][j-1]&&i<n-2&&j>0))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tetris.cpp:29:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   29 |             else if (a[i][j]<=122&&a[i][j]>=97&&(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+1][j-1])||(a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i+1][j+1])||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+1][j+1])||(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+1][j-1]))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 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 1 ms 204 KB Output is correct