-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
109 lines (108 loc) · 2.69 KB
/
B.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
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
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main() {
string s;
long long n,i,p=0,cur,prev,j;
vector<string> vect;
string tmp1,tmp2;
cin>>s;
n=s.size();
cur=n;
for(i=n-1;i>=0;i--)
{
if(s[i]=='.')
{
if(i==0)
{
p=1;
break;
}
if(cur==n)
{
if(i==n-1 || i<n-4)
{
//cout<<i<<"\n";
p=1;
break;
}
else
{
for(j=i+1;j<n;j++)
tmp2.push_back(s[j]);
cur=i;
}
}
//else if(i==0)
//{
//cout<<i<<"\n";
//p=1;
//break;
//}
else
{
if(cur-i<3 || cur-i>12)
{
//cout<<i<<"\n";
p=1;
break;
}
else
{
if(cur-i<=10)
{
for(j=i+2;j<cur;j++)
{
tmp1.push_back(s[j]);
}
tmp1.push_back('.');
tmp1.append(tmp2);
vect.push_back(tmp1);
tmp1.clear();
tmp2.clear();
tmp2.push_back(s[i+1]);
}
else
{
for(j=cur-8;j<cur;j++)
{
tmp1.push_back(s[j]);
}
tmp1.push_back('.');
tmp1.append(tmp2);
vect.push_back(tmp1);
tmp1.clear();
tmp2.clear();
for(j=i+1;j<cur-8;j++)
tmp2.push_back(s[j]);
}
cur=i;
}
}
}
if(i==0)
{
if(cur>8 || cur==n)
{
//cout<<cur<<"\n";
p=1;
break;
}
for(j=0;j<cur;j++)
tmp1.push_back(s[j]);
tmp1.push_back('.');
tmp1.append(tmp2);
vect.push_back(tmp1);
}
}
if(p==1)
cout<<"NO\n";
else
{
cout<<"YES\n";
for(i=vect.size()-1;i>=0;i--)
cout<<vect[i]<<"\n";
}
return 0;
}