fork download
  1. /*CodeChef is a non-commercial competitive programming community Hello a_r_k1
  2.  
  3. Logout
  4. PRACTICE
  5. COMPETE
  6. DISCUSS
  7. COMMUNITY
  8. HELP
  9. ABOUT
  10. CodeChef SnackDown 2016Compete & win $22.5K Qualifier ends on 05 June, SUN 9:00 PM IST Duration: 24 hrs
  11. -28
  12. Min
  13. -42
  14. Sec Join Now
  15. Home » SnackDown Online Pre-elimination round A » Longest Increasing Subsequences » All Submissions » kussoooooooooo [10302510]
  16. Solution: 10302510
  17. CodeSNCKPA16. By kussoooooooooo (kussoooooooooo), 2016-06-04 21:20:38.*/
  18. #define _USE_MATH_DEFINES
  19. #include <algorithm>
  20. #include <cstdio>
  21. #include <functional>
  22. #include <iostream>
  23. #include <cfloat>
  24. #include <climits>
  25. #include <cstdlib>
  26. #include <cstring>
  27. #include <cmath>
  28. #include <map>
  29. #include <queue>
  30. #include <random>
  31. #include <set>
  32. #include <sstream>
  33. #include <stack>
  34. #include <string>
  35. #include <time.h>
  36. #include <vector>
  37. using namespace std;
  38.  
  39. typedef long long ll;
  40. typedef unsigned long long ull;
  41. typedef pair<int, int> i_i;
  42. typedef pair<ll, int> ll_i;
  43. typedef pair<double, int> d_i;
  44. typedef pair<ll, ll> ll_ll;
  45. typedef pair<double, double> d_d;
  46. struct edge { int u, v; ll w; };
  47.  
  48. int INF = INT_MAX / 2;
  49. ll MOD = 1000000007;
  50. ll _MOD = 1000000009;
  51. double EPS = 1e-10;
  52.  
  53. int main() {
  54. int T; cin >> T;
  55. while (T--) {
  56. ll K; cin >> K;
  57. vector<i_i> xy;
  58. for (int i = 0; i < 33; i++) {
  59. xy.push_back(i_i(i * 4 + 1, i * 2));
  60. if (i) xy.push_back(i_i(i * 4, i * 2 + 1));
  61. }
  62. for (int i = 0; i < 33; i++) {
  63. int dx = -1;
  64. if (K>>i & 1) dx = 2;
  65. xy.push_back(i_i(i * 4 + dx, 1000 + i));
  66. }
  67. sort(xy.begin(), xy.end());
  68. vector<int> a;
  69. for (i_i p: xy) a.push_back(p.second + 1);
  70. vector<int> A = a;
  71. sort(A.begin(), A.end());
  72. for (int i = 0; i < a.size(); i++)
  73. a[i] = lower_bound(A.begin(), A.end(), a[i]) - A.begin();
  74. cout << a.size() << endl;
  75. for (int i = 0; i < a.size(); i++)
  76. cout << a[i] + 1 << (i + 1 < a.size() ? ' ' : '\n');
  77. }
  78. }
  79.  
  80. /*Comments
  81. CodeChef is a non-commercial competitive programming community
  82. About CodeChef About Directi CEO's Corner C-Programming Programming Languages Contact Us
  83. © 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
  84. In order to report copyright violations of any kind, send in an email to copyright@codechef.com
  85. CodeChef a product of Directi
  86. The time now is: 09:27:41 PM
  87. Your IP: 116.203.90.60
  88. CodeChef - A Platform for Aspiring Programmers
  89. CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.
  90. Practice Section - A Place to hone your 'Computer Programming Skills'
  91. Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.
  92. Compete - Monthly Programming Contests and Cook-offs
  93. Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to INR 20,000 (for Indian Community), $700 (for Global Community) and lots more CodeChef goodies up for grabs.
  94.  
  95. Programming Tools Practice Problems Initiatives
  96. Online IDE Easy Go for Gold
  97. Upcoming Coding Contests Medium CodeChef for Schools
  98. Contest Hosting Hard Campus Chapters
  99. Problem Setting Challenge
  100. CodeChef Tutorials Peer
  101. CodeChef Wiki School
  102. FAQ's */
  103.  
Success #stdin #stdout 0.01s 5276KB
stdin
5
1 2 3 4 5
stdout
98
1 66 67 3 2 68 5 4 69 7 6 70 9 8 71 11 10 72 13 12 73 15 14 74 17 16 75 19 18 76 21 20 77 23 22 78 25 24 79 27 26 80 29 28 81 31 30 82 33 32 83 35 34 84 37 36 85 39 38 86 41 40 87 43 42 88 45 44 89 47 46 90 49 48 91 51 50 92 53 52 93 55 54 94 57 56 95 59 58 96 61 60 97 63 62 98 65 64
98
66 1 3 2 67 68 5 4 69 7 6 70 9 8 71 11 10 72 13 12 73 15 14 74 17 16 75 19 18 76 21 20 77 23 22 78 25 24 79 27 26 80 29 28 81 31 30 82 33 32 83 35 34 84 37 36 85 39 38 86 41 40 87 43 42 88 45 44 89 47 46 90 49 48 91 51 50 92 53 52 93 55 54 94 57 56 95 59 58 96 61 60 97 63 62 98 65 64
98
1 66 3 2 67 68 5 4 69 7 6 70 9 8 71 11 10 72 13 12 73 15 14 74 17 16 75 19 18 76 21 20 77 23 22 78 25 24 79 27 26 80 29 28 81 31 30 82 33 32 83 35 34 84 37 36 85 39 38 86 41 40 87 43 42 88 45 44 89 47 46 90 49 48 91 51 50 92 53 52 93 55 54 94 57 56 95 59 58 96 61 60 97 63 62 98 65 64
98
66 1 67 3 2 5 4 68 69 7 6 70 9 8 71 11 10 72 13 12 73 15 14 74 17 16 75 19 18 76 21 20 77 23 22 78 25 24 79 27 26 80 29 28 81 31 30 82 33 32 83 35 34 84 37 36 85 39 38 86 41 40 87 43 42 88 45 44 89 47 46 90 49 48 91 51 50 92 53 52 93 55 54 94 57 56 95 59 58 96 61 60 97 63 62 98 65 64
98
1 66 67 3 2 5 4 68 69 7 6 70 9 8 71 11 10 72 13 12 73 15 14 74 17 16 75 19 18 76 21 20 77 23 22 78 25 24 79 27 26 80 29 28 81 31 30 82 33 32 83 35 34 84 37 36 85 39 38 86 41 40 87 43 42 88 45 44 89 47 46 90 49 48 91 51 50 92 53 52 93 55 54 94 57 56 95 59 58 96 61 60 97 63 62 98 65 64