fork(2) download
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. typedef int ll;
  6. using namespace __gnu_pbds;
  7. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  8. #pragma GCC target ("avx2")
  9. #pragma GCC optimization ("O3")
  10. #pragma GCC optimization ("unroll-loops")
  11. #define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
  12. #define so sizeof
  13. #define pb push_back
  14. #define cl clear() ;
  15. #define vl vector<ll>
  16. #define sz size()
  17. #define len length()
  18. #define emp empty()
  19. #define el endl;cout.flush()
  20. #define be begin()
  21. #define fi first
  22. #define se second
  23. #define br break
  24. #define en end()
  25. #define ro return 0
  26. #define eb emplace_back
  27. #define con continue
  28. #define ms(x) memset(x , 0ll, so x)
  29. #define all(x) (x).be , (x).en
  30. #define acc(x) accumulate((x).be , (x).en , 0ll)
  31. #define forn(i,a,b) for(ll i=a;i<=b;++i)
  32. #define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
  33. #define vll vector<pair<ll,ll> >
  34. #define pll pair<ll,ll>
  35. #define plll pair<ll,pair<ll,ll>>
  36. #define plvl pair<pair<ll,ll> ,ll>
  37. #define mp make_pair
  38. #define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
  39. #define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
  40. #define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
  41. #define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
  42. string Solution::SmallestString(string A, int B, int C) {
  43. string s = "";
  44. s = s + A;
  45. ll r = B ;
  46. ll a = C;
  47. if(a >= 10){
  48. a = a % 10 ;
  49. }
  50. ll n = s.len;
  51. unordered_map<string , ll > mpp;
  52. mpp.cl;
  53. mpp[s] = 1;
  54. queue<string> q;
  55. while(q.emp == false) q.pop();
  56. q.push(s);
  57. vector<string> ways ;
  58. ways.cl ;
  59. ways.pb(s);
  60. while(q.emp == false){
  61. string curr = q.front();
  62. q.pop();
  63. string rot = "";
  64. string add = "";
  65. add = add + curr;
  66. /// rotate it
  67. {
  68. string left = "" , right = "" ;
  69. forn(i , 0 , n - r - 1) left = left + curr[i] ;
  70. forn(i , n - r , n - 1 ) right = right + curr[i] ;
  71. rot = rot + right + left;
  72. }
  73. if(mpp[rot] == 0){
  74. ++mpp[rot];
  75. q.push(rot);
  76. ways.pb(rot);
  77. }
  78. /// add a to all indices ;
  79. if(a > 0 ) {
  80. forn(i , 0 , n - 1 ) {
  81. if(i % 2 == 1 ) {
  82. char c = add[i] ;
  83. ll num = c - '0';
  84. num = num + a;
  85. if(num >= 10){
  86. num = num % 10;
  87. }
  88. char x = num + 48;
  89. add[i] = x;
  90. }
  91. }
  92. }
  93. if(mpp[add] == 0){
  94. ++mpp[add];
  95. q.push(add);
  96. ways.pb(add);
  97. }
  98. }
  99. sort(all(ways));
  100. string coo = "";
  101. coo = coo + ways[0] ;
  102. return coo ;
  103. }
  104.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:42:8: error: ‘Solution’ has not been declared
 string Solution::SmallestString(string A, int B, int C) {
        ^~~~~~~~
stdout
Standard output is empty