Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #include <time.h>
- #pragma warning(disable:4996)
- typedef long long LL;
- typedef unsigned long long ULL;
- char s1[114514] = { 0 }, s2[114514] = { 0 };
- int main(){
- int m, n, i, j, flag1 = 0, flag2 = 0;
- int count1[30] = { 0 }, count2[30] = { 0 };
- scanf("%s%s", s1, s2);
- m = strlen(s1);
- n = strlen(s2);
- if(m > n){
- puts("Single Forever!");
- }
- else{//m<n
- for(i = 0; i < m; i++){
- count1[s1[i] - 'a'] += 1;
- count2[s2[i] - 'a'] += 1;
- }
- flag1 = 1;
- for(i = 0; i < 26; i++){
- if(count1[i] != count2[i]){
- flag1 = 0;
- break;
- }
- }
- if(flag1){
- puts("65472");
- }
- else{
- for(j = m; j < n; j++){
- count2[s2[j - m] - 'a'] -= 1;
- count2[s2[j] - 'a'] += 1;
- flag1 = 1;
- if(flag2){
- break;
- }
- for(i = 0; i < 26; i++){
- if(count1[i] != count2[i]){
- flag1 = 0;
- break;
- }
- }
- if(flag1){
- flag2 = 1;
- }
- }
- if(flag2){
- puts("65472");
- }
- else{
- puts("Single Forever!");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment