FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Competitive-Programming/ACMvsBSW.cpp at master · KevinMathewT/Competitive-Programming · GitHub
KevinMathewT
/
Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Competitive-Programming
/
ACMvsBSW.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (71 loc) · 1.54 KB
Breadcrumbs
Competitive-Programming
/
ACMvsBSW.cpp
Copy path
File metadata and controls
82 lines (71 loc) · 1.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
bits/stdc++.h
>
using
namespace
std
;
typedef
long
long
ll;
//
Author - Kevin Mathew
//
Birla Institute of Technology, Mesra
string s;
vector<string> ans;
void
te
(){
ans.
clear
();
cin >> s;
//
cout << s << "-\n";
ll point = s.
size
()-
1
;
string last =
"
"
;
string total = last;
string curr =
"
"
;
ll flag;
//
cout << last << " " << total << " " << curr << " " << point << "\n";
while
(point >=
0
){
cout << last <<
"
"
<< total <<
"
"
<< curr <<
"
"
<< point <<
"
\n
"
;
flag =
0
;
curr = s[point] + curr;
cout << last <<
"
"
<< total <<
"
"
<< curr <<
"
"
<< point <<
"
\n
"
;
if
(curr.
size
() > total.
size
()){
total = curr + total;
ans.
push_back
(curr);
last = curr;
curr =
"
"
;
flag =
1
;
}
if
(curr.
size
() < total.
size
()){
for
(ll i=
0
;i<total.
size
()-curr.
size
();i++)
curr =
"
0
"
+ curr;
}
if
(curr.
size
() == total.
size
()){
for
(ll i=
0
;i<curr.
size
();i++)
if
(curr[i] >= total[i]){
total = curr + total;
ans.
push_back
(curr);
last = curr;
curr =
"
"
;
flag =
1
;
break
;
}
else
break
;
}
//
cout << flag << "-\n";
if
(point ==
0
&& flag ==
0
){
ans[ans.
size
()-
1
] = curr + ans[ans.
size
()-
1
];
break
;
}
point--;
}
cout << ans.
size
() <<
"
\n
"
;
for
(ll i=ans.
size
()-
1
;i>=
0
;i--)
cout << ans[i] <<
"
"
;
cout <<
"
\n
"
;
}
int
main
()
{
freopen
(
"
input.txt
"
,
"
r
"
, stdin);
//
Comment
freopen
(
"
output.txt
"
,
"
w
"
, stdout);
//
this out.
ios::sync_with_stdio
(
false
);
//
Not
cin.
tie
(
NULL
);
//
this.
cout.
tie
(
0
);
//
or this.
ll T;
cin >> T;
while
(T--)
te
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL