Submission #237056

#TimeUsernameProblemLanguageResultExecution timeMemory
237056MrRobot_28Tetris (COCI17_tetris)C++17
80 / 80
5 ms384 KiB
#include<bits/stdc++.h> using namespace std; signed main() { int n, m; cin >> n >> m; vector <vector <char> > A(n, vector <char> (m)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> A[i][j]; } } vector <int> ans(5); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(A[i][j] == '.') { continue; } if(i > 0 && j > 0 && A[i][j] == A[i - 1][j] && A[i - 1][j] == A[i][j - 1] && A[i - 1][j - 1] == A[i][j]) { ans[0]++; } if(i > 2 && A[i - 3][j] == A[i][j] && A[i - 2][j] == A[i][j] && A[i - 1][j] == A[i][j]) { ans[1]++; } if(j > 2 && A[i][j - 3] == A[i][j] && A[i][j - 2] == A[i][j] && A[i][j - 1] == A[i][j]) { ans[1]++; } if(i > 1 && j > 0 && A[i - 1][j] == A[i][j] && A[i - 1][j - 1] == A[i][j] && A[i - 2][j - 1] == A[i][j]) { ans[2]++; } if(i < n - 1 && j > 1 && A[i][j - 1] == A[i][j] && A[i + 1][j - 1] == A[i][j] && A[i + 1][j - 2] == A[i][j]) { ans[2]++; } if(i > 0 && j > 1 && A[i][j - 1] == A[i][j] && A[i - 1][j - 1] == A[i][j] && A[i - 1][j - 2] == A[i][j]) { ans[3]++; } if(i > 1 && j < m - 1 && A[i - 1][j] == A[i][j] && A[i -1 ][j + 1] == A[i][j] && A[i - 2][j + 1] == A[i][j]) { ans[3]++; } if(i > 0 && j > 0 && i < n - 1 && A[i - 1][j] == A[i][j] && A[i + 1][j] == A[i][j] && A[i][j - 1] == A[i][j]) { ans[4]++; } if(i > 0 && j > 0 && j < m - 1 && A[i - 1][j] == A[i][j] && A[i][j - 1] == A[i][j] && A[i][j + 1] == A[i][j]) { ans[4]++; } if(i < n - 1 && j > 0 && j < m - 1 && A[i][j] == A[i + 1][j] && A[i][j - 1] == A[i][j] && A[i][j + 1] == A[i][j]) { ans[4]++; } if(i > 0 && i < n - 1 && j < m - 1 && A[i][j] == A[i - 1][j] && A[i][j] == A[i][j + 1] && A[i][j] == A[i + 1][j]) { ans[4]++; } } } for(int i = 0; i < 5; i++) { cout << ans[i] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...