Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define st first
- #define nd second
- const int N = 1000 + 5;
- int t, n, s, e;
- set<pair<pair<int, int>, int>> times;
- char ans[N];
- int main() {
- cin >> t;
- for(int tt = 1; tt <= t; tt++) {
- cin >> n;
- times.clear();
- for(int i = 1; i <= n; i++){
- cin >> s >> e;
- times.insert({{s, e}, i});
- }
- int outC = -1, outJ = -1;
- int ok = 1;
- for(auto x : times) {
- if(x.st.st < outC and x.st.st < outJ) {
- ok = 0;
- break;
- }
- if(x.st.st < outC) ans[x.nd] = 'J', outJ = x.st.nd;
- else ans[x.nd] = 'C', outC = x.st.nd;
- }
- cout << "Case #" << tt << ": ";
- if(!ok) { cout << "IMPOSSIBLE\n"; continue; }
- for(int i = 1; i <= n; i++) cout << ans[i];
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement