94A - Restoring Password - CodeForces Solution


implementation strings *900

Please click on ads to support us..

Python Code:

s=str(input());a=[];t=''
for i in range(10):
    a.append(str(input()))
for i in range(0,80,10):
    p=s[i:i+10]
    for j in range(10):
        if a[j]==p:
            t+=str(j)
            break
print(t)

C++ Code:

#include <bits/stdc++.h>
#define ll long long
#define ib ios_base::sync_with_stdio(false)
#define ct cin.tie(NULL)
#define inf INT_MAX
using namespace std;

/*
 
1. Think Greedy
2. Think Brute Force
3. Think solution in reverse order
4. Think DP [ check constraints carefully ]
5. Check base cases for DP and prove solution for Greedy
6. Think Graph 
 
*/

void solve() {
    string word;
    cin >> word;
    
    unordered_map<string, int> m;
    for(int i = 0 ; i < 10 ;i ++) {
        string pattern;
        cin >> pattern;
        m[pattern] = i;
    }
    
    for(int i = 0 ; i < 8 ; i ++) {
        string pattern = word.substr(i*10, 10);
        cout << m[pattern];
    }
    
    cout << "\n";
}

int main() {
	// your code goes here
	ib;
	ct;
// 	int t;
// 	cin >> t;
// 	while (t -- > 0) {
	    solve();
// 	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

1650A - Deletions of Two Adjacent Letters
1512A - Spy Detected
282A - Bit++
69A - Young Physicist
1651A - Playoff
734A - Anton and Danik
1300B - Assigning to Classes
1647A - Madoka and Math Dad
710A - King Moves
1131A - Sea Battle
118A - String Task
236A - Boy or Girl
271A - Beautiful Year
520B - Two Buttons
231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number