Guest User

Untitled

a guest
Apr 4th, 2020
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1.  
  2. int main() {
  3.  
  4.     int t;
  5.     cin>>t;
  6.     int ppp=t;
  7.     while(t--){
  8.         int n;
  9.         cin>>n;
  10.         vector<pair<int,int>> v;
  11.         int arr[n];
  12.         int dep[n];
  13.         for(int i=0;i<n;i++){
  14.             int a,d;
  15.             cin>>a>>d;
  16.             arr[i]=a;
  17.             dep[i]=d;
  18.             v.push_back(make_pair(a,d));
  19.         }
  20.         int ma=0;
  21.         int w[10000]={0};
  22.         for(int j=0;j<n;j++){
  23.             int a,b;
  24.             a = v[j].first;
  25.             b = v[j].second;
  26.             for(int i=a;i<b;i++){
  27.                 w[i]++;
  28.                 ma = max(ma,w[i]);
  29.             }
  30.  
  31.             }
  32.  
  33.         if(ma>2){
  34.             cout<<"Case #"<<ppp-t<<": IMPOSSIBLE\n";
  35.             continue;
  36.         }
  37.  
  38.         string s;
  39.  
  40.         int work[10000]={0};
  41.         for(int j=0;j<n;j++){
  42.             int a,b;
  43.             a = v[j].first;
  44.             b = v[j].second;
  45.             int m=0;
  46.             for(int i=a;i<b;i++){
  47.                 m = max(work[i],m);
  48.             }
  49.  
  50.             if(m%2==0){
  51.                 s+='C';
  52.                 for(int i=a;i<b;i++){
  53.                     work[i] = 1;
  54.                 }
  55.             }
  56.             if(m==1){
  57.                 s+='J';
  58.                 for(int i=a;i<b;i++){
  59.                     work[i] = 2;
  60.                 }
  61.             }
  62.  
  63.  
  64.         }
  65.  
  66.          cout<<"Case #"<<ppp-t<<": "<<s<<"\n";
  67.  
  68.        // cout<<"Case #"<<ppp-t<<": ";
  69.  
  70.     }
  71.  
  72.  
  73.     return 0;
  74. }
Add Comment
Please, Sign In to add comment