-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_mao.bin.cpp
39 lines (32 loc) · 947 Bytes
/
count_mao.bin.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
#include "graph.hpp"
#include "mao.hpp"
using namespace std;
int main(int argc, char* argv[]) {
cin.sync_with_stdio(false);
cin.tie(nullptr);
removeStackLimit();
if(argc != 2) {
cerr << "Usage: <method name prefix>\n";
cerr << "Available methods:\n";
for(auto p : countMAOMethods) {
cerr << " \"" << p.first << "\"\n";
}
fail("Invalid command line");
}
string namePrefix = argv[1];
Z (*method)(const GraphData&) = nullptr;
for(auto p : countMAOMethods) {
if(p.first.substr(0, namePrefix.size()) == namePrefix) {
if(method != nullptr) {
fail("Ambiguous method name");
}
method = p.second;
}
}
if(method == nullptr) {
fail("Method not found");
}
GraphData graphData = GraphData::read(cin);
cout << method(graphData) << "\n";
return 0;
}