Submission #71131353


Source Code Expand

/* Code By WCM */
/*
Date:
大致思路:
复杂度:
期望得分:
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <vector>
#include <queue>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;

inline int read();
void write(int);
void writeln(int);

vector <pii> r;
long long ans;

int main() {

//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n;) {
		int j = i;
		while(j < n && s[j] == s[i]) j++;
		r.eb(s[i] - '0', j - i), i = j;
	}
	for(int i = 0; i + 1 < r.size(); i++) 
		if(r[i + 1].fi == r[i].fi + 1) ans += min(r[i].se, r[i + 1].se);
	
	printf("%lld\n", ans);
	
//	printf("\nThe time used: ");
//	printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);

	return 0;

}

inline int read() {
	int res = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
	while(ch >= '0' && ch <= '9') res = (res << 1) + (res << 3) + (ch ^ 48), ch = getchar();
	return res * f;
}

void write(int x) {
	static int sta[35];
	int top = 0;
	do { sta[top++] = x % 10, x /= 10; } while(x);
	while(top) putchar(sta[--top] ^ 48);
}

void writeln(int x) {
	write(x);
	putchar('\n');
}


Submission Info

Submission Time
Task C - 1122 Substring 2
User WZwangchongming
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1459 Byte
Status AC
Exec Time 21 ms
Memory 13748 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i = 0; i + 1 < r.size(); i++)
      |                        ~~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 23
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3768 KiB
00_sample_01.txt AC 1 ms 3772 KiB
00_sample_02.txt AC 1 ms 3812 KiB
00_sample_03.txt AC 1 ms 3820 KiB
01_random_00.txt AC 1 ms 3740 KiB
01_random_01.txt AC 12 ms 5288 KiB
01_random_02.txt AC 12 ms 5396 KiB
01_random_03.txt AC 12 ms 5364 KiB
01_random_04.txt AC 12 ms 5396 KiB
01_random_05.txt AC 12 ms 5448 KiB
01_random_06.txt AC 18 ms 12864 KiB
01_random_07.txt AC 20 ms 13576 KiB
01_random_08.txt AC 7 ms 8024 KiB
01_random_09.txt AC 21 ms 13748 KiB
01_random_10.txt AC 19 ms 9704 KiB
01_random_11.txt AC 19 ms 9536 KiB
01_random_12.txt AC 19 ms 9484 KiB
01_random_13.txt AC 14 ms 6376 KiB
01_random_14.txt AC 14 ms 6260 KiB
01_random_15.txt AC 19 ms 13584 KiB
01_random_16.txt AC 19 ms 13472 KiB
01_random_17.txt AC 15 ms 9480 KiB
01_random_18.txt AC 18 ms 13568 KiB