Advertisement
Guest User

ADWOKAT

a guest
Nov 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int n, m, *a, *b, *d, *minEndDay, *maxStartDay, *stNum, *ndNum;
  6.  
  7.     std::ios::sync_with_stdio(false);
  8.  
  9.     std::cin >> n >> m;
  10.  
  11.     a = new int[n];
  12.     b = new int[n];
  13.     d = new int[n];
  14.  
  15.     minEndDay = new int[m];
  16.     maxStartDay = new int[m];
  17.     stNum = new int[m];
  18.     ndNum = new int[m];
  19.     for (int i = 0; i < m; i++)
  20.     {
  21.         minEndDay[i] = -1;
  22.         maxStartDay[i] = -1;
  23.     }
  24.    
  25.     for (int i = 0; i < n; i++)
  26.     {
  27.         std::cin >> a[i] >> b[i] >> d[i];
  28.         if ((minEndDay[d[i] - 1] > b[i]) || (minEndDay[d[i] - 1] == -1))
  29.         {
  30.             minEndDay[d[i] - 1] = b[i];
  31.             stNum[d[i] - 1] = i + 1;
  32.         }
  33.         if ((maxStartDay[d[i] - 1] < a[i]) || (maxStartDay[d[i] - 1] == -1))
  34.         {
  35.             maxStartDay[d[i] - 1] = a[i];
  36.             ndNum[d[i] - 1] = i + 1;
  37.         }
  38.     }
  39.  
  40.     for (int i = 0; i < m; i++)
  41.     {
  42.         if (minEndDay[i] >= maxStartDay[i])
  43.             std::cout << "NIE\n";
  44.         else
  45.         {
  46.             if(a[stNum[i] - 1] < a[ndNum[i] - 1])
  47.                 std::cout << "TAK " << stNum[i] << " " << ndNum[i] << std::endl;
  48.             else
  49.                 std::cout << "TAK " << ndNum[i] << " " << stNum[i] << std::endl;
  50.         }
  51.     }
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement