-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRO_STR.cs
130 lines (119 loc) · 3.6 KB
/
PRO_STR.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PRO_STR
{
class Program
{
static void Main(string[] args)
{
var a = Next().ToArray();
var listConvert = new List<Convert>();
var getNumber = "";
var j = 0;
for (int i = 0; i < a.Length; i++)
{
var tmp = (int)a[i]-48;
if (tmp>=0 && tmp<=9)
{
getNumber += a[i];
a[i] = '0';
for (j = i+1; j < a.Length; j++)
{
var tmp2 = (int)a[j] - 48;
if (tmp2<0 || tmp2>9)
{
break;
}
getNumber += a[j];
i = j;
a[j] = '0';
}
listConvert.Add(new Convert(getNumber,int.Parse(getNumber)));
getNumber = "";
}
}
listConvert.Sort();
var result = new StringBuilder();
j = 0;
for (int i = 0; i < a.Length; i++)
{
if (a[i]!='0') {
result.Append(a[i]);
}
else
{
for (int k = i + 1; k < a.Length; k++)
{
if (a[k]!='0')
{
break;
}
i = k;
}
result.Append(listConvert[j].number);
j++;
}
}
Console.WriteLine(result);
}
class Convert:IComparable<Convert>
{
public string number;
public int v;
public Convert(string number, int v)
{
this.number = number;
this.v = v;
}
public int CompareTo(Convert that)
{
return this.v - that.v;
}
}
static int s_index = 0;
static List<string> s_tokens;
private static string Next()
{
while (s_tokens == null || s_index == s_tokens.Count)
{
s_tokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
s_index = 0;
}
return s_tokens[s_index++];
}
private static bool HasNext()
{
while (s_tokens == null || s_index == s_tokens.Count)
{
s_tokens = null;
s_index = 0;
var nextLine = Console.ReadLine();
if (nextLine != null)
{
s_tokens = nextLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
else
{
return false;
}
}
return s_tokens.Count > 0;
}
private static int NextInt()
{
return Int32.Parse(Next());
}
private static double NextDouble()
{
return double.Parse(Next());
}
private static long NextLong()
{
return Int64.Parse(Next());
}
}
}