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. -1
  12. Days
  13. -1
  14. Hrs
  15. -28
  16. Min
  17. -42
  18. Sec Join Now
  19. Home » SnackDown Online Pre-elimination round A » Longest Increasing Subsequences » All Submissions » kussoooooooooo [10302510]
  20. Solution: 10302510
  21. CodeSNCKPA16. By kussoooooooooo (kussoooooooooo), 2016-06-04 21:20:38.*/
  22. #define _USE_MATH_DEFINES
  23. #include <algorithm>
  24. #include <cstdio>
  25. #include <functional>
  26. #include <iostream>
  27. #include <cfloat>
  28. #include <climits>
  29. #include <cstdlib>
  30. #include <cstring>
  31. #include <cmath>
  32. #include <map>
  33. #include <queue>
  34. #include <random>
  35. #include <set>
  36. #include <sstream>
  37. #include <stack>
  38. #include <string>
  39. #include <time.h>
  40. #include <vector>
  41. using namespace std;
  42.  
  43. typedef long long ll;
  44. typedef unsigned long long ull;
  45. typedef pair<int, int> i_i;
  46. typedef pair<ll, int> ll_i;
  47. typedef pair<double, int> d_i;
  48. typedef pair<ll, ll> ll_ll;
  49. typedef pair<double, double> d_d;
  50. struct edge { int u, v; ll w; };
  51.  
  52. int INF = INT_MAX / 2;
  53. ll MOD = 1000000007;
  54. ll _MOD = 1000000009;
  55. double EPS = 1e-10;
  56.  
  57. int main() {
  58. int T; cin >> T;
  59. while (T--) {
  60. ll K; cin >> K;
  61. vector<i_i> xy;
  62. for (int i = 0; i < 33; i++) {
  63. xy.push_back(i_i(i * 4 + 1, i * 2));
  64. if (i) xy.push_back(i_i(i * 4, i * 2 + 1));
  65. }
  66. for (int i = 0; i < 33; i++) {
  67. int dx = -1;
  68. if (K>>i & 1) dx = 2;
  69. xy.push_back(i_i(i * 4 + dx, 1000 + i));
  70. }
  71. sort(xy.begin(), xy.end());
  72. vector<int> a;
  73. for (i_i p: xy) a.push_back(p.second + 1);
  74. vector<int> A = a;
  75. sort(A.begin(), A.end());
  76. for (int i = 0; i < a.size(); i++)
  77. a[i] = lower_bound(A.begin(), A.end(), a[i]) - A.begin();
  78. cout << a.size() << endl;
  79. for (int i = 0; i < a.size(); i++)
  80. cout << a[i] + 1 << (i + 1 < a.size() ? ' ' : '\n');
  81. }
  82. }
  83.  
  84. /*Comments
  85. CodeChef is a non-commercial competitive programming community
  86. About CodeChef About Directi CEO's Corner C-Programming Programming Languages Contact Us
  87. © 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
  88. In order to report copyright violations of any kind, send in an email to copyright@codechef.com
  89. CodeChef a product of Directi
  90. The time now is: 09:27:41 PM
  91. Your IP: 116.203.90.60
  92. CodeChef - A Platform for Aspiring Programmers
  93. 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.
  94. Practice Section - A Place to hone your 'Computer Programming Skills'
  95. 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.
  96. Compete - Monthly Programming Contests and Cook-offs
  97. 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.
  98.  
  99. Programming Tools Practice Problems Initiatives
  100. Online IDE Easy Go for Gold
  101. Upcoming Coding Contests Medium CodeChef for Schools
  102. Contest Hosting Hard Campus Chapters
  103. Problem Setting Challenge
  104. CodeChef Tutorials Peer
  105. CodeChef Wiki School
  106. FAQ's */
  107.  
Success #stdin #stdout 0.01s 5480KB
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