답안 #165176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165176 2019-11-25T15:32:23 Z theStaticMind Tetris (COCI17_tetris) C++14
80 / 80
10 ms 8440 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<vector<int>> A(1000,vector<int>(1000,'.'));
vector<vector<bool>>vis(1000,vector<bool>(1000,false));
int ans[5]={0};
bool one(int a,int b){
      int key=A[a][b];
      if(key==A[a+1][b]&&A[a][b+1]==key&&A[a+1][b+1]==key){
            vis[a][b]=vis[a+1][b]=vis[a][b+1]=vis[a+1][b+1]=true;
            ans[0]++;
            return true;
      }
      return false;
}
bool two(int a,int b){
      int key=A[a][b];
      if(A[a][b+1]==key&&A[a][b+2]==key&&A[a][b+3]==key){
            vis[a][b]=vis[a][b+1]=vis[a][b+2]=vis[a][b+3]=true;
            ans[1]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+2][b]==key&&A[a+3][b]==key){
            vis[a][b]=vis[a+1][b]=vis[a+2][b]=vis[a+3][b]=true;
            ans[1]++;
            return true;
      }
      return false;
}
bool three(int a,int b){
      int key=A[a][b];
      if(A[a][b+1]==key&&A[a+1][b]==key&&A[a+1][b-1]==key){
            vis[a][b]=vis[a][b+1]=vis[a+1][b]=vis[a+1][b-1]=true;
            ans[2]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+1][b+1]==key&&A[a+2][b+1]==key){
            vis[a][b]=vis[a+1][b]=vis[a+1][b+1]=vis[a+2][b+1]=true;
            ans[2]++;
            return true;
      }
      return false;
}
bool four(int a,int b){
      int key=A[a][b];
      if(A[a][b+1]==key&&A[a+1][b+1]==key&&A[a+1][b+2]==key){
            vis[a][b]=vis[a][b+1]=vis[a+1][b+1]=vis[a+1][b+2]=true;
            ans[3]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+1][b-1]==key&&A[a+2][b-1]==key){
            vis[a][b]=vis[a+1][b]=vis[a+1][b-1]=vis[a+2][b-1]=true;
            ans[3]++;
            return true;
      }
      return false;
}
bool five(int a,int b){
      int key=A[a][b];
      if(A[a][b+1]==key&&A[a][b+2]==key&&A[a+1][b+1]==key){
            vis[a][b]=vis[a][b+1]=vis[a][b+2]=vis[a+1][b+1]=true;
            ans[4]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+1][b+1]==key&&A[a+1][b-1]==key){
            vis[a][b]=vis[a+1][b+1]=vis[a+1][b]=vis[a+1][b-1]=true;
            ans[4]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+2][b]==key&&A[a+1][b+1]==key){
            vis[a][b]=vis[a+1][b]=vis[a+2][b]=vis[a+1][b+1]=true;
            ans[4]++;
            return true;
      }
      if(A[a+1][b]==key&&A[a+2][b]==key&&A[a+1][b-1]==key){
            vis[a][b]=vis[a+1][b]=vis[a+2][b]=vis[a+1][b-1]=true;
            ans[4]++;
            return true;
      }
      return false;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
 //     freopen("q.gir","r",stdin);
 //     freopen("q.cik","w",stdout);
      int n,m;
      cin>>n>>m;
      for(int i=10;i<n+10;i++){
            string s;
            cin>>s;
            for(int j=10;j<m+10;j++){
                  A[i][j]=s[j-10];
            }
      }
      for(int i=10;i<n+10;i++){
            for(int j=10;j<m+10;j++){
                  if(A[i][j]=='.'||vis[i][j])continue;
                  if(one(i,j));
                  else if(two(i,j));
                  else if(three(i,j));
                  else if(four(i,j));
                  else if(five(i,j));
            }
      }
      for(int i=0;i<5;i++)cout<<ans[i]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 10 ms 8184 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8312 KB Output is correct
5 Correct 9 ms 8312 KB Output is correct
6 Correct 9 ms 8312 KB Output is correct
7 Correct 9 ms 8440 KB Output is correct
8 Correct 9 ms 8440 KB Output is correct
9 Correct 9 ms 8312 KB Output is correct
10 Correct 9 ms 8312 KB Output is correct