Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define st first
  5. #define nd second
  6.  
  7. const int N = 1000 + 5;
  8.  
  9. int t, n, s, e;
  10. set<pair<pair<int, int>, int>> times;
  11. char ans[N];
  12.  
  13. int main() {
  14.     cin >> t;
  15.     for(int tt = 1; tt <= t; tt++) {
  16.         cin >> n;
  17.         times.clear();
  18.         for(int i = 1; i <= n; i++){
  19.             cin >> s >> e;
  20.             times.insert({{s, e}, i});
  21.         }
  22.        
  23.         int outC = -1, outJ = -1;
  24.         int ok = 1;
  25.         for(auto x : times) {
  26.             if(x.st.st < outC and x.st.st < outJ) {
  27.                 ok = 0;
  28.                 break;
  29.             }
  30.             if(x.st.st < outC) ans[x.nd] = 'J', outJ = x.st.nd;
  31.             else ans[x.nd] = 'C', outC = x.st.nd;
  32.         }
  33.         cout << "Case #" << tt << ": ";
  34.         if(!ok) { cout << "IMPOSSIBLE\n"; continue; }
  35.         for(int i = 1; i <= n; i++) cout << ans[i];
  36.         cout << "\n";
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement