Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.003 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 4 KBi |
#6 |
Correcto
|
0.063 s | 3 KBi |
#7 |
Correcto
|
0.059 s | 3 KBi |
#8 |
Correcto
|
0.004 s | 1 KBi |
#9 |
Correcto
|
0.003 s | 0 KBi |
#10 |
Correcto
|
0.003 s | 3 KBi |
#11 |
Correcto
|
0.003 s | 0 KBi |
#12 |
Correcto
|
0.009 s | 3 KBi |
#13 |
Correcto
|
0.007 s | 1 KBi |
#14 |
Correcto
|
0.014 s | 0 KBi |
#15 |
Correcto
|
0.007 s | 2 KBi |
#16 |
Correcto
|
0.012 s | 1 KBi |
#17 |
Correcto
|
0.004 s | 3 KBi |
#18 |
Correcto
|
0.004 s | 2 KBi |
#19 |
Correcto
|
0.006 s | 2 KBi |
#20 |
Correcto
|
0.004 s | 1 KBi |
#21 |
Correcto
|
0.097 s | 2 KBi |
#22 |
Correcto
|
0.123 s | 6 KBi |
#23 |
Correcto
|
0.189 s | 2 KBi |
#24 |
Correcto
|
0.147 s | 3 KBi |
#25 |
Correcto
|
0.258 s | 2 KBi |
#include <algorithm> #include <iostream> #include <iterator> #include <numeric> #include <sstream> #include <fstream> #include <cassert> #include <climits> #include <cstdlib> #include <cstring> #include <bitset> #include <string> #include <cstdio> #include <vector> #include <cmath> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> using namespace std; ////////////// Prewritten code follows. Look down for solution. //////////////// #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x) #define For(i, a, b) for (int i=(a); i<(b); ++i) #define D(x) cerr << #x " is " << (x) << endl const double EPS = 1e-9; int cmp(double x, double y = 0, double tol = EPS) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } ////////////////////////// Solution starts below. ////////////////////////////// int main(){ int N; long R; cin >> N >> R; vector<int> P(N); vector<int> cards(N); for (int i = 0; i < N; ++i) { cin >> P[i]; cards[i] = i+1; } while (R > 0) { if (R & 1) { vector<int> new_cards(N); for (int i = 0; i < N; ++i) { new_cards[P[i]] = cards[i]; } cards.swap(new_cards); } R >>= 1; // P_squared[i] = P[P[i]] vector<int> P_squared(N); for (int i = 0; i < N; ++i) { P_squared[i] = P[P[i]]; } P_squared.swap(P); } for (int i = 0; i < N; ++i) { if (i > 0) cout << " "; cout << cards[i]; } cout << endl; return 0; }