Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. #include <fstream>
  6. #include <tuple>
  7. #include <set>
  8.  
  9. using namespace std;
  10.  
  11. int main(int argc, char **argv){
  12. string fileName(argv[1]); //Nombre del archivo de test generado
  13. // int tests = atoi(argv[2]); //Cantidad de casos de tests apsados
  14. int N = atoi(argv[2]);
  15. int L = atoi(argv[3]);
  16. // int seed = atoi(argv[5]);
  17.  
  18. ofstream output(fileName.c_str());
  19. // srand(seed);
  20. srand(time(NULL));
  21.  
  22. int P = rand()%((N-1)*(L+1)*(L+1));
  23.  
  24. int Ni, Li, Nf, Lf;
  25.  
  26. // for(int i = 0; i<tests; i++){
  27. for(int i = 0; i<1; i++){
  28.  
  29. output << N << " " << L << endl;
  30. Ni=0;
  31. Nf = (rand()%N);
  32.  
  33.  
  34. set<tuple<int,int,int,int>> aristas;
  35.  
  36. while(Nf!=N-1){ // Esto asegura el camino que necesito
  37. Nf = (rand()%(N));
  38. // Nf = (rand()%(N-Nf)) + Nf;
  39. Li = rand()%(L+1);
  40. Lf = rand()%(L+1);
  41. Ni = Nf;
  42. std::tuple<int,int,int,int> arista (Ni, Li, Nf, Lf);
  43. aristas.insert(arista);
  44. }
  45.  
  46.  
  47. for(int j=0; j<P; j++){
  48. Ni = rand()%N;
  49. Nf = rand()%N;
  50. Li = rand()%(L+1);
  51. Lf = rand()%(L+1);
  52. std::tuple<int,int,int,int> arista (Ni, Li, Nf, Lf);
  53. aristas.insert(arista);
  54.  
  55. }
  56.  
  57. for (std::set<tuple<int,int,int,int>>::iterator i = aristas.begin(); i != aristas.end(); ++i)
  58. {
  59. output << get<0>(*i) << " " << get<1>(*i) << " " << get<2>(*i) << " " << get<3>(*i) << "; ";
  60. }
  61.  
  62. output << endl;
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement