Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std; 
typedef vector<int> ve;
int n,k;
ve p,q,A,B,ip,iq;
void re(ve &x) {
	x.resize(n+1);
	fill(x.begin(),x.begin()+1+n,0);
}
ve inv(ve a) {
	ve orz;
	re(orz);
	for(int i=1;i<=n;i++) {
		orz[a[i]] = i;
	}
	return orz;
}
ve operator*(ve aa,ve bb) {
	ve orz; re(orz);
	for(int i=1;i<=n;i++) {
		orz[i] = aa[bb[i]];
	}
	return orz;
}
ve ksm(ve aa,int b) {
	ve orz; re(orz);
	for(int i=1;i<=n;i++) orz[i] = i;
	for(;b;b>>=1,aa = aa*aa) {
		if(b&1) {
			orz = orz*aa;
		}
	}
	return orz;
}
int main() {
	scanf("%d%d",&n,&k);
	re(p); re(q);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	for(int i=1;i<=n;i++) scanf("%d",&q[i]);
	ip = inv(p); iq = inv(q);
	ve yooo = q*ip*iq*p;
	A = ksm(yooo,(k-1)/6);
	int yo = k - (k-1)/6*6;
	switch(yo) {
		case 1:{
			B = p;
			break;
		}
		case 2:{
			B = q;
			break;
		}
		case 3:{
			B = q * ip;
			break;
		}
		case 4:{
			B = ip;
			A = A*q;
			break;
		}
		case 5:{
			B = iq;
			A = A*q*ip;
			break;
		}
		case 6:{
			B = iq*p;
			A = q*ip;
			break;
		}
	}
	ve ans = A * B * inv(A);
	for(int i=1;i<=n;i++) {
		printf("%d ",ans[i]);
	}
}

Compiler output:
a.cc:8:9: error: 'vector' does not name a type
    8 | typedef vector<int> ve;
      |         ^~~~~~
a.cc:10:1: error: 've' does not name a type
   10 | ve p,q,A,B,ip,iq;
      | ^~
a.cc:11:6: error: variable or field 're' declared void
   11 | void re(ve &x) {
      |      ^~
a.cc:11:9: error: 've' was not declared in this scope
   11 | void re(ve &x) {
      |         ^~
a.cc:11:13: error: 'x' was not declared in this scope
   11 | void re(ve &x) {
      |             ^
a.cc:15:1: error: 've' does not name a type
   15 | ve inv(ve a) {
      | ^~
a.cc:23:1: error: 've' does not name a type
   23 | ve operator*(ve aa,ve bb) {
      | ^~
a.cc:30:1: error: 've' does not name a type
   30 | ve ksm(ve aa,int b) {
      | ^~
a.cc: In function 'int main()':
a.cc:42:12: error: 'p' was not declared in this scope
   42 |         re(p); re(q);
      |            ^
a.cc:42:9: error: 're' was not declared in this scope
   42 |         re(p); re(q);
      |         ^~
a.cc:42:19: error: 'q' was not declared in this scope
   42 |         re(p); re(q);
      |                   ^
a.cc:45:9: error: 'ip' was not declared in this scope
   45 |         ip = inv(p); iq = inv(q);
      |         ^~
a.cc:45:14: error: 'inv' was not declared in this scope; did you mean 'int'?
   45 |         ip = inv(p); iq = inv(q);
      |              ^~~
      |              int
a.cc:45:22: error: 'iq' was not declared in this scope
   45 |         ip = inv(p); iq = inv(q);
      |                      ^~
a.cc:46:9: error: 've' was not declared in this scope
   46 |         ve yooo = q*ip*iq*p;
      |         ^~
a.cc:47:9: error: 'A' was not declared in this scope
   47 |         A = ksm(yooo,(k-1)/6);
      |         ^
a.cc:47:17: error: 'yooo' was not declared in this scope
   47 |         A = ksm(yooo,(k-1)/6);
      |                 ^~~~
a.cc:47:13: error: 'ksm' was not declared in this scope
   47 |         A = ksm(yooo,(k-1)/6);
      |             ^~~
a.cc:51:25: error: 'B' was not declared in this scope
   51 |                         B = p;
      |                         ^
a.cc:55:25: error: 'B' was not declared in this scope
   55 |                         B = q;
      |                         ^
a.cc:59:25: error: 'B' was not declared in this scope
   59 |                         B = q * ip;
      |                         ^
a.cc:63:25: error: 'B' was not declared in this scope
   63 |                         B = ip;
      |                         ^
a.cc:68:25: error: 'B' was not declared in this scope
   68 |                         B = iq;
      |                         ^
a.cc:73:25: error: 'B' was not declared in this scope
   73 |                         B = iq*p;
      |                         ^
a.cc:78:11: error: expected ';' before 'ans'
   78 |         ve ans = A * B * inv(A);
      |           ^~~~
      |           ;
a.cc:80:30: error: 'ans' was not declared in this scope; did you mean 'abs'?
   80 |                 printf("%d ",ans[i]);
      |                              ^~~
      |                              abs