Submission #00068


ソースコード

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <bits/stdc++.h>
#define lol long long
#define gcd(x, y) __gcd(x, y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed << setprecision(x)
#define all(x) x.begin(),x.end()
using namespace std;
using pii = pair<int, int>;
template <class A, class B>
inline bool chmax(A& a, const B& b) {
return b > a && (a = b, true);
}
template <class A, class B>
inline bool chmin(A& a, const B& b) {
return b < a && (a = b, true);
}
template <class A>
inline A abs(A& a) {
return (a < 0 ? -a : a);
}
bool inLine(int x, int y, int mx, int my) {
return (x >= 0 && y >= 0 && x < mx && y < my);
}
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T>>;
template<class T> using uset=unordered_set<T>;
template<class A,class B> using umap=unordered_map<A,B>;
const lol inf = (1LL << 62);
const int MOD = (1e9) + 7;
const int mod = 998244353;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, -2, -2, -2, -2,
-2, -1, -1, 1, 1, 0, 0, 2, 2, 2, 2, 2};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1, -2, -1, 0, 1,
2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2};
int co(vector<int> p,int cost){
int tp=0;
for(int i=2;i<=9;i++){
tp+=(p[1]!=p[i]);
}
for(int i=22;i<=30;i++){
tp+=(p[22]!=p[i]);
}
for(int i=10;i<=12;i++){
tp+=(p[10]!=p[i]);
}
for(int i=13;i<=15;i++){
tp+=(p[13]!=p[i]);
}
for(int i=16;i<=18;i++){
tp+=(p[16]!=p[i]);
}
for(int i=19;i<=21;i++){
tp+=(p[19]!=p[i]);
}
if(tp==0){
return (cost);
}
if(cost>=9){
return (mod);
}
int ans=mod;
auto v=p;
swap(v[1],v[24]);
swap(v[4],v[27]);
swap(v[7],v[30]);
swap(v[21],v[10]);
swap(v[16],v[18]);
chmin(ans,co(v,cost+1));
v=p;
swap(v[3],v[22]);
swap(v[6],v[25]);
swap(v[9],v[28]);
swap(v[12],v[19]);
swap(v[13],v[15]);
chmin(ans,co(v,cost+1));
v=p;
swap(v[1],v[28]);
swap(v[2],v[29]);
swap(v[3],v[30]);
swap(v[15],v[16]);
swap(v[19],v[21]);
chmin(ans,co(v,cost+1));
v=p;
swap(v[7],v[22]);
swap(v[8],v[23]);
swap(v[9],v[24]);
swap(v[10],v[12]);
swap(v[13],v[18]);
chmin(ans,co(v,cost+1));
return(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >>n;
for(int i=0;i<n;i++){
vector<int> p(31);
for(int j=0;j<30;j++){
cin >>p[j+1];
}
cout <<co(p,0)<<'\n';
}
return (0);
}

ステータス

項目 データ
問題 0006 - フロッピーキューブ
ユーザー名 保守性不在
投稿日時 2021-07-13 17:06:25
言語 C++17
状態 Accepted
得点 10
ソースコード長 2517 Byte
最大実行時間 669 ms
最大メモリ使用量 704 KB

セット

セット 得点 Cases
1 ALL 10 / 10 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00sample.in AC 92 ms 472 KB
1
01.in AC 41 ms 552 KB
1
02.in AC 75 ms 508 KB
1
03.in AC 88 ms 588 KB
1
04.in AC 90 ms 540 KB
1
05.in AC 136 ms 488 KB
1
06.in AC 160 ms 568 KB
1
07.in AC 170 ms 516 KB
1
08.in AC 152 ms 596 KB
1
09.in AC 211 ms 672 KB
1
10.in AC 180 ms 628 KB
1
11.in AC 231 ms 572 KB
1
12.in AC 275 ms 524 KB
1
13.in AC 271 ms 476 KB
1
14.in AC 271 ms 428 KB
1
15.in AC 317 ms 508 KB
1
16.in AC 379 ms 456 KB
1
17.in AC 374 ms 540 KB
1
18.in AC 431 ms 616 KB
1
19.in AC 416 ms 436 KB
1
20.in AC 454 ms 640 KB
1
21.in AC 446 ms 584 KB
1
22.in AC 439 ms 656 KB
1
23.in AC 553 ms 600 KB
1
24.in AC 519 ms 548 KB
1
25.in AC 532 ms 628 KB
1
26.in AC 590 ms 704 KB
1
27.in AC 569 ms 648 KB
1
28.in AC 580 ms 596 KB
1
29.in AC 611 ms 668 KB
1
30.in AC 669 ms 480 KB
1