Submission

Status:

[PPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: pottersk146

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-09 19:33:17

#include <iostream>
#include <set>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string a;
    string b;
    getline(cin, a);
    getline(cin, b);
    set<char> v;
    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]){
                    v.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]){
                    v.insert(b[i]);
                }
            }
        }
    }
    for (char c : v) {
        cout << c << " ";
    }
    return 0;
}