fork download
  1. /// Author : Nguyễn Thái Sơn - K18 - KHMT - UIT
  2. /// Training ICPC 2024
  3.  
  4. #include<bits/stdc++.h>
  5.  
  6. /// #pragma GCC optimize("O3,unroll-loops")
  7. /// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  8.  
  9. #define fi first
  10. #define se second
  11. #define TASK "test"
  12. #define pb push_back
  13. #define EL cout << endl
  14. #define Ti20_ntson int main()
  15. #define in(x) cout << x << endl
  16. #define all(x) (x).begin(),(x).end()
  17. #define getbit(x, i) (((x) >> (i)) & 1)
  18. #define cntbit(x) __builtin_popcount(x)
  19. #define FOR(i,l,r) for (int i = l; i <= r; i++)
  20. #define FORD(i,l,r) for (int i = l; i >= r; i--)
  21. #define Debug(a,n) for (int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl
  22.  
  23. using namespace std;
  24.  
  25. typedef long long ll;
  26. typedef vector<int> vi;
  27. typedef pair<int,int> vii;
  28. typedef unsigned long long ull;
  29. typedef vector<vector<int>> vvi;
  30. int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
  31.  
  32. const int N = 5e5 + 5;
  33. const int oo = INT_MAX;
  34. const int mod = 1e9 + 7;
  35. const int d4x[4] = {-1, 0, 1, 0} , d4y[4] = {0, 1, 0, -1};
  36. const int d8x[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  37.  
  38. int n, a[N];
  39. bool dp[370][13][8][8][8][8];
  40.  
  41.  
  42. inline void Read_Input() {
  43. dp[1][6][1][1][1][1] = true;
  44. cin >> n;
  45. }
  46.  
  47. inline void Solve() {
  48. FOR(i, 1, n) {
  49. FOR(j, 1, 16)
  50. cin >> a[i];
  51.  
  52. FOR(vt, 1, 11)
  53. FOR(o1, 0, 6)
  54. FOR(o2, 0, 6)
  55. FOR(o3, 0, 6)
  56. FOR(o4, 0, 6) {
  57. if (dp[i][vt][o1][o2][o3][o4] == false) continue;
  58.  
  59. /// xet cach di len tren
  60. /// vt = 6 -> new_vt = 2
  61. /// 2 - 3
  62. /// 6 - 7
  63. int new_vt = vt - 4;
  64.  
  65. int a1 = vt;
  66. int a2 = vt + 1;
  67. int a3 = vt + 4;
  68. int a4 = a3 + 1;
  69.  
  70. /// chung ta co duoc bang con a1, a2, a3, a4
  71. if (a[a1] == 0 && a[a2] == 0 && a[a3] == 0 && a[a4] == 0) {
  72. /// co the di vao
  73. /// co bao quat duoc goc nao hay khong
  74. /// 1 - 4 - 13 - 16
  75. if (a1 == 1) new_o1 = 0;
  76. if (a2 == 4) new_o2 = 0;
  77. if (a3 == 13) new_o3 = 0;
  78. if (a4 == 16) new_o4 = 0;
  79.  
  80. dp[i + 1][new_ct][new_o1][new_o2][new_o3][new_o4] = true;
  81. }
  82.  
  83. /// chu y len tren 1 hoac 2 buoc.
  84. /// Tuy nhien can luu y : di ra khoi bang
  85.  
  86. /// xet cach di xuong duoi
  87.  
  88. /// xet cach di sang trai
  89.  
  90. /// xet cach di sang phai
  91.  
  92.  
  93. }
  94.  
  95. }
  96. }
  97.  
  98. Ti20_ntson {
  99. freopen(TASK".INP","r",stdin);
  100. freopen(TASK".OUT","w",stdout);
  101. ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  102. int T = 1;
  103. // cin >> T;
  104. while (T -- ) {
  105. Read_Input();
  106. Solve();
  107. }
  108. }
  109.  
  110.  
  111.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty