Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by olol ( 14 years ago )
#include "iostream"
#include "string"
#include "stdlib.h"
#include "math.h"
using namespace std;
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
char s[10001];
char p[10001];
int a[1000];
int b[1000];
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
#endif
//==============================================================
int i=0,sn=0,pn=0,nar=0;
scanf("%c",&s[i]);
while (s[i] != 'n')
{
i++;
scanf("%c",&s[i]);
}
sn=i;
i=0;
scanf("%c",&p[i]);
a[p[i]]++;
while (p[i] >= 'a' && p[i] <= 'z')
{
i++;
scanf("%c",&p[i]);
a[p[i]]++;
}
pn=i;
if (pn > sn)
{
cout << 0;
return 0;
}
for (int j = 0; j < pn;j++)
{
if (s[j] != '?')
{
b[s[j]]++;
if (b[s[j]] > a[s[j]])
nar++;
}
}
int ot=0;
if (nar==0) ot++;
for (int j = pn; j < sn; j++)
{
if (s[j-pn] != '?')
{
b[s[j-pn]]--;
if (b[s[j-pn]] == a[s[j-pn]])nar--;
}
if (s[j] != '?')
{
b[s[j]]++;
if (b[s[j]]-1 == a[s[j]])nar++;
}
if (nar==0) ot++;
}
cout << ot;
return 0;
}
Revise this Paste