This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
#include #include<stdio.h> using namespace std; int gates[6][3] = { {0,1,2}, {0,2,1}, {1,2,0}, {1,0,2}, {2,0,1}, {2,1,0} }; int arr[3][2]; //int mini = INT_MAX; int visited[1000]; int ind(int place, int sets, int n){ int i = 1; while(place - i >= 0 || place + i < n) { if(sets == 0) { if(place - i >= 0 && visited[place - i] == 0) return place - i; else if(place + i < n && visited[place + i] == 0) return place + i; i++; } else { if(place + i < n && visited[place + i] == 0) return place + i; else if(place - i >= 0 && visited[place - i] == 0) return place i;
i++; }
} return -1;
} void fill(int sets, int gate,int n) { int place = arr[gate][0]; int fis_n = arr[gate][1]; //cout<
cout << "Error\n"; break; } visited[nex] = place; } fis_n--;
} } int min(int a, int b) { if(a < b) return a; else return b; } int absd(int d) { if(d >= 0) return d; return (-1)*d; } int findsol(int i, int j, int k, int n, int u) { for(int c = 0; c < n; c++) { visited[c] = 0; } int cost = 0; //cout<<arr[gates[u][0]][1]<<endl; fill(i, gates[u][0],n); //for(int i = 0; i < n; i++) cout<
}
}
return mini;
int main() { int t=1; cin >> t; for(int e = 1; e <= t; e++) { int n; cin >> n; for(int i = 0; i < 3; i++) { cin >> arr[i][0] >> arr[i][1]; arr[i][0]--; } int f = 2147483647; for(int i = 0; i < 6; i++) { f=min(f,finds(i, n)); } cout << "#" << e << " "; cout << f << endl;