Submission #63806098
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*
"The only way to do great work is to love what you do." – Steve Jobs
*/
// author: dheeraj
#include <bits/stdc++.h>
#include <vector>
#include<set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <iterator>
#include <climits> // For LONG_LONG_MAX
#include <iomanip> // For fixed and setprecision if needed
#include <numeric> // For accumulate
#include <sstream> // For stringstream
using namespace std;
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Asquare cout.tie(NULL);
#define MOD 998244353
#define int long long
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
const lld pi = 3.141592653589793238;
// const ll INF = LONG_LONG_MAX;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll, ll> umll;
typedef map<ll, ll> mll;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i, n) for (int i = 0; i < n; i++)
#define rl(i, m, n) for (int i = n; i >= m; i--)
#define py cout << "YES\n";
#define pm cout << "-1\n";
#define pn cout << "NO\n";
#define vr(v) v.begin(), v.end()
#define rv(v) v.end(), v.begin()
template <typename T1, typename T2>
istream &operator>>(istream &istream, pair<T1, T2> &p) {
return (istream >> p.first >> p.second);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &ostream, const pair<T1, T2> &p) {
return (ostream << p.first << " " << p.second);
}
template <typename T>
void print(const T &t) {
cout << t << "\n";
}
void printarr(ll arr[], ll n) {
fl(i, n) cout << arr[i] << " ";
cout << "\n";
}
template <typename T>
void printvec(const vector<T> &v) {
for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
cout << *it << " ";
}
cout << "\n";
}
template <typename T>
ll sumvec(const vector<T> &v) {
ll s = 0;
fl(i, v.size()) s += v[i];
return s;
}
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b) * b); }
ll moduloMultiplication(ll a, ll b, ll mod) {
ll res = 0;
a %= mod;
while (b) {
if (b & 1) res = (res + a) % mod;
b >>= 1;
a = (a * 2) % mod;
}
return res;
}
ll powermod(ll x, ll y, ll p) {
ll res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
bool sorta(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
bool sortd(const pair<int, int> &a, const pair<int, int> &b) { return (a.second > b.second); }
string decToBinary(int n) {
string s = "";
while (n > 0) {
s = to_string(n % 2) + s;
n = n / 2;
}
return s;
}
ll binaryToDecimal(const string &n) {
ll dec_value = 0;
int base = 1;
int len = n.length();
for (int i = len - 1; i >= 0; i--) {
if (n[i] == '1') dec_value += base;
base = base * 2;
}
return dec_value;
}
bool isPrime(ll n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
bool isPowerOfTwo(int n) { return (n && !(n & (n - 1))); }
bool isPerfectSquare(ll x) {
if (x >= 0) {
ll sr = sqrt(x);
return (sr * sr == x);
}
return false;
}
void getPrime(ll p, map < ll, ll >&ma){
while(p%2 == 0) {
ma[2]++;
p/=2;
}
for(ll i = 3; i <= sqrt(p); i++) {
while(p%i == 0) {
ma[i]++;
p/=i;
}
}
if(p > 1)
ma[p]++;
}
bool has_seven(ll n) {
while (n) {
if (n % 10 == 7) return true;
n /= 10;
}
return false;
}
int mod_exp(int base, int exp, int mod) {
int res = 1;
while (exp > 0) {
if (exp & 1) res = (1LL * res * base) % mod;
base = (1LL * base * base) % mod;
exp >>= 1;
}
return res;
}
int countBits(int x) {
int count = 0;
while (x) {
count += (x & 1);
x >>= 1;
}
return count;
}
bool isP(ll n)
{
return ceil(sqrtl(n))== floor(sqrtl(n));
}
bool triangle( ll x , ll y , ll z)
{
return (x + y > z && y + z > x && z + x > y);
}
void solve() {
string s;
cin>>s;
int n=s.size();
int ans=0;
n=s.size();
for(int i=0;i<n-1;i++)
{
if(s[i]==s[i+1])
ans++;
}
int len=ans + n;
if(ans==0 && s[0]=='0' && len%2==1)
{
cout<<1<<endl;
return;
}
if(ans==0 && s[0]=='0' && len%2==0)
{
cout<<2<<endl;
return;
}
if(len & 1)
{
cout<<ans+1<<endl;
}
else
cout<<ans<<endl;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin>>t;
while (t--) {
solve();
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Ticket Gate Log |
User |
dheeraj_001 |
Language |
C++ 17 (gcc 12.2) |
Score |
0 |
Code Size |
5305 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
3596 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 250 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.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, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_01.txt |
AC |
1 ms |
3536 KB |
00_sample_02.txt |
AC |
1 ms |
3476 KB |
00_sample_03.txt |
AC |
1 ms |
3432 KB |
01_random_01.txt |
WA |
1 ms |
3472 KB |
01_random_02.txt |
WA |
1 ms |
3420 KB |
01_random_03.txt |
AC |
1 ms |
3428 KB |
01_random_04.txt |
AC |
1 ms |
3472 KB |
01_random_05.txt |
AC |
1 ms |
3436 KB |
01_random_06.txt |
AC |
1 ms |
3432 KB |
01_random_07.txt |
AC |
1 ms |
3528 KB |
01_random_08.txt |
AC |
1 ms |
3472 KB |
01_random_09.txt |
AC |
1 ms |
3504 KB |
01_random_10.txt |
AC |
1 ms |
3460 KB |
02_handmade_01.txt |
AC |
1 ms |
3596 KB |
02_handmade_02.txt |
AC |
1 ms |
3468 KB |
02_handmade_03.txt |
AC |
1 ms |
3360 KB |
02_handmade_04.txt |
WA |
1 ms |
3444 KB |