Submission

Status:
[PPPPPPPP]

Score: 100

User: Pera

Problemset: สตริงซ้ำซ้ำ

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-26 09:52:59

#include <bits/stdc++.h>
using namespace std;

int main() {
    string str1, str2;
    cin >> str1 >> str2;

    vector<int> count1(52, 0);
    vector<int> count2(52, 0);
    for (int i = 0; i < str1.size(); ++i) {
        if (str1[i] >= 'a') count1[str1[i] - 'a' + 26]++;
        else count1[str1[i] - 'A']++;
    } 
    for (int i = 0; i < str2.size(); ++i) {
        if (str2[i] >= 'a') count2[str2[i] - 'a' + 26]++;
        else count2[str2[i] - 'A']++;
    }

    for (int i = 0; i < 52; i++) {
        if (i < 26 && count1[i] >= 1 && count2[i] >= 1) {
            char ch = 'A' + i;
            cout << ch << ' ';
        }
        else if (i >= 26 && count1[i] >= 1 && count2[i] >= 1) {
            char ch = i - 26 + 'a';
            cout << ch << ' ';
    }
}
    cout << '\n';
}