#54615: C++ Easy AC


belubruh123 (belubruh123)


#include <bits/stdc++.h>
using namespace std;

void forward(int (&arr)[6]) {
int path[] = {5, 3, 4}; // The path after Top
for (int idx : path) swap(arr[1], arr[idx]);
}


void right(int (&arr)[6]) {
for (int i = 0; i<3; i++) {
swap(arr[3],arr[i]);
}
}

int main() {
ios::sync_with_stdio(0);//opti out
cin.tie(0);//opti in
int dCnt;
int m;
cin >> dCnt >> m;
int dice[dCnt][6];

for (int i = 0; i < dCnt; i++) {
dice[i][0] = 5;
dice[i][1] = 1;
dice[i][2] = 2;
dice[i][3] = 6;
dice[i][4] = 3;
dice[i][5] = 4;
}
while (m--) {
int a;
int b;
cin >> a >> b;
if (b<0) {
if (b == -1) {
forward(dice[a-1]);
} else {
right(dice[a-1]);
}
} else {
swap(dice[a-1],dice[b-1]);
}
}
for (int i = 0; i<dCnt; i++) {
cout << dice[i][1] << " ";
}
return 0;
}
#54616: Re: C++ Easy AC


belubruh123 (belubruh123)


#include <bits/stdc++.h>
using namespace std;

void forward(int (&arr)[6]) {
int path[] = {5, 3, 4}; // The path after Top
for (int idx : path) swap(arr[1], arr[idx]);
}


void right(int (&arr)[6]) {
for (int i = 0; i<3; i++) {
swap(arr[3],arr[i]);
}
}

int main() {
ios::sync_with_stdio(0);//opti out
cin.tie(0);//opti in
int dCnt;
int m;
cin >> dCnt >> m;
int dice[dCnt][6];

for (int i = 0; i < dCnt; i++) {
dice[i][0] = 5;
dice[i][1] = 1;
dice[i][2] = 2;
dice[i][3] = 6;
dice[i][4] = 3;
dice[i][5] = 4;
}
while (m--) {
int a;
int b;
cin >> a >> b;
if (b<0) {
if (!(b+1)) {
forward(dice[a-1]);
} else {
right(dice[a-1]);
}
} else {
swap(dice[a-1],dice[b-1]);
}
}
for (int i = 0; i<dCnt; i++) {
cout << dice[i][1] << " ";
}
return 0;
}