Submission

Status:

[PPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: jeeno987

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

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-10 18:17:01

#include <iostream>
#include <string>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    bool inB[256] = {false}, printed[256] = {false};
    for (int i = 0; i < (int)b.size(); i++) inB[(unsigned char)b[i]] = true;
    bool first = true;
    for (int i = 0; i < (int)a.size(); i++) {
        unsigned char c = a[i];
        if (inB[c] && !printed[c]) {
            if (!first) cout << ' ';
            cout << a[i];
            printed[c] = true;
            first = false;
        }
    }
    cout << '\n';
    return 0;
}