/main.cxx Secret
Created
February 15, 2016 16:29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <algorithm> | |
#include <set> | |
#include <sstream> | |
using namespace std; | |
set<string> res; | |
void go(int p1, string s1, int p2, string s2, string cur) { | |
if(p1 == s1.size() && p2 == s2.size()) { | |
res.insert(cur); | |
return; | |
} | |
if(p1 < s1.size()) { | |
go(p1 + 1, s1, p2, s2, cur + s1[p1]); | |
} | |
if(p2 < s2.size()) { | |
go(p1, s1, p2 + 1, s2, cur + s2[p2]); | |
} | |
} | |
int main() | |
{ | |
int T; | |
scanf("%d", &T); | |
while(T--) { | |
res.clear(); | |
char b1[100], b2[100]; | |
scanf("%s %s", b1, b2); | |
go(0, string(b1), 0, string(b2), ""); | |
for(set<string>::iterator it = res.begin(); it != res.end(); it++) | |
cout << *it << endl; | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment