绝对不模拟的简单魔方
要相信题目的提示 (直接模拟的代码长达300行) ,由于魔方的特性,不论如何转动脚上的色块颜色不会变动,只要枚举8个角块看看是否一致即可,枚举角块时需确定访问角块颜色的顺序,例如以3号为顶,后左上访问顺序为123即坐标为\((3,4)->(4,3)-(4,4)\) ,那么可以通过此角块的移动来确定其他角块的访问顺序(方向一致即可起点可以变动),存下所有访问顺序和坐标遍历判断即可
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e4 + 10;
vector<string> s(10);
void solve() {
for (int i = 1; i <= 9; i++) {
cin >> s[i];
s[i] = ' ' + s[i];
}
map<string, int> able;
vector<vector<pair<int, int> > > check(10, vector<pair<int, int>>(3));
able["123"]++;
able["231"]++;
able["312"]++;
check[0] = {{3, 4},
{4, 3},
{4, 4}};
able["152"]++;
able["521"]++;
able["215"]++;
check[1] = {{1, 4},
{4, 12},
{4, 1}};
able["145"]++;
able["451"]++;
able["514"]++;
check[2] = {{1, 6},
{4, 9},
{4, 10}};
able["341"]++;
able["413"]++;
able["134"]++;
check[3] = {{3, 6},
{4, 6},
{4, 7}};
able["632"]++;
able["326"]++;
able["263"]++;
check[4] = {{7, 4},
{6, 4},
{6, 3}};
able["436"]++;
able["364"]++;
able["643"]++;
check[5] = {{6, 7},
{6, 6},
{7, 6}};
able["562"]++;
able["625"]++;
able["256"]++;
check[6] = {{6, 1},
{6, 12},
{9, 4}};
able["654"]++;
able["546"]++;
able["465"]++;
check[7] = {{9, 6},
{6, 10},
{6, 9}};
for (int i = 0; i < 8; i++) {
char a = s[check[i][0].first][check[i][0].second];
char b = s[check[i][1].first][check[i][1].second];
char c = s[check[i][2].first][check[i][2].second];
string k = "";
k += a;
k += b;
k += c;
if (able[k]) continue;
else {
set<char> ans;
ans.insert(a);
ans.insert(b);
ans.insert(c);
for (auto j: ans) {
cout << j << ' ';
}
cout << '\n';
return;
}
}
cout << "No problem" << '\n';
}
signed main() {
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
标签:钉耙,10,++,able,2024,int,ans,1003,check
From: https://www.cnblogs.com/yoez123/p/18317644