Advertisement
OIQ

Untitled

OIQ
Jan 13th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.     string s;
  11.  
  12.     cin >> s;
  13.  
  14.     if (s == "forward") {
  15.         int n, k;
  16.         cin >> n >> k;
  17.         vector <int> a(k);
  18.         for (int i = 0; i < k; i++)
  19.             cin >> a[i];
  20.  
  21.         cout << "first ";
  22.         for (int i = 0; i < k - 1; i++)
  23.             cout << a[i] << " ";
  24.     }
  25.  
  26.     else {
  27.         int n, k;
  28.         cin >> n >> k;
  29.         string ss;
  30.         cin >> ss;
  31.         vector <int> a(k);
  32.         for (int i = 0; i < k - 1; i++)
  33.             cin >> a[i];
  34.  
  35.         for (int i = 0; i < k - 1; i++)
  36.             cout << a[i] << " ";
  37.         cout << a[k - 2] + 1;
  38.        
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement