Submission #928142

# Submission time Handle Problem Language Result Execution time Memory
928142 2024-02-15T21:41:06 Z xad Tetris (COCI17_tetris) C++14
80 / 80
1 ms 460 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));
int fx[]={1,-1,0,0}, fy[]={0,0,1,-1};
int n,m; char ar[12][12]; int v[12][12];
bool check(int i, int j, char c) {
return (i>=0&&i<n&&j>=0&&j<m&&ar[i][j]==c&&!v[i][j]);
}
int nm(int i, int j) {
    int b=0,c=0,d=0;
    b=check(i,j+1,ar[i][j]), c=check(i-1,j,ar[i][j]), d=check(i-1,j+1,ar[i][j]);
    if (b&&c&&d) {
     v[i][j+1]=v[i-1][j]=v[i-1][j+1]=v[i][j]=1;
     return 1;
    }
    b=check(i,j+1,ar[i][j]), c=check(i, j+2,ar[i][j]), d=check(i,j+3,ar[i][j]);
    if (b&&c&&d) {
     v[i][j+1]=v[i][j+2]=v[i][j+3]=v[i][j]=1;
     return 2;
    }
    b=check(i-1,j,ar[i][j]), c=check(i-2,j,ar[i][j]), d=check(i-3,j,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j]=v[i-2][j]=v[i-3][j]=v[i][j]=1;
     return 2;
    }
    b=check(i,j+1,ar[i][j]), c=check(i,j+2,ar[i][j]), d=check(i-1,j+1,ar[i][j]);
    if (b&&c&&d) {
     v[i][j+1]=v[i][j+2]=v[i-1][j+1]=v[i][j]=1;
     return 5;
    }
    b=check(i-1,j,ar[i][j]), c=check(i-2,j,ar[i][j]), d=check(i-1,j-1,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j]=v[i-2][j]=v[i-1][j-1]=v[i][j]=1;
     return 5;
    }
    b=check(i-1,j,ar[i][j]), c=check(i-1,j-1,ar[i][j]), d=check(i-1,j+1,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j]=v[i-1][j-1]=v[i-1][j+1]=v[i][j]=1;
     return 5;
    }
    b=check(i-1,j+1,ar[i][j]), c=check(i-1,j,ar[i][j]), d=check(i-2,j,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j+1]=v[i-1][j]=v[i-2][j]=v[i][j]=1;
     return 5;
    }
    b=check(i,j+1,ar[i][j]), c=check(i-1,j+1,ar[i][j]), d=check(i-1,j+2,ar[i][j]);
    if (b&&c&&d) {
     v[i][j+1]=v[i-1][j+1]=v[i-1][j+2]=v[i][j]=1;
     return 3;
    }
    b=check(i-1,j,ar[i][j]), c=check(i-1,j-1,ar[i][j]), d=check(i-2,j-1,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j]=v[i-1][j-1]=v[i-2][j-1]=v[i][j]=1;
     return 3;
    }
    b=check(i,j+1,ar[i][j]), c=check(i-1,j,ar[i][j]), d=check(i-1,j-1,ar[i][j]);
    if (b&&c&&d) {
     v[i][j+1]=v[i-1][j]=v[i-1][j-1]=v[i][j]=1;
     return 4;
    }
    b=check(i-1,j,ar[i][j]), c=check(i-1,j+1,ar[i][j]), d=check(i-2,j+1,ar[i][j]);
    if (b&&c&&d) {
     v[i-1][j]=v[i-1][j+1]=v[i-2][j+1]=v[i][j]=1;
     return 4;
    }
    return 0;
}
int main() {
    /*freopen("measurement.in","r",stdin);
    freopen("measurement.out","w", stdout);*/

    x_x
    cin>>n>>m;
   for (int i=0; i<n; i++) {
    for(int j=0; j<m; j++) cin>>ar[i][j], v[i][j]=0;
   }
   int x[6]={};
   for (int i=n-1; i>=0; i--) {
        for (int j=0; j<m; j++) {
            if (!v[i][j]&&ar[i][j]!='.') x[nm(i,j)]++;
        }
   }
   for (int i=1; i<6; i++) {
    cout<<x[i]; if(i!=5)cout<<nn;
   }
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 0 ms 348 KB Output is correct