Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- int t;
- cin>>t;
- int ppp=t;
- while(t--){
- int n;
- cin>>n;
- vector<pair<int,int>> v;
- int arr[n];
- int dep[n];
- for(int i=0;i<n;i++){
- int a,d;
- cin>>a>>d;
- arr[i]=a;
- dep[i]=d;
- v.push_back(make_pair(a,d));
- }
- int ma=0;
- int w[10000]={0};
- for(int j=0;j<n;j++){
- int a,b;
- a = v[j].first;
- b = v[j].second;
- for(int i=a;i<b;i++){
- w[i]++;
- ma = max(ma,w[i]);
- }
- }
- if(ma>2){
- cout<<"Case #"<<ppp-t<<": IMPOSSIBLE\n";
- continue;
- }
- string s;
- int work[10000]={0};
- for(int j=0;j<n;j++){
- int a,b;
- a = v[j].first;
- b = v[j].second;
- int m=0;
- for(int i=a;i<b;i++){
- m = max(work[i],m);
- }
- if(m%2==0){
- s+='C';
- for(int i=a;i<b;i++){
- work[i] = 1;
- }
- }
- if(m==1){
- s+='J';
- for(int i=a;i<b;i++){
- work[i] = 2;
- }
- }
- }
- cout<<"Case #"<<ppp-t<<": "<<s<<"\n";
- // cout<<"Case #"<<ppp-t<<": ";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment