-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
76 lines (57 loc) · 1.6 KB
/
main.cpp
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
#include <bits/stdc++.h>
#include "Classes/print.h"
#include "Classes/Graph.h"
#include "Classes/Rosetta/comb.h"
#include "Classes/DisjointSet.h"
#define DEBUG true
#if DEBUG
#include <libgen.h>
#include <unistd.h>
#include <limits.h>
std::string getpath() {
char buf[PATH_MAX + 1];
if (readlink("/proc/self/exe", buf, sizeof(buf) - 1) == -1)
throw std::string("readlink() failed");
std::string str(buf);
return str.substr(0, str.rfind('/'));
}
#endif
int main(int argc, char **argv) {
#if DEBUG
clock_t tStart = clock();
std::string pubPath = getpath() + "/../datapub/" + std::string(argv[1]);
std::ifstream taskInput(pubPath + ".in");
#define cin taskInput
#endif
int N, E;
#if DEBUG
cin >> N >> E;
#else
scanf("%d %d", &N);
#endif
Graph graph(Directed, N);
int V1, V2;
for (int i = 0; i < E; ++i) {
#if DEBUG
cin >> V1 >> V2;
// std::cout << V1 << " " << V2 << std::endl;
#else
scanf("%d %d", &V1, &V2);
#endif
graph.addEdge( Node(V1), Node(V2) );
}
std::string myOutput = "myOutput";
#if DEBUG
std::ifstream taskOutput(pubPath + ".out");
std::string rightOutput;
std::getline(taskOutput, rightOutput);
printf("\n\n");
printf("My output:\t\t%s \n", myOutput.c_str());
printf("Right output:\t%s \n", rightOutput.c_str());
printf("PASSED:\t\t\t%s \n", (!myOutput.compare(rightOutput) ? "YES" : "NO"));
printf("Time taken:\t\t%.2fs \n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
#else
printf("%s\n", myOutput.c_str());
#endif
}
// Ended on asg3