记录编号 569990 评测结果 AAAAAAAAAAAAAAA
题目名称 [USACO Final95]奶牛排队 最终得分 100
用户昵称 Gravatarlihaoze 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2022-03-20 23:32:18 内存使用 0.00 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <vector>
  6. #include <string>
  7. #include <deque>
  8. #define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
  9. #define MAX(_a, _b) [&](int __a, int __b) { return __a < __b ? __b : __a; }((_a), (_b))
  10. #define MIN(_a, _b) [&](int __a, int __b) { return __a > __b ? __b : __a; }((_a), (_b))
  11. #define ABS(_x) [&](int __x) { return __x < 0 ? -__x : __x; }(_x)
  12. #define INT(_x) int _x = IO::read<int>();
  13. #define fi first
  14. #define se second
  15.  
  16. using ll = long long;
  17. using PII = std::pair<int, int>;
  18.  
  19. namespace IO {
  20. template <typename T> inline T read() {
  21. char ch = getchar();
  22. T ret = 0, sig = 1;
  23. while(ch < '0' || ch > '9') { if(ch == '-') sig = -1; ch = getchar(); }
  24. while(ch >= '0' && ch <= '9') ret *= 10, ret += ch - 48, ch = getchar();
  25. return ret * sig;
  26. }
  27. template <typename T> inline void write(T out) {
  28. if(!out) { putchar('0'), putchar(' '); return; }
  29. int stk[100], tt = 0;
  30. if(out < 0) out = -out, putchar('-');
  31. while(out) stk[tt++] = out % 10, out /= 10;
  32. for(register int i = --tt; i>=0; --i) putchar(stk[i] + 48);
  33. putchar(' ');
  34. }
  35. template <typename T> inline void read(T& ret) { ret = IO::read<T>(); }
  36. template <typename T, typename... Args> inline void read(T& x, Args&... args) { IO::read(x), IO::read(args...); }
  37. template <typename T, typename... Args> inline void write(T x, Args... args) { IO::write(x), IO::write(args...); }
  38. };
  39.  
  40.  
  41. const int N = 1 << 15;
  42. int n;
  43. std::vector<int> chosen[N], a;
  44.  
  45. inline void mk_g() {
  46. int m = 1 << ( n - 1 );
  47. int tmp = m - 1;
  48. for (register int i = 0; i < m; ++i) {
  49. chosen[i].emplace_back(((i << 1) + 1) & tmp);
  50. chosen[i].emplace_back((i << 1) & tmp);
  51. }
  52. }
  53.  
  54. inline void euler(int x) {
  55. while (chosen[x].size()) {
  56. int u = chosen[x][0];
  57. chosen[x].erase(chosen[x].begin());
  58. euler(u);
  59. }
  60. a.emplace_back(x);
  61. }
  62.  
  63. int main() {
  64. #ifdef DEBUG
  65. OPEN(test);
  66. #endif
  67. OPEN(cowsonparade);
  68. IO::read(n);
  69.  
  70. if(n == 1 ) {
  71. IO::write(0, 1);
  72. return 0;
  73. }
  74.  
  75. mk_g();
  76. euler(0);
  77.  
  78. std::reverse(a.begin(), a.end());
  79.  
  80. int len = a.size();
  81. for (register int i = 1; i<n-1; ++i) putchar(48), putchar(' ');
  82. for (register int i = 0; i<len; ++i) putchar((a[i] & 1) + 48), putchar(' ');
  83.  
  84. return 0;
  85. }