Advertisement
Guest User

Untitled

a guest
May 28th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <queue>
  5. #include <stack>
  6. #include <map>
  7. #include <algorithm>
  8. #include <numeric>
  9. #include <functional>
  10. #include <set>
  11. #include <sstream>
  12. #include <cstdio>
  13. #include <cstdlib>
  14. #include <cstring>
  15. #include <cmath>
  16. #include <cctype>
  17. #include <climits>
  18. #include <fstream>
  19. #include <time.h>
  20.  
  21. #define FOR(i,a,b) for(int i=(a);i<(b);++i)
  22. #define FORE(i,a,b) for(int i=(a);i<=(b);++i)
  23. #define REP(i,n) FOR(i,0,n)
  24. #define REPE(i,n) FORE(i,0,n)
  25. #define FOE(i,a) for(auto i : a)
  26. #define ALL(c) (c).begin(), (c).end()
  27. #define DUMP(x) cerr << #x << " = " << (x) << endl;
  28. #define SUM(x) std::accumulate(ALL(x), 0L)
  29.  
  30. using namespace std;
  31.  
  32. struct MiddleCode {
  33. string s;
  34. string encode(string _s) {
  35. s = _s;
  36. string t = "";
  37. while (s.size() != 0) {
  38. int half = s.size() / 2;
  39. int del_idx = half;
  40. if (s.size() % 2 == 0 && s[half - 1] < s[half]) {
  41. del_idx = half - 1;
  42. }
  43. t += s[del_idx];
  44. s.erase(del_idx, 1);
  45. }
  46. return t;
  47. }
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement