https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/11/Codeforces-Round-444-Div-2-problem-C-Solution-for-Cube-Solution-In-CC.png?fit=640%2C360

Codeforces Round #444 (Div. 2), problem: (C) Solution for Cube Solution In C/C++

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

const int R[6][8] = {
{12, 13, 4, 5, 16, 17, 20, 21},
{14, 15, 6, 7, 18, 19, 22, 23},
{ 0, 2, 4, 6, 8, 10, 23, 21},
{ 1, 3, 5, 7, 9, 11, 22, 20},
{ 2, 3, 16, 18, 9, 8, 15, 13},
{ 0, 1, 17, 19, 11, 10, 14, 12}
};

int a[24];
int b[24];

int main()
{
for (int i = 0; i < 24; i++)
scanf(“%d”, a + i);

for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 24; j++)
b[j] = a[j];

for (int j = 0; j < 8; j++)
b[R[i][j]] = a[R[i][(j + 2) % 8]];

bool valid = true;

for (int j = 0; j < 24; j += 4)
if (b[j] != b[j + 1] || b[j + 1] != b[j + 2] || b[j + 2] != b[j + 3])
valid = false;

if (valid)
{
puts(“YES”);

return 0;
}
}

puts(“NO”);

return 0;
}

(Visited 15 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: