Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int fermate,nsegni,cont=0;
- string apertura1, apertura2,watched,watched2;
- cin>>fermate;
- cin>>apertura1;
- cin>>apertura2;
- cin>>nsegni;
- cin>>watched;
- //converto la sequenza vista nei caratteri delle fermate
- for(int i=0;i<nsegni;i++){
- if(watched[i]=='<'){
- watched[i]='^';
- watched2.push_back('v');
- }else{
- watched[i]='v';
- watched2.push_back('^');
- }
- }
- // inverto la sequenza cosi da rispettare i versi
- reverse(watched2.begin(),watched2.end());
- // conto le ripetizioni
- for(int i=0;i<=fermate-nsegni;i++){
- if(apertura1.substr(i,nsegni)==watched){
- cont++;
- }
- if(apertura2.substr(i,nsegni)==watched2){
- cont++;
- }
- }
- cout<<cont;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement