Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pi acos(-1.0)
- #define ll int
- #define s(n) scanf("%d", &n)
- using namespace std;
- struct task{
- ll start, end, index, who;
- };
- /*
- 1 = c
- 2 = j
- */
- bool crit(task a, task b){
- if(a.start > b.start) return false;
- if(a.start < b.start) return true;
- if(a.end > b.end) return false;
- return true;
- }
- bool crit2(task a, task b){
- if(a.index > b.index) return false;
- return true;
- }
- int main()
- {
- ll test;
- s(test);
- ll loop;
- for(loop = 1; loop <= test; loop++)
- {
- ll n;
- task t[20000];
- s(n);
- ll i;
- for(i = 1; i <= n; i++){
- s(t[i].start); s(t[i].end);
- t[i].index = i;
- }
- sort(t+1, t+1+n, crit);
- ll oneAss , twoAss = 0;
- bool impossible = false;
- for(i = 1; i <= n && !impossible; i++){
- if(i==1){
- t[i].who = 1;
- oneAss = i;
- }
- else
- {
- if(t[oneAss].end <= t[i].start){
- t[i].who = 1;
- oneAss = i;
- }
- else if(twoAss == 0){
- t[i].who = 2;
- twoAss = i;
- }
- else if(t[twoAss].end <= t[i].start){
- t[i].who = 2;
- twoAss = i;
- }
- else {
- impossible = true;
- }
- }
- }
- if(impossible) printf("Case #%d: IMPOSSIBLE\n", loop);
- else {
- sort(t+1, t+1+n, crit2);
- printf("Case #%d: ", loop);
- for(i=1; i<=n; i++){
- if(t[i].who == 1) printf("C");
- else printf("J");
- }
- printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement