Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #define INPUT_FILE_NAME "input.txt"
  2. #define OUTPUT_FILE_NAME "output.txt"
  3. #define RESULT_FILE_NAME "result.txt"
  4. #include <bits/stdc++.h>
  5. #define _a second.first.first
  6. #define _b second.first.second
  7. #define _x second.second.first
  8. #define _y second.second.second
  9. #define _s first.first
  10. #define _f first.second
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     ifstream input(INPUT_FILE_NAME);
  16.     ifstream output(OUTPUT_FILE_NAME);
  17.     int r, c, f, n, b, t;
  18.     input >> r >> c >> f >> n >> b >> t;
  19.     vector<pair<pair<int, int>, pair<pair<int, int>, pair<int, int>>>> moves(n);
  20.     for(int i = 0; i < n; i++)
  21.     {
  22.         input >> moves[i]._a >> moves[i]._b >> moves[i]._x >> moves[i]._y >> moves[i]._s >> moves[i]._f;
  23.     }
  24.     vector<bool> used(n, false);
  25.     input.close();
  26.     long long score = 0;
  27.     while(f-->0)
  28.     {
  29.         int m, curr_t = 0, curr_r = 0, curr_c = 0;
  30.         output >> m;
  31.         for(int i = 0; i < m && curr_t <= t; i++)
  32.         {
  33.             int ri;
  34.             output >> ri;
  35.             if(used[ri])
  36.             {
  37.                 score = 0;
  38.                 goto show_result;
  39.             }
  40.             used[ri] = true;
  41.             curr_t += abs(moves[ri]._a - curr_r) + abs(moves[ri]._b - curr_c);
  42.             if(curr_t <= moves[ri]._s) score += b;
  43.             curr_t = max(curr_t, moves[ri]._s);
  44.             int dist = abs(moves[ri]._a - moves[ri]._x) + abs(moves[ri]._b - moves[ri]._y);
  45.             curr_t += dist;
  46.             if(curr_t <= moves[ri]._f) score += dist;
  47.             curr_r = moves[ri]._x;
  48.             curr_c = moves[ri]._y;
  49.         }
  50.     }
  51.     show_result:
  52.     output.close();
  53.     ofstream result(RESULT_FILE_NAME);
  54.     result << score << "\n";
  55.     result.close();
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement