Advertisement
sivan_iut

Untitled

Apr 3rd, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int T;
  7.     cin>>T;
  8.     for(int i=0; i<T; i++)
  9.     {
  10.         cout<<"Case "<<"#"<<i+1<<": ";
  11.  
  12.         int task;
  13.         cin>>task;
  14.  
  15.         int sadman[task+1];
  16.         int mehedi[task+1];
  17.  
  18.         for(int j=0; j<task; j++)
  19.         {
  20.             cin>>sadman[j]>>mehedi[j];
  21.         }
  22.  
  23.         string sivan;
  24.         sivan.push_back('C');
  25.  
  26.  
  27.        int a=0;
  28.  
  29.        for(int j=1; j<task; j++)
  30.         {
  31.  
  32.  
  33.             if(sadman[j]>=mehedi[j-1])
  34.                 sivan.push_back('C');
  35.  
  36.             else if(sadman[j]<mehedi[j-1])
  37.             {
  38.                 sivan.push_back('J');
  39.                 if(j==task-1)
  40.                 break;
  41.  
  42.                 if(sadman[j+1]<mehedi[j] && sadman[j+1]<mehedi[j-1])
  43.                 {
  44.                     a++;
  45.                     break;
  46.                 }
  47.  
  48.  
  49.  
  50.             }
  51.  
  52.  
  53.         }
  54.  
  55.  
  56.             if(a==0)
  57.             cout<<sivan;
  58.             else
  59.                 cout<<"IMPOSSIBLE";
  60.  
  61.  
  62.  
  63.  
  64.         cout<<endl;
  65.  
  66.  
  67.     }
  68.  
  69.  
  70.  
  71.  
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement