当前位置:网站首页>Niu Mei and 01 Chuan
Niu Mei and 01 Chuan
2022-06-11 12:41:00 【whitewall_ nine】
// Problem: Niu Meihe 01 strand
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/20960/1043
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// 2022-03-01 19:24:46
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair
const ll mod = 1e9 + 7;
inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a%mod;
a = a * a %mod;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
inline ll inv (ll a) {
return qmi(a, mod - 2);
}
int cnt[100005];
void solve() {
string s;
cin >> s;
int n = s.size();
for (int i = 0; i < n ;i ++)
{
cnt[i + 1] = s[i] == '0'?0 : 1;
cnt[i + 1] += cnt[ i ];
}
int m = 0;
for (int i = 1, l = 0; i <= n ; i++) {
if (cnt[i] - cnt[l] && i - l > cnt[i] - cnt[l]) {
l = i;
m ++;
}
}
cout << m << endl;
}
int main () {
int t;
t =1;
//cin >> t;
while (t --) solve();
return 0;
}
set up l Is the rightmost end of the previous segment . Then the properties that each segment needs to satisfy are 1 The number and 0 Are not equal and exist . Here, just use prefix and processing
边栏推荐
- Moist or not? This is a problem
- leetcode-59. Spiral matrix II JS
- Technical difficulties of secsha
- 2. Completablefuture
- 2022 vmvare download and installation tutorial on the latest official website (ultra detailed)
- 科海融生&正航,以信息化驱动管理升级,携手共迎数智未来
- 7、CAS
- 9、聊聊ThreadLocal
- CMD of Jerry's AI protocol_ SET_ BLE_ Format of visibility command [chapter]
- 1、线程基础知识
猜你喜欢

How can I use a domain name to access a website?

2022年618投影仪保值品牌榜,当贝投影闲鱼保值率排行TOP1

馆客多游泳馆会员管理系统可以实现哪些场景?

Oracle DatabaseLink cross database connection

Flink multi stream conversion (side output stream shunting, union, connect) real-time reconciliation of APP payment operations and third-party payment operations

Splunk health checks orphaned searches

Ways to double the summer performance of natatoriums

PADS使用之绘制原理图

13. Explanation of reentrantlock, reentrantreadwritelock and stampedlock

秒杀多级缓存-----商品详情页
随机推荐
(solve) the kV store down problem of Splunk
openharmony标准系统之app手动签名
How about Lenovo Xiaoxin 520? Which is more worth buying than dangbei D3x?
Record a CODIS memory cleanup
Jerry's aicmd_ SET_ BT_ Addr command format [chapter]
经营体育馆有哪些要素?
馆客多游泳馆会员管理系统可以实现哪些场景?
Record a troubleshooting of MySQL master-slave asynchrony
7、CAS
Which 4K projector is the most cost-effective? When the Bay X3 Pro highlights the 128G storage 618, it is worth seeing
Record a JVM GC process
Flink multi stream conversion (side output stream shunting, union, connect) real-time reconciliation of APP payment operations and third-party payment operations
9. Parler de threadlocal
C#事件总线
mysql的主从复制
Audio adaptation of openharmony Standard System Porting
Oracle database import data steps
知麻Z1投影仪真的好用吗?实际效果怎么样?
Sulley fuzzer learning
Oracle DatabaseLink cross database connection