Skip to content

Instantly share code, notes, and snippets.

@AgrYpn1a
Created February 11, 2015 16:05
Show Gist options
  • Save AgrYpn1a/7e2615d086139111a53b to your computer and use it in GitHub Desktop.
Save AgrYpn1a/7e2615d086139111a53b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string r1, r2;
int checkViruses (const int x, const int y, const int l) {
short int matches;
matches=0;
for (int i=-1; i<l-1; i++) {
if (r1[x+i] == r2[y+i])
matches++;
}
return matches;
}
int main()
{
short int n;
long int q;
vector<int> results;
cin >> n;
cin >> r1 >> r2;
cin >> q;
for (int i=0; i<q; i++) {
short int x, y, l;
cin >> x >> y >> l;
results.push_back(checkViruses(x, y, l));
}
for (vector<int>::iterator it=results.begin(); it != results.end(); ++it)
cout << *it << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment