blob: fa74a22ce835fdc7bc2926e55036fa82b292138b (
plain)
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
|
#include<iostream>
#include<sstream>
#include<fstream>
using namespace std;
string check(string s, char chs[], int n) {
if(s.length()<n) { cout << s << endl ;return "";}
int i;
for(i = 0; i < n-1; ++i) {
if(s.at(i) != chs[i])
return "";
}
if(s.at(i) == chs[i]) return "";
return s;
}
void get_chs(string s, char* chs, int n) {
if(s.length()<n) return;
for(int i = 0; i < n; ++i) {
chs[i] = s.at(i);
//cout << chs[i];
}
//cout << "*" << endl;
}
int main() {
ifstream in("input.txt");
ofstream out("output.txt");
for(int ts = 0; ts < 100; ++ts) {
int n;
string s;
in >> n >> s;
++n;
char* chs = new char[n];
out << s << ' ';
get_chs(s, chs, n);
for(int i = 0; i < 2; ++i) {
in >> s;
out << check(s, chs, n);
get_chs(s, chs, n);
}
out << '\n';
}
in.close();
out.close();
return 0;
}
|