Submission

Status:

[PPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: eefirefire

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-22 16:54:05

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s1, s2;
    if (cin >> s1 >> s2) {
        vector<bool> in_s1(256, false);
        vector<bool> in_s2(256, false);

        for (char c : s1) {
            if (isalpha(c)) in_s1[(unsigned char)c] = true;
        }
        for (char c : s2) {
            if (isalpha(c)) in_s2[(unsigned char)c] = true;
        }

        string common = "";
        for (int i = 0; i < 256; i++) {
            if (in_s1[i] && in_s2[i]) {
                common += (char)i;
            }
        }

        sort(common.begin(), common.end());

        cout << common << '\n';
    }
}