-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10361 - Automatic Poetry.cpp
More file actions
140 lines (131 loc) · 3.02 KB
/
10361 - Automatic Poetry.cpp
File metadata and controls
140 lines (131 loc) · 3.02 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <iostream>
#include<stdlib.h>
#include <cstdio>
#include<sstream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define vc vector<int>
#define pb push_back
#define pf printf
#define mxpq priority_queue<int>
#define mnpq priority_queue<int,vector<int>,compare>
#define ms(a) memset(a,0,sizeof(a));
#define input(s) getline(cin,s);
#define mpii map<int,int>
#define mpsi map<string,int>
#define str string s;
#define sz size();
#define ln strlen(s);
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mn2(a, b) (a<b?a:b)
#define mn3(a, b, c) mn2(a, mn2(b, c))
#define mn4(a, b, c, d) mn2(a, mn2(b, mn2(c, d)))
#define mx2(a, b) (a>b?a:b)
#define mx3(a, b, c) mx2(a, mx2(b, c))
#define mx4(a, b, c, d) mx2(a, mx2(b, mx2(c, d)))
#define max 1000001
#define Pinf 99999999999
#define Ninf -99999999999
#define PI acos(-1)
#define MOD 1000000007
using namespace std;
int main()
{
string first,second,s2,s3,s4,s5;
int tc;
cin>>tc;
getchar();
while(tc--)
{
s2="";
s3="";
s4="";
s5="";
getline(cin,first);
getline(cin,second);
int flen=first.size();
bool found=false;
int count=0;
for(int i=0; i<flen; i++)
{
if(first[i]=='<')
{
found=true;
count++;
continue;
}
if(first[i]=='>')
{
found=false;
continue;
}
if(found==true)
{
if(count==1)
{
s2+=first[i];
}
else
s4+=first[i];
}
}
bool fnd=false;
int cnt=0;
for(int i=0; i<flen; i++)
{
if(first[i]=='>')
{
fnd=true;
cnt++;
continue;
}
if(first[i]=='<')
{
fnd=false;
continue;
}
if(fnd==true)
{
if(cnt==1)
{
s3+=first[i];
}
else
s5+=first[i];
}
}
for(int i=0; i<flen; i++)
{
if(first[i]=='<'||first[i]=='>')
{
continue;
}
else
printf("%c",first[i]);
}
printf("\n");
int slen=second.size();
for(int i=0; i<slen; i++)
{
if(second[i]=='.')
{
cout<<s4<<s3<<s2<<s5;
break;
}
else
printf("%c",second[i]);
}
printf("\n");
}
return 0;
}