Skip to content

Instantly share code, notes, and snippets.

@AgrYpn1a
Created February 11, 2015 16:04
Show Gist options
  • Save AgrYpn1a/1dc8e1dd9b36eb8a5a76 to your computer and use it in GitHub Desktop.
Save AgrYpn1a/1dc8e1dd9b36eb8a5a76 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;
cin >> n;
cin >> r1 >> r2;
cin >> q;
for (int i=0; i<q; i++) {
short int x, y, l;
cin >> x >> y >> l;
cout << checkViruses(x, y, l) << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment