Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- в”Џв•— в”Џв•—
- ║┃ ║┃╔━╦╦┳═╗
- в•‘в”ѓ в”ѓв•љв”«в•‘в”ѓв”ѓв”ѓв•©в”«
- в”—в•ќ в•љв”Ѓв•©в•ђв”»в”Ѓв•©в”Ѓв•ќ
- в•”в”“в•”в”“
- ║╚┛┣═╦┳╗
- в”—в•—в”Џв•Јв”ѓв”ѓв•‘в”ѓ
- в”—в•ќв”—в•ђв”»в•ђв•ќ
- */
- #include <bits/stdc++.h>
- #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
- #define int long long
- #define double long double
- #define pii pair<int, int>
- #define vi vector <int>
- #define pb push_back
- #define fir first
- #define sec second
- #define all(x) (x).begin(), (x).end()
- #define rall(x) (x).rbegin(), (x).rend()
- #define sz(a) signed(a.size())
- using namespace std;
- const double pi = 3.141592653589793238462643383279;
- const int MOD = 998244353;
- const int INF = 1e9;
- const double eps = 0.000000000000001;
- template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
- template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
- template<class T> inline istream& operator>>(istream& str, vector <T> &a) { for (auto &i : a) str >> i; return str; }
- void boot_up() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- #endif
- fast;
- cout.setf(ios::fixed); cout.precision(15);
- }
- signed main(){
- boot_up();
- //freopen("input.txt", "r", stdin);
- //freopen("g.txt", "w", stdout);
- ifstream fin("f.txt");
- ofstream fout("g.txt");
- int last = 0, fl = 0;
- string s;
- while (getline(fin, s)) {
- int res = 0;
- //cout << s[0] << endl;
- int poin = 0;
- while (s[poin] == ' ') poin++;
- if (s[poin] - '0' >= 0 && s[poin] - '9' <= 0) {
- int p = poin;
- while (p < s.size() && s[p] - '0' >= 0 && s[p] - '0' <= 9) {
- p++;
- }
- int k = 1;
- for (int i = p - 1; i >= poin; i--) {
- res += (s[i] - '0') * k;
- k *= 10;
- }
- if (s.size() <= p) {
- if (fl == 1 && res >= last) continue;
- if (fl == 28 && res <= last) continue;
- }
- if (!fl) {
- p++;
- if (s[p] == 'D') fl = 1;
- else fl = 28;
- } else fl = 0;
- } else if (s[poin] == 'D') {
- if (fl == 28) continue;
- res = 1;
- fl = 0;
- } else if (s[poin] == 'U') {
- if (fl == 1) continue;
- res = 28;
- fl = 0;
- }
- if (res == last) continue;
- fout << res << endl;
- last = res;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement