Advertisement
iamrasheeq

w

Apr 4th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. bool hi(const vector<int> &vec,const vector<int> &vic);
  5. bool hello(const vector<int> &vec, const vector<int> &vic);
  6. int main()
  7. {
  8.     int test;
  9.     cin >> t;
  10.     for (int nin = 1; nin <= test; nin++)
  11.     {
  12.         vector<vector<int> > vec1;
  13.         string re;
  14.         int n, f1 = 0 , f2=0;
  15.         bool w = false;
  16.         cin >> n;
  17.        
  18.        
  19.    
  20.         for (int i = 0; i < n; i++)
  21.         {
  22.             vector<int> vv;
  23.  
  24.             for (int i = 0; i < 2; i++)
  25.             {
  26.                 int x2;
  27.                 cin>>x2;
  28.                 vv.push_back(x2);
  29.             }
  30.             vv.push_back(0);
  31.             vv.push_back(i);        
  32.             vec1.push_back(vv);
  33.         }
  34.  
  35.         sort(vec1.begin(), vec1.end(), hi);
  36.         for (int k = 0; k < n; k++)
  37.         {
  38.            
  39.            
  40.             if (vec1[k][0] >= f2)
  41.             {
  42.                 f2 = vec1[k][1];
  43.                 vec1[k][2] = 9;
  44.             }else if (vec1[k][0] >= f1)
  45.             {
  46.                 f1 = vec1[k][1];
  47.                 vec1[k][2] = 6;
  48.             }
  49.             else
  50.             {
  51.                 w = true;
  52.             }
  53.         }
  54.  
  55.         sort(vec1.begin(), vec1.end(), hello);
  56.  
  57.        
  58.  
  59.         if (!w)
  60.         {  
  61.  
  62.             for (int i = 0; i < n; i++)
  63.             {
  64.                 if (vec1[i][2] == 6)
  65.                 {
  66.                     re = re + 'J';
  67.                 }
  68.                 else if (vec1[i][2] == 9)
  69.                 {
  70.                     re = re + 'C';
  71.                 }
  72.             }
  73.  
  74.             cout <<"Case #"<<nin<<": "<< re << endl;
  75.         }
  76.         else
  77.         {
  78.             cout <<"Case: #"<<nin<<": IMPOSSIBLE"<< endl;
  79.            
  80.         }
  81.     }
  82.    
  83.  
  84.    
  85. }
  86.  
  87.  
  88. bool hi(const vector<int> &vec,const vector<int> &vic)
  89. {
  90. return (vec[0] < vic[0]);
  91. }
  92.  
  93. bool hello(const vector<int> &vec, const vector<int> &vic)
  94. {
  95. return (vec[3] < vic[3]);
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement