Submission #884307

# Submission time Handle Problem Language Result Execution time Memory
884307 2023-12-07T06:34:05 Z vjudge1 Tetris (COCI17_tetris) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 2e5+1;
const int MOD = 1e9+7;

void solve() {
  int n,m;
  cin >> n >> m;
  char a[n+1][m+1];
  bool ctd[n+1][m+1];
  memset(ctd,0,sizeof ctd);
  F(i,n) {
    string s;
    cin >> s;
    F(j,m) a[i][j] = s[j-1];
  }
  vi ans(6,0);
  F(i,n) {
    F(j,m) {
      if (a[i][j] == '.') continue;
      if (ctd[i][j]) continue;
      if (i<n-1 && j<m) {
        if (a[i][j] == a[i+1][j] && a[i+1][j]==a[i+1][j+1] && a[i+1][j+1]==a[i+2][j+1]) {
          ctd[i][j] = ctd[i+1][j] = ctd[i+1][j+1] = ctd[i+2][j+1] = 1;
          ans[3]++;
          continue;
        }
      }
      if (i<n && j>1 && j<m) {
        if (a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j] && a[i][j] == a[i+1][j-1]) {
          ctd[i][j]  = ctd[i][j+1] = ctd[i+1][j] = ctd[i+1][j-1] = 1;
          ans[3]++;
          continue;
        }
      }
      if (i<n-1 && j>1) {
        if (a[i][j] == a[i+1][j] && a[i+1][j]==a[i+1][j-1] && a[i+1][j-1]==a[i+2][j-1]) {
          ctd[i][j] = ctd[i+1][j] = ctd[i+1][j-1] = ctd[i+2][j-1] = 1;
          ans[4]++;
          continue;
        }
      }
      if (i<n && j<m-1) {
        if (a[i][j] == a[i][j+1] && a[i][j+1] == a[i+1][j+1] && a[i+1][j+1] == a[i+1][j+2]) {
          ctd[i][j]  = ctd[i][j+1] = ctd[i+1][j+1] = ctd[i+1][j+2] = 1;
          ans[4]++;
          continue;
        }
      }
    }
  }
  vi dx = {0,1,0,-1};
  vi dy = {1,0,-1,0};
  int adj[n+5][m+5];
  memset(adj,0,sizeof adj);
  F(i,n) {
    F(j,m) {
      for (int k=0;k<4;k++) {
        int gx = i+dx[k];
        int gy = j+dy[k];
        if (gx >= 1 && gx <= n && gy >= 1 && gy <= m && a[gx][gy]>='a' && a[gx][gy]<='z' && a[gx][gy] == a[i][j]) {
          adj[i][j]++;
        }
      }
    }
  }
  F(i,n) {
    F(j,m) {
      if (adj[i][j] == 3) {
        ans[5]++;
        ctd[i][j] = ctd[i][j+1] = ctd[i][j-1] = ctd[i-1][j] = 1;
    }
  }
  F(i,n){
    F(j,m) {
      if (a[i][j] == '.') continue;
      if (ctd[i][j]) continue;
      if (i<n && j<m && a[i][j] == a[i+1][j] && a[i+1][j] == a[i][j+1] && a[i][j+1] == a[i+1][j+1] && adj[i][j] == 2 && adj[i+1][j]==2 && adj[i][j+1] == 2 && adj[i+1][j+1] == 2) {
        ans[1]++;
      }
      if (adj[i][j] == 1 && adj[i][j+1] == 2 && adj[i][j+2] == 2 && adj[i][j+3] == 1) {
        ans[2]++;
      }
    }
  }
  F(i,5) cout << ans[i] << "\n";
}
    
                  
                             
signed main() { 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #ifdef Local
  freopen("in","r",stdin);
  freopen("out","w",stdout); 
  #endif
  int t = 1;
  //cin >> t;
	F(i,t) solve();
}

Compilation message

tetris.cpp: In function 'void solve()':
tetris.cpp:96:15: error: a function-definition is not allowed here before '{' token
   96 | signed main() {
      |               ^
tetris.cpp:105:1: error: expected '}' at end of input
  105 | }
      | ^
tetris.cpp:11:14: note: to match this '{'
   11 | void solve() {
      |              ^