#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
using namespace std;
int main() {
std::ios_base::sync_with_stdio (false);
// cin.tie(NULL);
int n, t;
cin >> n;
cin >> t;
if (t % 2 == 0) {
int v;
cin >> v;
cout << v;
while(cin >> v) {
cout << " " << v;
}
} else {
int v;
vector<int> vv;
while(cin >> v) {
vv.push_back(v);
}
for(int i = vv.size() - 1; i > 0; i--) {
cout << vv[i] << " ";
}
cout << vv[0];
}
cout << endl;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <iostream> #include <vector> #include <unordered_set> #include <set> using namespace std; int main() { std::ios_base::sync_with_stdio (false); // cin.tie(NULL); int n, t; cin >> n; cin >> t; if (t % 2 == 0) { int v; cin >> v; cout << v; while(cin >> v) { cout << " " << v; } } else { int v; vector<int> vv; while(cin >> v) { vv.push_back(v); } for(int i = vv.size() - 1; i > 0; i--) { cout << vv[i] << " "; } cout << vv[0]; } cout << endl; return 0; } |
English