Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void write_sample(const string& s, map<int, char>& chars) {
- }
- signed main() {
- freopen("program.in", "r", stdin);
- const int max_states = 228;
- const int max_actions = 1488;
- map<int, char> chars;
- map<pair<int, char>, tuple<int, char, int>> prog;
- set<int> states;
- int actions = 0;
- write_sample("00111000", chars);
- int cur_st, new_st, shift;
- char cur_ch, new_ch;
- while (cin >> cur_st) {
- cin >> cur_ch >> new_st >> new_ch >> shift;
- prog[{ cur_st, cur_ch }] = { new_st, new_ch, shift };
- }
- int state = 1, pos = 0;
- while (state != 0) {
- if (!chars.count(pos)) {
- chars[pos] = '!';
- }
- assert(prog.count({ state, chars[state] })); // netu perehoda
- auto [new_st, new_ch, shift] = prog[{ state, chars[pos] }];
- chars[pos] = new_ch;
- state = new_st;
- pos += shift;
- states.insert(state);
- ++actions;
- assert(states.size() <= max_states);
- assert(actions <= max_actions);
- }
- string ans;
- while (chars.count(pos) && chars[pos] != '!') {
- ans += chars[pos];
- ++pos;
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement