Created
February 3, 2017 19:01
-
-
Save na-ka-na/c19b7e6e0bafdc45fbede14a9b3d39f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <unordered_map> | |
using namespace std; | |
static const unordered_map<int, int> mapA{}; | |
int funcA(int key) { | |
auto f = mapA.find(key); | |
if (f == mapA.end()) { | |
return -9; | |
} else { | |
return f->second; | |
} | |
} | |
unordered_map<int, int> mapB{}; | |
int funcB(int key) { | |
auto f = mapB.find(key); | |
if (f == mapB.end()) { | |
return -9; | |
} else { | |
return f->second; | |
} | |
} | |
int funcC(int key) { | |
static const unordered_map<int, int> map{}; | |
auto f = map.find(key); | |
if (f == map.end()) { | |
return -9; | |
} else { | |
return f->second; | |
} | |
} | |
int funcD(int key) { | |
unordered_map<int, int> map{}; | |
auto f = map.find(key); | |
if (f == map.end()) { | |
return -9; | |
} else { | |
return f->second; | |
} | |
} | |
int main(int argc, char** argv) { | |
char f = *argv[1]; | |
int key = stoi(string(argv[2])); | |
int res = 0; | |
if (f == 'A') { | |
for (int i=0; i<100000000; ++i) { | |
res += funcA(key); | |
} | |
} | |
if (f == 'B') { | |
for (int i=0; i<100000000; ++i) { | |
res += funcB(key); | |
} | |
} | |
if (f == 'C') { | |
for (int i=0; i<100000000; ++i) { | |
res += funcC(key); | |
} | |
} | |
if (f == 'D') { | |
for (int i=0; i<100000000; ++i) { | |
res += funcD(key); | |
} | |
} | |
cout << res << endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment