Advertisement
Guest User

depou

a guest
Nov 9th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int A[1001], B[1001], C[1001];
  4.  
  5. struct drum {
  6.     char x, y;
  7. }v[1001];
  8.  
  9.  
  10. int main()
  11. {
  12.     int n, op = 0, c = 0, b = 0;
  13.     cin >> n;
  14.     for (int i = 0; i < n; i++)
  15.         cin >> A[i];
  16.  
  17.     for (int i = n - 1; i >= 0; i--)
  18.     {
  19.         if (A[i] == 1)
  20.         {
  21.             C[c++] = A[i];
  22.             v[op].x = 'A';
  23.             v[op].y = 'C';
  24.             op++;
  25.         }
  26.         else
  27.         {
  28.             if (A[i] == C[c - 1] + 1 && c)
  29.             {
  30.                 C[c++] = A[i];
  31.                 v[op].x = 'A';
  32.                 v[op].y = 'C';
  33.                 op++;
  34.             }
  35.             else
  36.             {
  37.                 {
  38.                     B[b++] = A[i];
  39.                     v[op].x = 'A';
  40.                     v[op].y = 'B';
  41.                     op++;
  42.                 }
  43.             }
  44.         }
  45.  
  46.     }
  47.  
  48.  
  49.     for (int i = b - 1; i >= 0; i--)
  50.     {
  51.         C[c++] = B[i];
  52.         v[op].x = 'B';
  53.         v[op].y = 'C';
  54.         op++;
  55.     }
  56.  
  57.         for (int i = 1; i < c; i++)
  58.         if (C[i] != C[i - 1] + 1)
  59.             op = 0;
  60.    
  61.    
  62.     cout << op << "\n";
  63.     if(op)
  64.     for (int i = 0; i < op; i++)
  65.         cout << v[i].x << " " << v[i].y << "\n";
  66.  
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement