-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommonPermutation_UVA10252.cpp
55 lines (45 loc) · 1.06 KB
/
commonPermutation_UVA10252.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("commonPermutation_UVA10252.in");
ofstream fout("commonPermutation_UVA10252.out");
int main()
{
while (true)
{
string a = "", b = "";
getline(fin, a);
getline(fin, b);
int size0 = a.size(), size1 = b.size();
vector<bool> used(size1, false);
string ans = "";
for (int i = 0; i <= size0 - 1; ++i)
{
for (int j = 0; j <= size1 - 1; ++j)
{
if (a[i] == b[j] && used[j] == false)
{
ans += a[i];
used[j] = true;
break;
}
}
}
sort(ans.begin(), ans.end());
if (fin.eof())
{
break;
}
fout << ans << '\n';
}
return 0;
}