Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28685 gaochunzhen 【BJ】T1 C++ 运行出错 0 3179 MS 272 KB 6551 2024-04-28 19:41:17

Tests(21/26):


#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6 + 9; struct TET { string Name; int type, px[4], py[4]; } bl[29]; string NUMBER[4]; int rev[29], PX[4], PY[4], A[5][5], no_use[29]; void init() { NUMBER[1] = "1", NUMBER[2] = "2", NUMBER[3] = "3"; bl[1].Name = "Z", bl[1].type = 1; bl[1].px[0] = 0, bl[1].px[1] = 0, bl[1].px[2] = 1, bl[1].px[3] = 1; bl[1].py[0] = 0, bl[1].py[1] = 1, bl[1].py[2] = 1, bl[1].py[3] = 2; bl[5].Name = "S", bl[5].type = 2; bl[5].px[0] = 0, bl[5].px[1] = 0, bl[5].px[2] = 1, bl[5].px[3] = 1; bl[5].py[0] = 1, bl[5].py[1] = 2, bl[5].py[2] = 0, bl[5].py[3] = 1; bl[9].Name = "J", bl[9].type = 3; bl[9].px[0] = 0, bl[9].px[1] = 1, bl[9].px[2] = 1, bl[9].px[3] = 1; bl[9].py[0] = 0, bl[9].py[1] = 0, bl[9].py[2] = 1, bl[9].py[3] = 2; bl[13].Name = "L", bl[13].type = 4; bl[13].px[0] = 0, bl[13].px[1] = 1, bl[13].px[2] = 1, bl[13].px[3] = 1; bl[13].py[0] = 2, bl[13].py[1] = 0, bl[13].py[2] = 1, bl[13].py[3] = 2; bl[17].Name = "T", bl[17].type = 5; bl[17].px[0] = 0, bl[17].px[1] = 1, bl[17].px[2] = 1, bl[17].px[3] = 1; bl[17].py[0] = 1, bl[17].py[1] = 0, bl[17].py[2] = 1, bl[17].py[3] = 2; bl[21].Name = "O", bl[21].type = 6; bl[21].px[0] = 0, bl[21].px[1] = 0, bl[21].px[2] = 1, bl[21].px[3] = 1; bl[21].py[0] = 0, bl[21].py[1] = 1, bl[21].py[2] = 0, bl[21].py[3] = 1; bl[25].Name = "I", bl[25].type = 7; bl[25].px[0] = 0, bl[25].px[1] = 0, bl[25].px[2] = 0, bl[25].px[3] = 0; bl[25].py[0] = 0, bl[25].py[1] = 1, bl[25].py[2] = 2, bl[25].py[3] = 3; for (int i = 1; i <= 7; i++) { for (int j = 1; j <= 3; j++) { int _i = (i - 1) * 4 + 1 + j, mx = 1e9, my = 1e9; for (int k = 0; k <= 3; k++) { bl[_i].px[k] = bl[_i - 1].py[k]; bl[_i].py[k] = -bl[_i - 1].px[k]; mx = min(mx, bl[_i].px[k]), my = min(my, bl[_i].py[k]); } for (int k = 0; k <= 3; k++) { bl[_i].px[k] -= mx, bl[_i].py[k] -= my; } bl[_i].type = i, bl[_i].Name = bl[(i - 1) * 4 + 1].Name + NUMBER[j]; } bl[(i - 1) * 4 + 1].Name += "0"; } for (int i = 1; i <= 28; i++) { for (int j = 0; j <= 3; j++) { A[bl[i].py[j]][bl[i].px[j]] = 1; } for (int j = 1; j <= 28; j++) { int fl = 1; for (int k = 0; k <= 3; k++) { if (!A[bl[j].px[k]][bl[j].py[k]]) { fl = 0; break; } } if (fl) { rev[i] = j; break; } } for (int j = 0; j <= 3; j++) { A[bl[i].py[j]][bl[i].px[j]] = 0; } } no_use[3] = no_use[4] = no_use[7] = no_use[8] = no_use[22] = no_use[23] = no_use[24] = no_use[27] = no_use[28] = 1; } int n, m, tot, a[N], cnt[9]; int id(int x, int y) {return (x - 1) * m + y;} bool chk(int x, int y, int t) { for (int i = 0; i <= 3; i++) { int _x = x + bl[t].px[i], _y = y + bl[t].py[i]; if (_x > n || _y > m || a[id(_x, _y)]) return 0; } return 1; } int ans[N][3], tp, fl; void dfs(int x, int y) { if (clock() * 1000 >= 990ll * CLOCKS_PER_SEC) { printf("No\n"); exit(0); } if (y > m) { for (int j = 1; j <= m; j++) if (!a[id(x, j)]) return; if (x < n) dfs(x + 1, 1); else { printf("Yes\n"); for (int i = 1; i <= tp; i++) { int _x = ans[i][0], _y = ans[i][1], t = ans[i][2]; if (!fl) cout << bl[t].Name << ' ' << _x << ' ' << _y << endl; else cout << bl[rev[t]].Name << ' ' << _y << ' ' << _x << endl; // cout << "{" << t << ", " << _x << ", " << _y << "}, "; } exit(0); } return; } dfs(x, y + 1); for (int i = 1; i <= 28; i++) { if (no_use[i] || cnt[bl[i].type] == tot || !chk(x, y, i)) continue; for (int j = 0; j <= 3; j++) { int _x = x + bl[i].px[j], _y = y + bl[i].py[j]; a[id(_x, _y)] = 1; } ans[++tp][0] = x, ans[tp][1] = y, ans[tp][2] = i; cnt[bl[i].type]++; dfs(x, y + 1); for (int j = 0; j <= 3; j++) { int _x = x + bl[i].px[j], _y = y + bl[i].py[j]; a[id(_x, _y)] = 0; } tp--, cnt[bl[i].type]--; } } int unit8[19][3] = {{0, 0, 0}, {1, 1, 1}, {1, 1, 3}, {11, 1, 5}, {6, 2, 1}, {6, 2, 6}, {10, 3, 3}, {18, 3, 5}, {18, 4, 1}, {14, 4, 4}, {21, 5, 6}, {16, 6, 2}, {21, 7, 1}, {25, 7, 4}, {25, 8, 4}}; int unit4[19][3] = {{0, 0, 0}, {6, 1, 1}, {9, 3, 1}, {1, 1, 2}, {1, 3, 3}, {16, 1, 4}, {6, 1, 6}, {9, 3, 6}, {19, 1, 7}, {25, 3, 8}, {17, 1, 9}, {25, 4, 9}, {16, 1, 11}, {21, 1, 13}, {21, 3, 13}}; int main() { scanf("%d%d", &n, &m); if (n * m % 28) { printf("No\n"); fclose(stdin); fclose(stdout); return 0; } tot = n * m / 28; init(); if (n % 7 == 0 && m % 7 != 0) swap(n, m), fl ^= 1; if (n % 8 == 0) { printf("Yes\n"); for (int i = 0; i < n; i += 8) { for (int j = 0; j < m; j += 7) { for (int k = 1; k <= 14; k++) { int _x = i + unit8[k][1], _y = j + unit8[k][2], t = unit8[k][0]; if (!fl) cout << bl[t].Name << ' ' << _x << ' ' << _y << endl; else cout << bl[rev[t]].Name << ' ' << _y << ' ' << _x << endl; } } } fclose(stdin); fclose(stdout); return 0; } else if (n % 4 == 0) { if (m % 14) { printf("No\n"); fclose(stdin); fclose(stdout); return 0; } printf("Yes\n"); for (int i = 0; i < n; i += 4) { for (int j = 0; j < m; j += 14) { for (int k = 1; k <= 14; k++) { int _x = i + unit4[k][1], _y = j + unit4[k][2], t = unit4[k][0]; if (!fl) cout << bl[t].Name << ' ' << _x << ' ' << _y << endl; else cout << bl[rev[t]].Name << ' ' << _y << ' ' << _x << endl; } } } fclose(stdin); fclose(stdout); return 0; } if (n < m) swap(n, m), fl ^= 1; dfs(1, 1); printf("No\n"); return 0; }


测评信息: