Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
int main(){
const int N = 10; const int D = 10; const int L = 8;
std::string input; getline(std::cin, input);
std::map<std::string, int> digits;
for(int k = 0; k < N; k++){
std::string temp; getline(std::cin, temp);
digits.insert(std::pair<std::string, int>(temp, k));
}
for(int k = 0; k < L; k++){
std::string temp = input.substr(k * D, D);
std::cout << digits[temp];
}
puts("");
return 0;
}
Copy The Code &
Try With Live Editor
Input
01001100100101100000010110001001011001000101100110010110100001011010100101101100
0100110000
0100110010
0101100000
0101100010
0101100100
0101100110
0101101000
0101101010
0101101100
0101101110
0100110000
0100110010
0101100000
0101100010
0101100100
0101100110
0101101000
0101101010
0101101100
0101101110
Output
12345678
Demonstration
Codeforces Solution-A. Restoring Password-Solution in C, C++, Java, Python