Submission

Status:

[PPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: pottersk146

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

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-12 19:13:11

#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string a;
    string b;
    cin>>a>>b;
    set<char> x;
    if (a.length()>b.length()){
        for (int i=0; i<a.length(); i++){
            for (int j=0; j<b.length(); j++){
                if (a[i]==b[j]){
                    x.insert(a[i]);
                }
            }
        }
    }
    else {
        for (int i=0; i<b.length(); i++){
            for (int j=0; j<a.length(); j++){
                if (b[i]==a[j]){
                    x.insert(b[i]);
                }
            }
        }
    }
    for (auto y:x){
        cout<<y<<" ";
    }
}