P2730中本地测试完好无损,下了数据是对的,但评测就是错的。有谁知道为什么洛谷评测时一直第一个数输出 0 吗()
12pts.
#include<bits/stdc++.h>
using namespace std;
string mb = "";
map<string,string>a;
string Id1(string s){
string r = "";
for(int i = 7;i>=4;i--){
r+=s[i];
}
for(int i = 3;i>=0;i--){
r+=s[i];
}
return r;
}
string Id2(string s){
string r = "";
r+=s[3];
r+=s[0];
r+=s[1];
r+=s[2];
r+=s[5];
r+=s[6];
r+=s[7];
r+=s[4];
return r;
}
string Id3(string s){
string r = "";
r+=s[0];
r+=s[6];
r+=s[1];
r+=s[3];
r+=s[4];
r+=s[2];
r+=s[5];
r+=s[7];
return r;
}
void bfs(string start){
a[start] = "";
queue<string>x;
x.push(start);
while(!x.empty()){
//cout<<"start:"<<x.front()<<endl;
if(x.front()==mb){
return;
}
if(a[Id1(x.front())]==""){
//cout<<"Type 1 Push in:"<<Id1(x.front())<<endl;
x.push(Id1(x.front()));
a[Id1(x.front())] = a[x.front()]+'A';
}
if(a[Id2(x.front())]==""){
//cout<<"Type 2 Push in:"<<Id2(x.front())<<endl;
x.push(Id2(x.front()));
a[Id2(x.front())] = a[x.front()]+'B';
}
if(a[Id3(x.front())]==""){
//cout<<"Type 3 Push in:"<<Id3(x.front())<<endl;
x.push(Id3(x.front()));
a[Id3(x.front())] = a[x.front()]+'C';
}
x.pop();
}
}
int main(){
string mbh;
getline(cin,mbh);
for(int i = 0;i<mbh.length();i++){
if(mbh[i]!=' ')mb+=mbh[i];
}
//cout<<mb<<endl;
// cout<<Id1("12345678")<<endl;
// cout<<Id2("12345678")<<endl;
// cout<<Id3("12345678")<<endl;
//a["000000"] = "789";
//cout<<(a.find("000000"))<<endl;
bfs("12345678");
cout<<a[mb].length()<<endl;
cout<<a[mb]<<endl;
//return 0;
system ("pause");
}
助人为乐者玄关