Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int n, m, *a, *b, *d, *minEndDay, *maxStartDay, *stNum, *ndNum;
- std::ios::sync_with_stdio(false);
- std::cin >> n >> m;
- a = new int[n];
- b = new int[n];
- d = new int[n];
- minEndDay = new int[m];
- maxStartDay = new int[m];
- stNum = new int[m];
- ndNum = new int[m];
- for (int i = 0; i < m; i++)
- {
- minEndDay[i] = -1;
- maxStartDay[i] = -1;
- }
- for (int i = 0; i < n; i++)
- {
- std::cin >> a[i] >> b[i] >> d[i];
- if ((minEndDay[d[i] - 1] > b[i]) || (minEndDay[d[i] - 1] == -1))
- {
- minEndDay[d[i] - 1] = b[i];
- stNum[d[i] - 1] = i + 1;
- }
- if ((maxStartDay[d[i] - 1] < a[i]) || (maxStartDay[d[i] - 1] == -1))
- {
- maxStartDay[d[i] - 1] = a[i];
- ndNum[d[i] - 1] = i + 1;
- }
- }
- for (int i = 0; i < m; i++)
- {
- if (minEndDay[i] >= maxStartDay[i])
- std::cout << "NIE\n";
- else
- {
- if(a[stNum[i] - 1] < a[ndNum[i] - 1])
- std::cout << "TAK " << stNum[i] << " " << ndNum[i] << std::endl;
- else
- std::cout << "TAK " << ndNum[i] << " " << stNum[i] << std::endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement