Advertisement
Guest User

Untitled

a guest
Sep 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. /*
  2. в”Џв•— в”Џв•—
  3. ║┃ ║┃╔━╦╦┳═╗
  4. в•‘в”ѓ в”ѓв•љв”«в•‘в”ѓв”ѓв”ѓв•©в”«
  5. в”—в•ќ в•љв”Ѓв•©в•ђв”»в”Ѓв•©в”Ѓв•ќ
  6. в•”в”“в•”в”“
  7. ║╚┛┣═╦┳╗
  8. в”—в•—в”Џв•Јв”ѓв”ѓв•‘в”ѓ
  9. в”—в•ќв”—в•ђв”»в•ђв•ќ
  10. */
  11. #include <bits/stdc++.h>
  12. #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  13. #define int long long
  14. #define double long double
  15. #define pii pair<int, int>
  16. #define vi vector <int>
  17. #define pb push_back
  18. #define fir first
  19. #define sec second
  20. #define all(x) (x).begin(), (x).end()
  21. #define rall(x) (x).rbegin(), (x).rend()
  22. #define sz(a) signed(a.size())
  23. using namespace std;
  24. const double pi = 3.141592653589793238462643383279;
  25. const int MOD = 998244353;
  26. const int INF = 1e9;
  27. const double eps = 0.000000000000001;
  28.  
  29. template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
  30. template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
  31. template<class T> inline istream& operator>>(istream& str, vector <T> &a) { for (auto &i : a) str >> i; return str; }
  32.  
  33.  
  34. void boot_up() {
  35. #ifdef LOCAL
  36. freopen("input.txt", "r", stdin);
  37. //freopen("output.txt", "w", stdout);
  38. #endif
  39. fast;
  40. cout.setf(ios::fixed); cout.precision(15);
  41. }
  42.  
  43. signed main(){
  44. boot_up();
  45. //freopen("input.txt", "r", stdin);
  46. //freopen("g.txt", "w", stdout);
  47. ifstream fin("f.txt");
  48. ofstream fout("g.txt");
  49. int last = 0, fl = 0;
  50. string s;
  51. while (getline(fin, s)) {
  52. int res = 0;
  53. //cout << s[0] << endl;
  54. int poin = 0;
  55. while (s[poin] == ' ') poin++;
  56. if (s[poin] - '0' >= 0 && s[poin] - '9' <= 0) {
  57. int p = poin;
  58. while (p < s.size() && s[p] - '0' >= 0 && s[p] - '0' <= 9) {
  59. p++;
  60. }
  61. int k = 1;
  62. for (int i = p - 1; i >= poin; i--) {
  63. res += (s[i] - '0') * k;
  64. k *= 10;
  65. }
  66. if (s.size() <= p) {
  67. if (fl == 1 && res >= last) continue;
  68. if (fl == 28 && res <= last) continue;
  69. }
  70. if (!fl) {
  71. p++;
  72. if (s[p] == 'D') fl = 1;
  73. else fl = 28;
  74. } else fl = 0;
  75.  
  76.  
  77. } else if (s[poin] == 'D') {
  78. if (fl == 28) continue;
  79. res = 1;
  80. fl = 0;
  81. } else if (s[poin] == 'U') {
  82. if (fl == 1) continue;
  83. res = 28;
  84. fl = 0;
  85. }
  86. if (res == last) continue;
  87. fout << res << endl;
  88. last = res;
  89. }
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement