-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
133 lines (101 loc) · 3.45 KB
/
Copy pathmain.cpp
File metadata and controls
133 lines (101 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
#include <chrono>
#include <sstream>
#include "user_code.h"
#include "file_reader.h"
#include "file_writer.h"
using namespace std;
using namespace std::chrono;
/**
* @brief Do not modify this code.
*
*/
void question1(string input_file, string output_file)
{
vector<int> delta;
// read from input file
question1_reader(input_file, delta);
auto start = high_resolution_clock::now();
auto output = question_one(delta);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
auto computeDuration = duration.count();
std::cout << "Time taken by function: " << duration.count() << " microseconds" << endl;
std::cout << "Total time taken: " << computeDuration << " microseconds" << endl;
// save output to output_file
question1_writer(output_file, output);
}
/**
* @brief Do not modify this code.
*
*/
void question2(string input_file, string output_file)
{
vector<int> values;
vector<bool> present;
// read from input file
question2_reader(input_file, values, present);
auto start = high_resolution_clock::now();
auto output = question_two(values, present);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
auto computeDuration = duration.count();
std::cout << "Time taken by function: " << duration.count() << " microseconds" << endl;
std::cout << "Total time taken: " << computeDuration << " microseconds" << endl;
// write output to file
question2_writer(output_file, output);
}
/**
* @brief Do not modify this code.
*
*/
void question3(string input_file, string output_file)
{
int N, S, K;
vector<vector<int>> edges;
vector<int> destinations;
// read from input file
question3_reader(input_file, N, edges, S, K, destinations);
auto start = high_resolution_clock::now();
auto output = question_three(N, edges, S, K, destinations);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
auto computeDuration = duration.count();
std::cout << "Time taken by function: " << duration.count() << " microseconds" << endl;
std::cout << "Total time taken: " << computeDuration << " microseconds" << endl;
// write output to file
question3_writer(output_file, output);
}
//////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS SECTION
//////////////////////////////////////////////////////////////////////////////////
/**
* @brief Do not modify this code.
*
* @param argc
* @param argv
* @return int
*/
int main(int argc, char **argv)
{
if (argc < 7)
{
cerr << "Error: Insufficient arguments provided." << endl;
cerr << "Usage: " << argv[0]
<< " <q1_input_file> <q1_output_file> <q2_input_file> <q2_output_file> <q3_input_file> <q3_output_file>" << endl;
return 1;
}
string question1_input_file = argv[1];
string question1_output_file = argv[2];
string question2_input_file = argv[3];
string question2_output_file = argv[4];
string question3_input_file = argv[5];
string question3_output_file = argv[6];
question1(question1_input_file, question1_output_file);
question2(question2_input_file, question2_output_file);
question3(question3_input_file, question3_output_file);
return 0;
}