Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define INPUT_FILE_NAME "input.txt"
- #define OUTPUT_FILE_NAME "output.txt"
- #define RESULT_FILE_NAME "result.txt"
- #include <bits/stdc++.h>
- #define _a second.first.first
- #define _b second.first.second
- #define _x second.second.first
- #define _y second.second.second
- #define _s first.first
- #define _f first.second
- using namespace std;
- int main()
- {
- ifstream input(INPUT_FILE_NAME);
- ifstream output(OUTPUT_FILE_NAME);
- int r, c, f, n, b, t;
- input >> r >> c >> f >> n >> b >> t;
- vector<pair<pair<int, int>, pair<pair<int, int>, pair<int, int>>>> moves(n);
- for(int i = 0; i < n; i++)
- {
- input >> moves[i]._a >> moves[i]._b >> moves[i]._x >> moves[i]._y >> moves[i]._s >> moves[i]._f;
- }
- vector<bool> used(n, false);
- input.close();
- long long score = 0;
- while(f-->0)
- {
- int m, curr_t = 0, curr_r = 0, curr_c = 0;
- output >> m;
- for(int i = 0; i < m && curr_t <= t; i++)
- {
- int ri;
- output >> ri;
- if(used[ri])
- {
- score = 0;
- goto show_result;
- }
- used[ri] = true;
- curr_t += abs(moves[ri]._a - curr_r) + abs(moves[ri]._b - curr_c);
- if(curr_t <= moves[ri]._s) score += b;
- curr_t = max(curr_t, moves[ri]._s);
- int dist = abs(moves[ri]._a - moves[ri]._x) + abs(moves[ri]._b - moves[ri]._y);
- curr_t += dist;
- if(curr_t <= moves[ri]._f) score += dist;
- curr_r = moves[ri]._x;
- curr_c = moves[ri]._y;
- }
- }
- show_result:
- output.close();
- ofstream result(RESULT_FILE_NAME);
- result << score << "\n";
- result.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement