Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int A[1001], B[1001], C[1001];
- struct drum {
- char x, y;
- }v[1001];
- int main()
- {
- int n, op = 0, c = 0, b = 0;
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> A[i];
- for (int i = n - 1; i >= 0; i--)
- {
- if (A[i] == 1)
- {
- C[c++] = A[i];
- v[op].x = 'A';
- v[op].y = 'C';
- op++;
- }
- else
- {
- if (A[i] == C[c - 1] + 1 && c)
- {
- C[c++] = A[i];
- v[op].x = 'A';
- v[op].y = 'C';
- op++;
- }
- else
- {
- {
- B[b++] = A[i];
- v[op].x = 'A';
- v[op].y = 'B';
- op++;
- }
- }
- }
- }
- for (int i = b - 1; i >= 0; i--)
- {
- C[c++] = B[i];
- v[op].x = 'B';
- v[op].y = 'C';
- op++;
- }
- for (int i = 1; i < c; i++)
- if (C[i] != C[i - 1] + 1)
- op = 0;
- cout << op << "\n";
- if(op)
- for (int i = 0; i < op; i++)
- cout << v[i].x << " " << v[i].y << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement