ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#194887 | #3417. 序列转换 | diamond_plus | 100 | 1ms | 1236kb | C++11 | 1.7kb | 2023-10-18 18:08:18 | 2023-10-18 21:38:14 |
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
using namespace std;
#define rd read()
#define int long long
// const int N = ;
const int MOD = 998244353;
const int INF = 0x7fffffff;
const int Fill = 0x3f;
const int FillINF = 0x3f3f3f3f;
void write(int n)
{
if (n < 0)
{
putchar('-');
n = -n;
}
if (n < 10)
{
putchar(n + '0');
return;
}
write(n / 10);
putchar(n % 10 + '0');
return;
}
void wt(int n, bool o = 1)
{
write(n);
if (!o)
{
putchar(' ');
}
else
{
putchar('\n');
}
}
int read()
{
char ch;
int type = 1, n = 0;
ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
{
type = -1;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
n = (n << 1) + (n << 3) + (ch ^ 48);
ch = getchar();
}
return n * type;
}
int n;
void solve()
{
int i, j;
int cnt = 0;
string s, ans = "";
char now;
n = rd;
cin >> s;
now = s[0];
cnt = 1;
if (n == 1)
{
cout << 1 << s;
return ;
}
for (i = 1; i < s.size(); i++)
{
if (s[i] == now)
{
cnt++;
continue;
}
cout << cnt << now;
cnt = 1;
now = s[i];
}
cout << cnt << now;
}
signed main()
{
int T;
int i, j;
T = 1;
while (T--)
{
solve();
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 1ms
memory: 1232kb
input:
10 0123123023
output:
10111213111213101213
result:
ok single line: '10111213111213101213'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
10 0123412340
output:
10111213141112131410
result:
ok single line: '10111213141112131410'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1236kb
input:
100 011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110...
output:
1021101120212011102110112011102120211011202120111021202110112011102110112021201110211011201110212021...
result:
ok single line: '102110112021201110211011201110...1201110211011202120111021202110'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
100 012120201120201012201012120120201012201012120012120201201012120012120201120201012120201012201012...
output:
1011121112101210211210121011101122101110111211121011121012101110112210111011121112201112111210121011...
result:
ok single line: '101112111210121021121012101110...2101210111011221011101112111220'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
100 012312302301301212302301301201232301301201231230301201231230230112302301301201232301301201231230...
output:
1011121311121310121310111310111211121310121310111310111210111213121310111310111210111213111213101310...
result:
ok single line: '101112131112131012131011131011...3101112101112131112131013101112'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
100 012341234023401340124012312340234013401240123012342340134012401230123412340340124012301234123402...
output:
1011121314111213141012131410111314101112141011121311121314101213141011131410111214101112131011121314...
result:
ok single line: '101112131411121314101213141011...3101112131411121314101213141011'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1236kb
input:
1000 01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011001011...
output:
1021101120212011102110112011102120211011202120111021202110112011102110112021201110211011201110212021...
result:
ok single line: '102110112021201110211011201110...1201110212021101120212011102110'
Test #8:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
1000 01212020112020101220101212012020101220101212001212020120101212001212020112020101212020101220101...
output:
1011121112101210211210121011101122101110111211121011121012101110112210111011121112201112111210121011...
result:
ok single line: '101112111210121021121012101110...2111210121021121012101110111210'
Test #9:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
1000 01231230230130121230230130120123230130120123123030120123123023011230230130120123230130120123123...
output:
1011121311121310121310111310111211121310121310111310111210111213121310111310111210111213111213101310...
result:
ok single line: '101112131112131012131011131011...1121310121310111011121311121310'
Test #10:
score: 10
Accepted
time: 0ms
memory: 1236kb
input:
1000 01234123402340134012401231234023401340124012301234234013401240123012341234034012401230123412340...
output:
1011121314111213141012131410111314101112141011121311121314101213141011131410111214101112131011121314...
result:
ok single line: '101112131411121314101213141011...2141011121310111213141112131410'
Extra Test:
score: 0
Extra Test Passed