Submission #167257

#TimeUsernameProblemLanguageResultExecution timeMemory
167257foolifish07Tetris (COCI17_tetris)C++11
0 / 80
4 ms1276 KiB
#include <bits/stdc++.h> #include <vector> #include <string> #include <bitset> #include <algorithm> #include <iostream> #include <cstdio> using namespace std; const int maxn = 30010 * 4; int h[maxn], w[maxn]; int score, scoreCnt; int x[4], y[4]; int m, n; void calc() { int cnt = 0; for(int i = 0; i < 4; i++) { w[y[i]]++; if (w[y[i]] == m) { cnt++; } h[x[i]] = max(h[x[i]], y[i]); } // for(int i = 0; i < 4; i++) { // cout << "(" << x[i] << ", " << y[i] << ") " ; // } cout << endl; if (cnt == 1) { score += 100; } else if (cnt == 2) { score += 250; } else if (cnt == 3) { score += 400; } else if (cnt == 4) { score += 1000; } scoreCnt += cnt; } void getxy6h(int pos, int rh[][2]) { int maxh = 0; for(int i = 0; i < 3; i++) { if (rh[i][0] != 0) { maxh = max(maxh, h[pos + i]); } else { maxh = max(maxh, h[pos + i] - 1); } } int nn = 0; for(int i = 0; i < 3; i++) { for(int j = 0; j < 2; j++) { if (rh[i][j] == 1 && nn < 4) { x[nn] = pos + i; y[nn] = maxh + j + 1; nn++; } } } } void getxy6w(int pos, int rw[][3]) { int maxh = 0; for(int i = 0; i < 2; i++) { if (rw[i][0] != 0) { maxh = max(maxh, h[pos + i]); } else if (rw[i][1] != 0){ maxh = max(maxh, h[pos + i] - 1); } else { maxh = max(maxh, h[pos + i] - 2); } } int nn = 0; for(int i = 0; i < 2; i++) { for(int j = 0; j < 3; j++) { if (rw[i][j] == 1 && nn < 4) { x[nn] = pos + i; y[nn] = maxh + j + 1; nn++; } } } } void solve() { char s[10]; memset(h, 0, sizeof(h)); memset(w, 0, sizeof(w)); scanf("%d%d", &m, &n); score = 0; scoreCnt = 0; for (int ii = 1; ii <= n; ii++) { int pos, rotate; scanf("%s%d%d", s, &pos, &rotate); if (s[0] == 'I') { if (rotate == 0 || rotate == 180) { int maxh = 0; for(int i = 0; i < 4; i++) { maxh = max(h[pos + i], maxh); } for(int i = 0; i < 4; i++) { x[i] = pos + i; y[i] = maxh + 1; } } else { for(int i = 0; i < 4; i++) { x[i] = pos; y[i] = h[pos] + i + 1; } } calc(); } else if (s[0] == 'J') { if (rotate == 0) { int rh[3][2] = { 1, 1, 1, 0, 1, 0 }; getxy6h(pos, rh); calc(); } else if (rotate == 90) { int rw[2][3] = { 1, 1, 1, 0, 0, 1 }; getxy6w(pos, rw); calc(); } else if (rotate == 180) { int rh[3][2] = { 0, 1, 0, 1, 1, 1 }; getxy6h(pos, rh); calc(); } else { int rw[3][2] = { 1, 0, 0, 1, 1, 1 }; getxy6h(pos, rw); calc(); } } else if (s[0] == 'L') { if (rotate == 0) { int rh[3][2] = { 1, 0, 1, 0, 1, 1 }; getxy6h(pos, rh); calc(); } else if (rotate == 90) { int rw[2][3] = { 1, 1, 1, 1, 0, 0 }; getxy6w(pos, rw); calc(); } else if (rotate == 180) { int rh[3][2] = { 1, 1, 0, 1, 0, 1 }; getxy6h(pos, rh); calc(); } else { int rw[2][3] = { 0, 0, 1, 1, 1, 1 }; getxy6w(pos, rw); calc(); } } else if (s[0] == 'O') { int rw[2][3] = { 1, 1, 0, 1, 1, 0 }; getxy6w(pos, rw); calc(); } else if (s[0] == 'S') { if (rotate == 0 || rotate == 180) { int rh[3][2] = { 1, 0, 1, 1, 0, 1 }; getxy6h(pos, rh); calc(); } else { int rw[2][3] = { 0, 1, 1, 1, 1, 0 }; getxy6w(pos, rw); calc(); } } else if (s[0] == 'T') { if (rotate == 0) { int rh[3][2] = { 1, 0, 1, 1, 1, 0 }; getxy6h(pos, rh); calc(); } else if (rotate == 90) { int rw[2][3] = { 1, 1, 1, 0, 1, 0 }; getxy6w(pos, rw); calc(); } else if (rotate == 180) { int rh[3][2] = { 0, 1, 1, 1, 0, 1 }; getxy6h(pos, rh); calc(); } else if (rotate == 270) { int rw[2][3] = { 0, 1, 0, 1, 1, 1 }; getxy6w(pos, rw); calc(); } } else if (s[0] == 'Z') { if (rotate == 0 || rotate == 180) { int rh[3][2] = { 0, 1, 1, 1, 1, 0 }; getxy6h(pos, rh); calc(); } else { int rw[2][3] = { 1, 1, 0, 0, 1, 1 }; getxy6w(pos, rw); calc(); } } } printf("%d\n", score); for(int i = 0; i < m; i++) { printf("%d ", h[i] - scoreCnt); } printf("\n"); } int main() { int t; scanf("%d", &t); for(int i = 1; i <= t; i++) { printf("Case #%d:\n", i); solve(); } return 0; }

Compilation message (stderr)

tetris.cpp: In function 'void solve()':
tetris.cpp:95:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &m, &n);
     ~~~~~^~~~~~~~~~~~~~~~
tetris.cpp:100:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s%d%d", s, &pos, &rotate);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
tetris.cpp: In function 'int main()':
tetris.cpp:210:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...