Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Peam

Problemset: อะนาแกรม 2

Language: c

Time: 0.001 second

Submitted On: 2025-10-09 13:46:39

#include <stdio.h>
int main(){
    char str1[100001], str2[100001];
    scanf("%s%s", str1, str2);

    int box[8], box1[8], box2[8];
    //str1
    for(int i = 0; str1[i] != '\0'; i++){
        box1[str1[i] - 'A']++;
        box[str1[i] - 'A']++;
    }

    //str2
    for(int i = 0; str2[i] != '\0'; i++){
        box2[str2[i] - 'A']++;
        box[str2[i] - 'A']--;
    }

    int cnt = 0;
    for(int i = 0; i < 8; i++){
        if(box[i] != 0){
            cnt++;
            box[i] = box1[i] - box2[i];
            if(box[i] < 0){
                box[i] *= -1;
            }
        }

    }

    for(int i = 0; i < 8; i++){
        printf("%d ", box1[i]);
    }
    printf("\n");
    for(int i = 0; i < 8; i++){
        printf("%d ", box2[i]);
    }
    printf("\n");
    for(int i = 0; i < 8; i++){
        printf("%d ", box[i]);
    }
    printf("\n");
    if(cnt <= 3){
        printf("anagram");
    }
    else{
        printf("no");
    }

    return 0;
}