generated from sigonasr2/CPlusPlusProjectTemplate
Fix even odd
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5fb885c027
commit
55a95a3a08
22
main.cpp
22
main.cpp
@ -25,11 +25,12 @@ struct Room{
|
||||
};
|
||||
|
||||
std::map<std::string,Room>rooms;
|
||||
std::vector<std::string>targetRooms;
|
||||
int maxFlow=0;
|
||||
int iterations=0;
|
||||
int branchesRemaining=0;
|
||||
|
||||
void printArr(std::vector<std::string> a, int n){
|
||||
void printArr(int n){
|
||||
int minutesRemaining1=26;
|
||||
int minutesRemaining2=26;
|
||||
std::string currentPos="AA";
|
||||
@ -44,11 +45,11 @@ void printArr(std::vector<std::string> a, int n){
|
||||
int flowTotal=0;
|
||||
|
||||
for (int i=0;i<n;i++){
|
||||
std::string valve=a[i];
|
||||
if ((i&1)==0){
|
||||
movePlan1.push_back(valve);
|
||||
} else {
|
||||
std::string valve=targetRooms[i];
|
||||
if (i&1){
|
||||
movePlan2.push_back(valve);
|
||||
} else {
|
||||
movePlan1.push_back(valve);
|
||||
}
|
||||
//std::cout<<a[i]<<" ";
|
||||
}
|
||||
@ -81,17 +82,17 @@ void printArr(std::vector<std::string> a, int n){
|
||||
}
|
||||
}
|
||||
|
||||
void permutation(std::vector<std::string> a,int size, int n){
|
||||
void permutation(int size, int n){
|
||||
if (size==1){
|
||||
printArr(a,n);
|
||||
printArr(n);
|
||||
return;
|
||||
}
|
||||
for (int i=0;i<size;i++){
|
||||
permutation(a,size-1,n);
|
||||
permutation(size-1,n);
|
||||
if (size&1){
|
||||
swap(a[0],a[size-1]);
|
||||
swap(targetRooms[i],targetRooms[size-i]);
|
||||
} else {
|
||||
swap(a[i],a[size-i]);
|
||||
swap(targetRooms[0],targetRooms[size-1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,7 +158,6 @@ void explore(std::string currentRoom,std::map<std::string,bool>visitedvalves,int
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<std::string>targetRooms;
|
||||
std::ifstream file("testinput");
|
||||
while (file.good()){
|
||||
std::string line;
|
||||
|
Loading…
x
Reference in New Issue
Block a user