Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit1d22c53e6f73f34c299b5c9cb29288346d48aea6 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-01-12 17:51:03 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-01-12 17:51:03 +0200
Files0e25a4b0bc73ae1177b671cd9c0916cbff700381
uni-projects-1d22c53e6f73f34c299b5c9cb29288346d48aea6.tar
uni-projects-1d22c53e6f73f34c299b5c9cb29288346d48aea6.tar.gz
uni-projects-1d22c53e6f73f34c299b5c9cb29288346d48aea6.zip
Parente9e977eb45122241564e787cc435378ba32c1206 (diff)
hw(AI/1): Add timer on any argument
1 files changed, 12 insertions, 1 deletions
-rw-r--r--Year 4/Artificial Intelligence/hw01/main.cpp13
diff --git a/Year 4/Artificial Intelligence/hw01/main.cpp b/Year 4/Artificial Intelligence/hw01/main.cpp
index 87e6167..17b568b 100644
--- a/Year 4/Artificial Intelligence/hw01/main.cpp
+++ b/Year 4/Artificial Intelligence/hw01/main.cpp
@@ -5,10 +5,12 @@
#include <math.h>
#include <climits>
#include <cassert>
+#include <chrono>
// #include "graph.h"
using namespace std;
+using namespace chrono;
int I, N = 0;
@@ -171,7 +173,7 @@ bool solvable(Node* root) {
}
}
-int main() {
+int main(int argc, char* argv[]) {
/* Input */
cin >> N >> I;
if (I == -1) { I = N; }
@@ -200,11 +202,15 @@ int main() {
path.push_back(root);
/* IDA* */
+ auto startTime = system_clock::now();
+
int bound = 3;
while(bound != SOLVED) {
bound = dfs(path, bound);
}
+ auto endTime = system_clock::now();
+
/* Output */
cout << (path.size() - 1) << endl;
for (int i = 1; i < path.size(); i++) {
@@ -212,4 +218,9 @@ int main() {
delete path[i];
}
delete root;
+
+ if (argc > 1) {
+ auto millis = duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
+ std::cout << "Took: " << millis / 1000.0 << "s" << std::endl;
+ }
}