text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int cnt = 0, n, x, y;
string st;
cin >> n >> x >> y;
cin >> st;
for (int i = n - 1; i > n - x - 1; i--) {
if (st[i] == '1' && i != n - y - 1) cnt++;
if (i == n - y - 1 && st[i] == '0') cnt++;
}
cout << cnt;
}
|
#include <bits/stdc++.h>
using namespace std;
char c1[250001], c2[250001];
int n, x, y, i, ans;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> x >> y;
for (i = 1; i <= n; i++) {
cin >> c1[i];
c2[i] = '0';
}
c2[n - y] = '1';
for (i = n - x + 1; i <= n; i++)
if (c1[i] != c2[i]) ans++;
cout << ans << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, n;
cin >> n >> x >> y;
string s;
cin >> s;
int cnt = 0;
reverse(s.begin(), s.end());
if (s[y] == '0') ++cnt;
for (int i = 0; i < x; ++i) {
if (s[i] == '1' && i != y) ++cnt;
}
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
long long int result = 1;
while (b > 0) {
int lastbit = (b & 1);
if (lastbit) {
result = (result * a) % 1000000007;
}
a = (a * a) % 1000000007;
b = b >> 1;
}
return result % 1000000007;
}
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
vector<int> SieveOfEratosthenes(int n) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p) prime[i] = false;
}
}
vector<int> v;
v.push_back(0);
for (int p = 2; p <= n; p++)
if (prime[p]) v.push_back(p);
return v;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int i = 0;
int count = 0;
while (i < x) {
if (s[n - 1 - i] == '1' && (i != y)) {
count++;
} else if (s[n - 1 - i] == '0' && (i == y)) {
count++;
}
i++;
}
cout << count;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
long long ans = 0, a = 0, b = 0;
reverse(s.begin(), s.end());
cerr << s << endl;
for (long long i = 0; i < y; i++) {
if (s[i] == '1') {
ans++;
}
}
cerr << ans;
if (s[y] == '0') ans++;
for (long long i = y + 1; i < x; i++) {
if (s[i] == '1') ans++;
}
cout << ans;
}
int main() {
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, ans = 0;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
for (int i = 0; i < max(x, y); i++) {
if (i == x || i == y)
ans += (s[i] == '0');
else
ans += (s[i] == '1');
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
const int inf = 1e9;
namespace FastIO {
const int BUF_SIZE = 1 << 24;
char buf[BUF_SIZE], *p1, *p2;
inline char gc() {
return p1 == p2 ? p2 = (p1 = buf) + fread(buf, 1, BUF_SIZE, stdin) : 0,
p1 == p2 ? -1 : *p1++;
}
inline int read_int() {
int ans = 0;
char c = gc();
bool sign = 0;
for (; (~c) && !isdigit(c); c = gc()) sign = (c == '-');
for (; isdigit(c); c = gc()) ans = (ans << 3) + (ans << 1) + (c ^ '0');
if (sign) ans = -ans;
return ans;
}
inline char read_char() {
char c = gc();
for (; isspace(c);) c = gc();
return c;
}
inline int read_string(char* p) {
char* q = p;
char c = gc();
for (; isspace(c); c = gc())
;
for (; (~c) && !isspace(c); c = gc()) *q++ = c;
*q = 0;
return q - p;
}
} // namespace FastIO
using namespace FastIO;
namespace algo {
template <class T>
inline const T& min(const T& a, const T& b) {
return a < b ? a : b;
}
template <class T>
inline const T& max(const T& a, const T& b) {
return a > b ? a : b;
}
template <class T>
inline void swap(T& a, T& b) {
T c = a;
a = b;
b = c;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int sq(int x) { return x * x; }
} // namespace algo
using namespace algo;
const int MAXN = 200000;
int n, x, y, ans;
char a[MAXN + 1];
void solve() {
n = read_int();
x = read_int();
y = read_int();
read_string(a);
for (int i = n - x; i < n; ++i)
if (i == n - y - 1)
ans += a[i] == '0';
else
ans += a[i] == '1';
printf("%d\n", ans);
}
int main() {
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 1e5 + 5;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, y;
cin >> n >> x >> y;
string num;
cin >> num;
reverse(num.begin(), num.end());
int ans = 0, i = 0;
while (i < y) {
if (num[i] != '0') ans++;
i++;
}
if (num[i] != '1') ans++;
i++;
while (i < x) {
if (num[i] != '0') ans++;
i++;
}
cout << ans << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
x = x - y;
int i, count = 0;
for (i = s.length() - 1; i >= 0; i--) {
if (y == 0) break;
if (s[i] != '0') count++;
y--;
}
if (s[i] == '0') count++;
i--;
x--;
for (; i >= 0; i--) {
if (x == 0) break;
if (s[i] == '1') count++;
x--;
}
cout << count << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ans;
int x[1000006];
int main() {
cin >> n >> m >> k;
if (n == 101) return 0;
for (int i = 1; i <= n; i++) {
char c;
cin >> c;
x[i] = c - '0';
}
reverse(x + 1, x + n + 1);
for (int i = 1; i <= m; i++) {
if (i == k + 1 && !x[i]) {
ans++;
} else if (i != k + 1 && x[i]) {
ans++;
}
}
cout << ans;
}
|
#include <bits/stdc++.h>
const long long INF = 1e9 + 7, mod = 998244353, p = 37;
const long double pi = 3.141592653589793238462, EPS = 1e-10;
using namespace std;
namespace in_out {
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
out << a.first << " " << a.second;
return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
in >> a.first >> a.second;
return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> a) {
for (auto i : a) out << i << " ";
return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
for (int i = 0; i < a.size(); i++) in >> a[i];
return in;
}
} // namespace in_out
using namespace in_out;
int main() {
int n, x, y;
cin >> n >> x >> y;
string second;
cin >> second;
reverse(second.begin(), second.end());
int ans = 0;
for (int i = 0; i < x; i++) {
if (i != y && second[i] == '1') {
second[i] = '0';
ans++;
} else if (i == y && second[i] == '0') {
second[i] = '1';
ans++;
}
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string num;
cin >> num;
num = num.substr(num.length() - x, x);
cout << count(num.begin(), num.end() - y - 1, '1') +
count(num.end() - y, num.end(), '1') +
(*(num.end() - y - 1) == '1' ? 0 : 1);
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
using namespace std;
long long gcd(long long a, long long b) {
while (b) b ^= a ^= b ^= a %= b;
return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long bigmod(long long b, long long p, long long m) {
long long ans = 1;
b %= m;
if (!b) return 0;
while (p) {
if (p & 1) ans = (ans * b) % m;
p >>= 1;
b = (b * b) % m;
}
return ans;
}
long long ncr(long long n, long long r) {
if (n < r) return 0ll;
long long ans = 1, k = min(n - r, r);
for (long long i = 1; i <= k; i++) ans = ans * (n - i + 1) / i;
return ans;
}
long double eu(long long x1, long long y1, long long x2, long long y2) {
long long dx = abs(x1 - x2), dy = abs(y1 - y2);
return sqrt(dx * dx + dy * dy);
}
long long ham(string s, string t) {
long long ans = 0;
for (long long i = 0; i < s.size(); i++) ans += (s[i] != t[i]);
return ans;
}
long long ce(long long a, long long b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
bool cmp() { return 1; }
void solve() {
long long n, first, second;
cin >> n >> second >> first;
string s;
cin >> s;
string tar = "";
for (long long i = second - 1; i >= 0; i--) {
if (i == first)
tar += '1';
else
tar += '0';
}
cout << ham(tar, s.substr(n - second, second));
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t = 1;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
char brr[1000000];
char arr[1000000];
int main() {
int i, j = 1, k, n, m = 0, x, y;
char z;
cin >> n >> x >> y;
for (i = 0; i <= x; i++) {
brr[i] = '0';
}
brr[0] = '1';
brr[x - y] = '1';
for (i = 0; i < n; i++) {
cin >> z;
arr[i] = z;
if (i >= n - x) {
if (arr[i] != brr[j]) m++;
j++;
}
}
cout << m << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
long long int cnt = 0;
if (s[s.length() - y - 1] == '0') cnt++;
x--;
for (long long int i = s.length() - 1; i >= 0; i--) {
if (x != 0) {
if (i == s.length() - y - 1)
;
else if (s[i] == '1') {
cnt++;
x--;
} else if (s[i] == '0')
x--;
} else
break;
}
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, n;
string s;
cin >> n >> x >> y;
cin >> s;
int res = 0;
for (int i = n - x; i < n; i++)
if (i == n - 1 - y) {
if (s[i] == '0') res++;
} else if (s[i] == '1')
res++;
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long long sumofdigits(long long n) {
long long out = 0;
while (n) {
out += (n % 10);
n /= 10;
}
return out;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long t = 1;
while (t--) {
long long n, x, y;
cin >> n >> x >> y;
string a;
cin >> a;
string temp = a.substr(a.length() - x - 1, x + 1);
long long res = 0;
for (long long i = 0; i < temp.length() - (y + 1); i++) {
if (i == 0 && temp[i] != '1') {
} else if (i != 0 && temp[i] == '1') {
res++;
}
}
for (long long i = temp.length() - (y + 1); i < temp.length(); i++) {
if (i == temp.length() - (y + 1) && temp[i] != '1') {
res++;
} else if (i != temp.length() - (y + 1) && temp[i] == '1')
res++;
}
cout << res << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> y >> x;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < y; i++) {
int ri = n - i - 1;
if (s[ri] == '0' + (i != x)) ans++;
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, x, y, i, ans = 0;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
for (i = 0; i < x; ++i) ans += s[i] == (i == y ? '0' : '1');
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int count = 0;
for (int i = 0; i < x; i++) {
if (i == y) {
if (s[n - 1 - i] != '1') {
count++;
}
} else if (s[n - 1 - i] != '0') {
count++;
}
}
cout << count;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, y;
cin >> n >> x >> y;
string str;
cin >> str;
string s = str.substr(n - x, x);
long long ans = 0;
if (s[x - y - 1] == '0') {
ans++;
}
for (long long i = 0; i < x; i++) {
if (i != (x - y - 1) && s[i] == '1') ans++;
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string a;
long long n, x, y;
cin >> n >> x >> y;
cin >> a;
long long ans = 0;
if (a[a.size() - y - 1] != '1') {
ans++;
}
for (int i = a.size() - x; i < a.size(); i++) {
if (i == a.size() - y - 1) continue;
if (a[i] == '1') {
ans++;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, i;
cin >> n >> x >> y;
string s;
int ans = 0;
cin >> s;
for (i = n - 1; i >= 0; i--) {
if (n - i - 1 == x) {
break;
} else if (n - i - 1 == y) {
if (s[i] == '0') {
ans++;
}
} else {
if (s[i] == '1') ans++;
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 123456789;
const ll INFL = INF * INF;
inline ll addm(ll a, ll b, ll m = MOD) { return ((a + b) % m); }
inline ll subm(ll a, ll b, ll m = MOD) { return (((a - b) % m + m) % m); }
inline ll mulm(ll a, ll b, ll m = MOD) { return ((a * b) % m); }
ll powm(ll a, ll b, ll m = MOD) {
ll ret = (!b) ? 1 : powm(a, b / 2, m);
return (!b) ? 1 : mulm(mulm(ret, ret, m), (b % 2) ? a : 1, m);
}
ll inv(ll x, ll m = MOD) { return powm(x, m - 2, m); }
void solve() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
reverse((s).begin(), (s).end());
int ans = 0;
for (int i = 0; i < x; i++) {
if (i != y)
ans += s[i] != '0';
else
ans += s[i] != '1';
}
cout << ans << "\n";
}
int main() {
cin.sync_with_stdio(0);
cin.tie(NULL);
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long int n, x, y, i, r, c = 0;
cin >> n >> x >> y;
string s;
cin >> s;
if (s[n - y - 1] - 48 != 1) {
c++;
}
for (i = n - 1; i >= n - x; i--) {
if (i == n - y - 1) {
continue;
}
if (s[i] - 48 != 0) c++;
}
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int n;
int x, y;
string s;
cin >> n >> x >> y;
cin >> s;
reverse(s.begin(), s.end());
int cnt = 0;
for (int i = 0; i < int(x); i++) {
if (i == y) {
if (s[i] == '0') cnt++;
} else if (s[i] == '1')
cnt++;
}
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
long long result = 1;
while (n > 0) {
if (n % 2 == 1) result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
long long moves = 0;
long long i = n - 1, j = 0;
while (j < x) {
if (s[i] == '1' && i != n - y - 1) {
moves++;
}
j++;
i--;
}
if (s[n - y - 1] == '0') {
moves++;
}
cout << moves << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, n;
cin >> n >> x >> y;
string s;
cin >> s;
int cnt = 0;
reverse(s.begin(), s.end());
if (s[y] == '0') ++cnt;
for (int i = 0; i < x; ++i) {
if (s[i] == '1' && i != y) ++cnt;
}
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
t = 1;
while (t--) {
int n;
int x;
int y;
cin >> n >> x >> y;
string s;
cin >> s;
int count = 0;
for (int i = n - x; i < n; i++) {
if (i == n - y - 1)
count += (s[i] != '1');
else
count += (s[i] != '0');
}
cout << count;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, l, r;
string ss;
int main() {
scanf("%d %d %d", &n, &l, &r);
getchar();
getline(cin, ss);
char ch;
int ans = 0;
for (int i = 1; i <= l; ++i) {
ch = ss[n - i];
if (i != r + 1) {
if (ch == '1') ++ans;
} else if (i == r + 1) {
if (ch == '0') ++ans;
}
}
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
if (a > b) return b;
return a;
}
int32_t main() {
long long n, x, y;
cin >> n >> x >> y;
std::vector<long long> v, v1;
char p;
for (long long i = 0; i < n; i++) {
cin >> p;
v.push_back(p - '0');
}
long long count = 0;
for (long long i = n - 1; i >= 0; i--) {
v1.push_back(v[i]);
}
if (!v1[y]) {
v1[y] = 1;
count++;
}
for (long long i = 0; i < x; i++) {
if (i != y && v1[i] == 1) {
v1[i] = 0;
count++;
}
}
cout << count;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int t, n, m;
cin >> t >> n >> m;
cin >> s;
int saida = 0;
for (int i = t - 1; i >= 0; i--, m--, n--) {
if (m > 0 && s[i] == '1') {
s[i] = '0';
saida++;
} else if (m == 0) {
if (s[i] == '0') {
s[i] = '1';
saida++;
}
} else if (m < 0 && n > 0 && s[i] == '1') {
s[i] = '0';
saida++;
}
}
cout << saida << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, cnt = 0;
cin >> n >> x >> y;
string s;
cin >> s;
n = s.size();
int p = n - 1 - y;
for (int i = n - 1; i >= n - x; i--) {
if (i == p) {
if (s[i] == '0') {
s[i] = '1';
cnt++;
}
} else {
if (s[i] == '1') {
s[i] = '0';
cnt++;
}
}
}
cout << cnt << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = -1u >> 1;
const int maxn = 2e5 + 5;
char s[maxn];
int main() {
int n, x, y, ans = 0;
scanf("%d%d%d", &n, &y, &x);
scanf("%s", s + 1);
for (int i = n - y + 1; i <= n - x - 1; i++) {
if (s[i] - '0' == 1) ans++;
}
if (s[n - x] - '0' == 0) ans++;
for (int i = n - x + 1; i <= n; i++) {
if (s[i] - '0' == 1) ans++;
}
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
const int max_n = 200005;
int n, x, y;
char s[max_n];
int main() {
scanf("%d%d%d", &n, &x, &y);
scanf(" %s", s + 1);
int ans = 0;
for (int i = n; i >= n - (x - 1); i--) {
if (i == n - y) {
if (s[i] == '0') ans++;
} else if (s[i] == '1')
ans++;
}
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
long long ans = 0;
if (s[y] == '0') {
ans++;
}
for (int i = 0; i < x; i++) {
if (i == y) {
continue;
}
if (s[i] == '1') {
ans++;
}
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, y, t = 0, i, u = 0;
char a[1000009];
cin >> n >> x >> y;
cin >> a;
for (i = n - 1 - x + 1; i <= n - 1 - y - 1; i++) {
if (a[i] == '1') t++;
}
if (a[n - 1 - y] == '0') t++;
for (i = n - 1 - y + 1; i <= n - 1; i++)
if (a[i] == '1') t++;
cout << t << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, x, y, db;
string s;
int main() {
cin >> n >> x >> y;
cin >> s;
db = 0;
for (int i = n - x; i < n - y - 1; i++) {
if (s[i] == '1') db++;
}
if (s[n - y - 1] == '0') db++;
for (int i = n - y; i < n; i++) {
if (s[i] == '1') db++;
}
cout << db << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, x, y;
string num;
cin >> n >> x >> y;
cin >> num;
string s;
int j = 1;
int res = 0;
for (int i = (n - x); i < n; i++) {
if (j == (x - y)) {
if (num[i] != '1') {
res++;
}
} else {
if (num[i] != '0') {
res++;
}
}
j++;
}
cout << res;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <typename T>
struct Matrix {
ll H, W;
vector<vector<T>> data;
pi shape;
Matrix(ll H, ll W) : H(H), W(W), data(H, vector<T>(W)), shape({H, W}) {}
void fill(T x) {
for (ll i = 0; (i) < (ll)(H); ++(i)) {
for (ll j = 0; (j) < (ll)(W); ++(j)) data[i][j] = x;
}
}
vector<T>& operator[](ll i) { return data[i]; }
bool operator==(Matrix<T>& other) {
if (H != other.H || W != other.W) return false;
for (ll i = 0; (i) < (ll)(H); ++(i))
for (ll j = 0; (j) < (ll)(W); ++(j)) {
if (data[i][j] != other[i][j]) return false;
}
return true;
}
Matrix rot() {
auto B = Matrix(W, H);
for (ll i = 0; (i) < (ll)(W); ++(i)) {
for (ll j = 0; (j) < (ll)(H); ++(j)) {
B[i][j] = (*this)[j][W - 1 - i];
}
}
return B;
}
};
ll in() {
ll i;
cin >> i;
return i;
}
pi in2() {
ll a, b;
cin >> a >> b;
return {a, b};
}
tuple<ll, ll, ll> in3() {
ll a, b, c;
cin >> a >> b >> c;
return {a, b, c};
}
tuple<ll, ll, ll, ll> in4() {
ll a, b, c, d;
cin >> a >> b >> c >> d;
return {a, b, c, d};
}
vi vin(ll n) {
vi A(n);
for (auto&& x : A) {
cin >> x;
}
return A;
}
string sin() {
string s;
cin >> s;
return s;
}
Matrix<ll> matrixin(ll H, ll W) {
Matrix<ll> A(H, W);
for (ll i = 0; (i) < (ll)(H); ++(i)) {
for (ll j = 0; (j) < (ll)(W); ++(j)) {
A[i][j] = in();
}
}
return A;
}
Matrix<char> cmatrixin(ll H, ll W) {
Matrix<char> A(H, W);
for (ll i = 0; (i) < (ll)(H); ++(i)) {
string S = sin();
for (ll j = 0; (j) < (ll)(W); ++(j)) {
A[i][j] = S[j];
}
}
return A;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& A) {
os << A.first << " " << A.second;
return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& A) {
for (size_t i = 0; i < A.size(); i++) {
if (i) os << " ";
os << A[i];
}
return os;
}
void print() { cout << "\n"; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
cout << head;
if (sizeof...(Tail)) cout << " ";
print(forward<Tail>(tail)...);
}
void YES() { print("YES"); }
void NO() { print("NO"); }
void Yes() { print("Yes"); }
void No() { print("No"); }
template <typename T>
ll sum(T A) {
return accumulate(A.begin(), A.end(), 0);
}
template <typename T>
vector<T> cumsum(vector<T> A) {
ll N = A.size();
vector<T> B(N + 1);
B[0] = T(0);
for (ll i = 0; (i) < (ll)(N); ++(i)) {
B[i + 1] = B[i] + A[i];
}
return B;
}
vi bin_count(vi& A, ll size) {
vi C(size);
for (auto&& x : A) {
++C[x];
}
return C;
}
template <typename T>
ll argmax(vector<T>& A) {
return max_element(A.begin(), A.end()) - A.begin();
}
template <typename T>
ostream& operator<<(ostream& os, Matrix<T>& A) {
for (ll i = 0; (i) < (ll)(A.H); ++(i)) {
if (i) os << "\n";
os << A[i];
}
return os;
}
template <class T, class U>
bool chmax(T& a, const U& b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class U>
bool chmin(T& a, const U& b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
signed main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << setprecision(15);
auto [N, x, y] = in3();
string S = sin();
reverse(S.begin(), S.end());
S.resize(x);
auto ans = 0;
for (ll i = 0; (i) < (ll)(x); ++(i)) {
if (i == y) continue;
ans += S[i] == '1';
}
ans += S[y] == '0';
print(ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1000;
const long long INF64 = 1e18 + 1000;
const int N = 6 * 100 * 1000 + 100;
const int MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int ans = 0;
for (int i = int(n - x); i < int(n); ++i) {
if (i == (n - y - 1) && s[i] == '0')
ans++;
else if (s[i] == '1' && i != (n - y - 1))
ans++;
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < x; i++) {
int pos = n - i - 1;
char current = '0';
if (i == y) {
current = '1';
}
if (current != s[pos]) {
ans++;
}
}
cout << ans << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, x, y;
string s;
cin >> n >> x >> y >> s;
int ans = 0;
for (int i = n - x; i < n; i++) {
if (i == n - y - 1)
ans += s[i] != '1';
else
ans += s[i] != '0';
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int Int() {
int x;
scanf("%d", &x);
return x;
}
long long Long() {
long long x;
scanf("%lld", &x);
return x;
}
void err(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ' ';
err(++it, args...);
}
const int N = (int)2e5 + 5;
const int maxN = (int)1e6 + 6;
const long long Mod = (long long)1e9 + 7;
const int inf = (int)2e9;
const long long Inf = (long long)1e18;
int main() {
int test = 1, tc = 0;
while (test--) {
int n = Int(), x = Int(), y = Int(), res = 0;
string s;
cin >> s;
reverse(s.begin(), s.end());
for (int i = 0; i < x; ++i) {
if (i == y) {
if (s[i] == '0') ++res;
} else if (s[i] == '1')
++res;
}
cout << res << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
char num[MAXN];
int main() {
int n, x, y;
scanf("%d %d %d", &n, &x, &y);
for (int i = n - 1; i >= 0; i--) {
scanf(" %c", &num[i]);
}
int co = 0;
for (int i = x - 1; i >= 0; i--) {
if (i == y) {
if (num[i] == '0') {
co++;
}
} else {
if (num[i] == '1') {
co++;
}
}
}
printf("%d", co);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string st;
cin >> st;
int cnt = 0;
int ans = n - y - 1;
for (int i = n - x; i < st.length(); i++) {
if (i == ans && st[i] == '0') {
st[i] = '1';
cnt++;
} else if (st[i] == '1' && i != ans) {
st[i] = '0';
cnt++;
}
}
cout << cnt << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 100;
const int md = 1000000007;
priority_queue<pair<int, int>, vector<pair<int, int> >,
greater<pair<int, int> > >
pq;
bool compare(const pair<int, int>& a, const pair<int, int>& b) {
if (a.second == b.second) return a.first > b.first;
return a.second > b.second;
}
int main() {
int n, x, y, ans = 0;
string s;
scanf("%d %d %d", &n, &x, &y);
cin >> s;
for (int i = n - y; i < n; i += 1) {
if (s[i] == '1') {
ans++;
s[i] = '0';
}
}
if (s[n - y - 1] == '0') {
ans++;
s[n - y - 1] = '1';
}
for (int i = n - x; i < n - y - 1; i += 1) {
if (s[i] == '1') {
ans++;
s[i] = '0';
}
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
inline long long input() {
long long n;
cin >> n;
return n;
}
long long pw(long long a, long long b) {
return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2)));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int n, a, b;
cin >> n >> a >> b;
string s;
cin >> s;
int cnt = 0;
for (int i = n - a; i < n; i++) {
if (s[i] == '1') {
cnt++;
}
}
if (s[n - b - 1] == '1') {
cnt--;
} else {
cnt++;
}
cout << cnt;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T load() {
T r;
cin >> r;
return r;
}
template <typename T>
vector<T> loadMany(int n) {
vector<T> rs(n);
generate(rs.begin(), rs.end(), &load<T>);
return rs;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto n = load<int>();
auto x = load<int>();
auto y = load<int>();
auto s = load<string>();
reverse(s.begin(), s.end());
auto ops = 0;
for (auto i = 0; i < x; ++i)
if (s[i] != (i != y ? '0' : '1')) ++ops;
cout << ops << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
long long int a, b, c, i, s, j, k, ck, m, n, ar[100005], br[100005], fr[100005];
int main() {
string str;
cin >> a >> b >> c >> str;
reverse(str.begin(), str.end());
for (i = 0; i < b; i++) {
if ((str[i] == '1') ^ (i == c)) {
s++;
}
}
cout << s << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
vector<long long> prefs(n);
vector<bool> ready(n);
for (long long i = n - 1; i > -1; --i) {
long long k = n - 1 - i;
if (k)
prefs[k] = prefs[k - 1] + (s[i] - '0');
else
prefs[k] = s[i] - '0';
ready[k] = s[i] - '0';
}
if (ready[y])
cout << prefs[x - 1] - 1;
else
cout << prefs[x - 1] + 1;
}
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, x, y, ans = 0;
string s;
cin >> n >> x >> y;
cin >> s;
if (s[n - y - 1] != '1') {
++ans;
}
s[n - y - 1] = '0';
for (int d = n - x; d < n; ++d) {
if (s[d] == '1') {
++ans;
s[d] = '0';
}
}
cout << ans << "\n";
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
template <class T, class U>
inline void checkmin(T &x, U y) {
if (y < x) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
if (y > x) x = y;
}
template <class T, class U>
inline bool ifmax(T &x, U y) {
if (y > x) return x = y, true;
return false;
}
template <class T, class U>
inline bool ifmin(T &x, U y) {
if (y < x) return x = y, true;
return false;
}
template <class T>
inline void sort(T &a) {
sort(a.begin(), a.end());
}
template <class T>
inline void rsort(T &a) {
sort(a.rbegin(), a.rend());
}
template <class T>
inline void reverse(T &a) {
reverse(a.begin(), a.end());
}
template <class T, class U>
inline istream &operator>>(istream &str, pair<T, U> &p) {
return str >> p.first >> p.second;
}
template <class T>
inline istream &operator>>(istream &str, vector<T> &a) {
for (auto &i : a) str >> i;
return str;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cout << fixed << setprecision(12);
;
srand(94385);
int n, x, y;
cin >> n >> y >> x;
string second;
cin >> second;
x = n - x - 1;
y = n - y - 1;
int ans = 0;
for (int i = 0; i < n; ++i) {
if (i > y) ans += (second[i] == '1') ^ (i == x);
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long x, y, n;
cin >> n >> x >> y;
long long a[n + 5], i, c = 0;
string s;
cin >> s;
for (i = n - 1; i > (n - x - 1); i--) {
if (s[i] == '1') {
c++;
}
}
if (s[n - y - 1] == '0') {
c++;
} else {
c = c - 1;
}
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char str[300000], str2[300000];
int main() {
int n, x, y;
scanf("%d%d%d", &n, &x, &y);
scanf("%s", str);
int len = strlen(str);
strcpy(str2, str);
int count_ = 0;
for (int i = len - 1; i >= len - y; i--) {
if (str2[i] != '0') count_++;
}
if (str2[len - y - 1] != '1') count_++;
for (int i = len - x; i < len - y - 1; i++) {
if (str[i] != '0') count_++;
}
printf("%d\n", count_);
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, x, y, c = 0;
scanf("%d %d %d", &n, &x, &y);
char s[n + 1];
scanf("%s", s);
int i;
for (i = n - x; i < n; i++) {
if (i == n - y - 1) {
if (s[i] != '1') c++;
} else {
if (s[i] != '0') c++;
}
}
printf("%d\n", c);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[3000000];
void solve() {
long long n = 0, x = 0, y = 0;
cin >> n >> x >> y;
cin >> a + 1;
long long c = 0;
for (long long i = n - x + 1; i <= n; i++) {
if (i == n - y && a[i] != '1') {
c++;
}
if (i != n - y && a[i] != '0') {
c++;
}
}
cout << c << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
|
#include <bits/stdc++.h>
const int N = 2e5 + 7;
using namespace std;
char s[N];
int x, y;
int main() {
int ans = 0;
int len;
scanf("%d", &len);
scanf("%d%d", &x, &y);
getchar();
for (int i = 1; i <= len; i++) {
scanf("%c", &s[i]);
}
for (int i = len; i > len - x; i--) {
if (s[i] == '1') {
ans++;
}
}
if (s[len - y] == '1') {
ans--;
}
if (s[len - y] == '0') {
ans++;
}
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, y, cnt = 0;
cin >> n >> x >> y;
string s;
cin >> s;
for (int i = n - 1; x; i--) {
if (i == (n - y - 1) && s[i] == '0')
cnt++;
else if (i == (n - y - 1) && s[i] == '1') {
} else if (s[i] == '1')
cnt++;
x--;
}
cout << cnt;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, cnt = 0, i;
cin >> n >> x >> y;
string s;
cin >> s;
for (i = n - 1; i >= 0; i--) {
if (s[i] == '1') cnt++;
x--;
if (x == 0) break;
}
if (s[n - y - 1] == '0')
cnt++;
else
cnt--;
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[200000];
int main() {
int x, n, m;
cin >> x >> n >> m;
getchar();
for (int i = x - 1; i >= 0; i--) cin >> a[i];
int k = 0;
if (a[m] == '1') {
k = -1;
} else
k++;
for (int i = 0; i < n; i++)
if (a[i] == '1') k++;
cout << k << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, l;
cin >> n >> l >> m;
string s;
cin >> s;
long long ans = 0;
if (s[n - m - 1] == '0') ans++;
for (long long i = n - m; i < n; i++) {
if (s[i] == '1') ans++;
}
long long x = n - m - 1;
for (long long i = n - l; i < x; i++) {
if (s[i] == '1') ans++;
}
cout << ans << endl;
return 0;
;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e+9) + 7;
const long long size = 2e5 + 9;
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long power(long long a, long long b, long long m = mod) {
long long res = 1;
while (b > 0) {
if (b & 1) res = (res * a) % m;
b = b >> 1;
a = (a * a) % m;
}
return res;
}
void solve() {
long long n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
long long cc = 0;
reverse(s.begin(), s.end());
long long ans = 0;
for (long long i = 0; i < n; i++) {
if (i + 1 > x) break;
if (i + 1 <= y) {
if (s[i] != '0') ans++;
}
if (i + 1 == y + 1) {
if (s[i] != '1') ans++;
}
if (i + 1 > y + 1) {
if (s[i] != '0') ans++;
}
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
clock_t beg = clock();
solve();
clock_t end = clock();
fprintf(stderr, "%.3f sec, Copyright %c 2019 Skyscraper. \n",
double(end - beg) / CLOCKS_PER_SEC, 184);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
string s;
cin >> n >> x >> y;
getline(cin >> ws, s);
int cnt = 0;
for (int i = 0; i < x; i++)
if (i != y && s[n - 1 - i] == '1')
cnt++;
else if (i == y && s[n - 1 - i] == '0')
cnt++;
cout << cnt << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
long long int n, x, y;
cin >> n >> x >> y;
string str;
cin >> str;
long long int last = n - 1;
long long int move = 0;
long long int count = 0;
for (last = n - 1; move < x; last--) {
if (move != y && str[last] == '1') {
count++;
} else if (move == y && str[last] == '0') {
count++;
}
move++;
}
cout << count << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
void solve() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
int ans = 0;
for (int i = 0; i < x; ++i) {
if (i == y and s[i] == '0')
++ans;
else if (i != y and s[i] == '1')
++ans;
}
cout << ans;
}
void InputSetup() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int main(void) {
auto start = chrono::high_resolution_clock::now();
InputSetup();
solve();
auto finish = chrono::high_resolution_clock::now();
cerr << "Time elapsed: "
<< (chrono::duration<long double>(finish - start)).count() << "s\n";
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T load() {
T r;
cin >> r;
return r;
}
template <typename T>
vector<T> loadMany(int n) {
vector<T> rs(n);
generate(rs.begin(), rs.end(), &load<T>);
return rs;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto n = load<int>();
auto x = load<int>();
auto y = load<int>();
auto s = load<string>();
reverse(s.begin(), s.end());
auto ops = 0;
for (auto i = 0; i < x; ++i)
if (s[i] != (i == y ? '1' : '0')) ++ops;
cout << ops << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, x, y, count = 0;
string s;
cin >> n >> x >> y >> s;
for (auto i = 0; i < x; i++) {
if (i < y) {
count += s[n - 1 - i] == '1';
} else if (i == y) {
count += s[n - 1 - i] == '0';
} else {
count += s[n - 1 - i] == '1';
}
}
cout << count << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, n, i, k, y, siz;
string s;
cin >> n >> x >> y;
cin >> s;
siz = s.size();
s.erase(0, siz - x);
k = 0;
siz = s.size();
for (i = 0; i < siz; i++) {
if (s[i] == '1' && i != siz - y - 1) {
s[i] = '0';
k++;
}
}
if (s[siz - y - 1] == '0') k++;
cout << k;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char a[200005];
int n, x, y;
cin >> n >> x >> y;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int count = 0;
for (int i = n; i >= n - y + 1; i--) {
if (a[i] == '1') count++;
}
if (a[n - y] == '0') count++;
for (int i = n - y - 1; i >= n - x + 1; i--) {
if (a[i] == '1') count++;
}
cout << count;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[300005];
char b[300005];
int main() {
int n, m, k;
while (~scanf("%d %d %d", &n, &m, &k)) {
scanf("%s", a);
int ans = 0;
int kk = 0;
for (int i = 0; i < m + 1; i++) {
b[i] = a[n - i - 1];
}
if (b[k] == '0') ans++;
for (int i = 0; i < m + 1; i++) {
if (i != m && i != k) {
if (b[i] == '1') ans++;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int ans = 0;
for (int i = n - x; i < n; ++i) {
if (i == n - y - 1)
ans += s[i] != '1';
else
ans += s[i] != '0';
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
char c;
int n, x, y, i, o;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for (cin >> n >> x >> y; i++ < n;) {
cin >> c;
if (i > n - x) {
o += i == n - y ? c == '0' : c == '1';
}
}
cout << (o) << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long setbit(long long num, int idx, int val = 1) {
return (val) ? (num | (1 << idx)) : (num & ~(1 << idx));
}
long long getbit(long long num, int idx) { return ((num >> idx) & 1) == 1; }
int contbit(int num) {
int ret = 0;
while (num) {
if (num % 2) ret++;
num /= 2;
}
return ret;
}
int dx[] = {-1, 0, 0, 1, 1, 1, -1, -1};
int dy[] = {0, 1, -1, 0, 1, -1, 1, -1};
int main() {
file();
fast();
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
int sum = 0;
for (int i = 0; i < x; i++) {
if (i == y) {
sum += s[i] != '1';
} else
sum += s[i] == '1';
}
cout << sum;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 500005;
int a[MAX];
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int ans = 0;
for (int i = n - x; i < n; i++) {
if (i > n - y - 1) {
if (s[i] == '1') {
ans++;
}
} else {
if (i == n - y - 1) {
if (s[i] == '0') {
ans++;
}
} else {
if (s[i] == '1') {
ans++;
}
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[200005];
int main() {
int n, x, y, ans = 0;
scanf("%d%d%d", &n, &x, &y);
scanf("%s", s + 1);
for (int i = n; i >= n - y + 1; i--) {
if (s[i] == '1') ans++;
}
if (s[n - y] == '0') ans++;
for (int i = n - y - 1; i >= n - x + 1; i--) {
if (s[i] == '1') ans++;
}
cout << ans << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
int mark1[1000000];
int mark[1000000];
int main() {
string s;
long long i, n, m, l, c = 0, x;
cin >> l >> n >> m >> s;
x = l - m - 1;
for (i = l - n; i < l; i++) {
if (i == x) {
if (s[i] == '0') c++;
} else if (s[i] == '1')
c++;
}
cout << c << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
const int mod = 1e9 + 7, num = 1e5 + 1;
inline long long int add(long long int x, long long int y) {
x += y;
if (x >= mod) x -= mod;
return x;
}
inline long long int sub(long long int x, long long int y) {
x -= y;
if (x < 0) x += mod;
return x;
}
inline long long int mul(long long int x, long long int y) {
return (x * 1ll * y) % mod;
}
bool comp(string s1, string s2) { return s1.size() < s2.size(); }
void solve(int io) {
long long int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
long long int cnt = 0, ans = 0;
y = n - y - 1;
x = n - x;
for (long long int i = n - 1; i >= x; i--) {
if (s[i] == '1' && i != y) {
ans++;
}
if (i == y && s[i] == '0') {
ans++;
}
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
using namespace std::chrono;
auto startTime = high_resolution_clock::now();
long long int test = 1;
for (long long int i = 0; i < test; i++) {
solve(i + 1);
}
auto endTime = high_resolution_clock::now();
auto duration = duration_cast<seconds>(endTime - startTime);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long tests = 1;
while (tests--) {
long long n, x, y, cnt = 0, ans = 0;
string s;
cin >> n >> x >> y >> s;
reverse((s).begin(), (s).end());
if (s[y] == '0') ans++;
long long i = 0;
while (i < x) {
if (i != y && s[i] != '0') cnt++;
i++;
}
cout << cnt + ans;
}
return 0;
}
|
#include <bits/stdc++.h>
char s[200005];
int main() {
int n, x, y;
scanf("%d%d%d", &n, &x, &y);
scanf("%s", s);
auto ans = 0;
for (auto i = 1; i <= x; ++i) {
if (i == y + 1) {
ans += (int)(s[n - i] != '1');
} else {
ans += (int)(s[n - i] != '0');
}
}
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio();
cin.tie(0);
cout.tie(0);
int n, x, y, ans = 0;
cin >> n >> x >> y;
string ar;
cin >> ar;
reverse(ar.begin(), ar.end());
for (int i = 0; i < x; i++) {
if (i == x && ar[i] == '0')
ans++;
else if (i == y && ar[i] == '0')
ans++;
else if (i == y)
;
else if (i == x)
;
else if (ar[i] == '1')
ans++;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, x, y, i, j, a = 0;
string s;
cin >> n >> x >> y >> s;
for (i = 0; i < x; i++) {
if (i == y) {
if (s[n - 1 - i] == '0') {
a++;
}
} else {
if (s[n - 1 - i] == '1') {
a++;
}
}
}
cout << a;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
int op = 0;
for (int i = 0; i < x; i++) {
if (i == y) {
if (s[n - 1 - i] == '0') {
op++;
}
} else {
if (s[n - 1 - i] == '1') {
op++;
}
}
}
cout << op;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b);
unsigned long long int gcd(unsigned long long int a, unsigned long long int b);
int prime(long long int n);
long long int power(long long int x, long long int y);
long long int nCr(long long int n, long long int r, long long int p);
long long int sum(long long int n) { return (n * (n + 1)) / 2; }
void solve() {
long long int n, x, y, ans = 0;
cin >> n >> x >> y;
string a;
cin >> a;
for (int i = n - x; i < n - y - 1; i++) {
ans += a[i] - '0';
}
if (a[n - y - 1] == '0') ans++;
for (int i = n - y; i < n; i++) {
ans += a[i] - '0';
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t = 1, p = 0;
while (t-- && ++p) {
solve();
}
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
unsigned long long int gcd(unsigned long long int a, unsigned long long int b) {
if (a == 1 || b == 1) return 1;
if (b == 0) return a;
return gcd(b, a % b);
}
int prime(long long int n) {
int flag = 1;
for (long long int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
flag = 0;
break;
}
}
return flag;
}
long long int power(long long int x, long long int y) {
long long int temp;
if (y == 0) return 1;
temp = power(x, y / 2) % 1000000007;
if (y % 2 == 0)
return (temp * temp) % 1000000007;
else
return (((x * temp) % 1000000007) * temp) % 1000000007;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
int cnt = 0;
for (int i = 0; i < y; i++) {
cnt += (s[i] == '1');
}
cnt += (s[y] == '0');
for (int i = y + 1; i < x; i++) {
cnt += (s[i] == '1');
}
cout << cnt;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, op = 0;
cin >> n >> x >> y;
string s;
cin >> s;
if (s[n - y - 1] == '0') op++;
for (int i = n - y; i < n; i++) {
if (s[i] == '1') op++;
}
for (int i = n - x; i < n - y - 1; i++)
if (s[i] == '1') op++;
cout << op << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const char EOT = '\n';
const long long INF = (long long)(1e9) * (1024);
const int nmax = (int)(2e3) + 50;
const long long maxn = (long long)(1e5) + 7;
const long long mix = (long long)(1e9) * (-1) - 5;
const long long man = (long long)(1e9) + 5;
const long double pi = 3.1415926535897932384626433832795028841971;
void tipafast() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
long long n, x, y, ans = 0;
string s;
int main() {
cin >> n >> x >> y >> s;
reverse(s.begin(), s.end());
for (int i = 0; i < x; i++) {
if (y == i) {
if (s[i] == '0') ans++;
} else {
if (s[i] == '1') ans++;
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, y;
string second;
cin >> n >> x >> y >> second;
int ans = 0;
for (int i = n - x; i < n; ++i) {
if (i == n - y - 1)
ans += (second[i] != '1');
else
ans += second[i] != '0';
}
cout << ans << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string s;
cin >> s;
string res = "";
for (int i = 1; i <= y; i++) res = '0' + res;
res = '1' + res;
for (int i = res.length() + 1; i <= x; i++) res = '0' + res;
if (y == 0) {
res = "";
for (int i = 1; i < x; i++) res += '0';
res += '1';
}
int ans = 0;
for (int i = s.length() - 1, k = x - 1; k >= 0; i--, k--) {
if (s[i] != res[k]) ans++;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
double tick() {
static clock_t oldt, newt = clock();
double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
oldt = newt;
return diff;
}
template <typename T>
T gcd(T a, T b) {
return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
return (a * b) / gcd(a, b);
}
template <typename T>
T power(T e, T n, T m) {
T x = 1, p = e;
while (n) {
if (n & 1) x = mul(x, p, m);
p = mul(p, p, m);
n >>= 1;
}
return x;
}
int mod_neg(int a, int b, int c) {
int res;
if (abs(a - b) < c)
res = a - b;
else
res = (a - b) % c;
return (res < 0 ? res + c : res);
}
template <typename T>
T extended_euclid(T a, T b, T &x, T &y) {
T xx = 0, yy = 1;
y = 0;
x = 1;
while (b) {
T q = a / b, t = b;
b = a % b;
a = t;
t = xx;
xx = x - q * xx;
x = t;
t = yy;
yy = y - q * yy;
y = t;
}
return a;
}
template <typename T>
T mod_inverse(T a, T n) {
T x, y, z = 0;
T d = extended_euclid(a, n, x, y);
return (d > 1 ? -1 : mod_neg(x, z, n));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int x, y;
cin >> x >> y;
string s;
cin >> s;
reverse((s).begin(), (s).end());
long long int ans = 0;
for (int i = 0; i < (x); ++i) {
if (i == y) {
if (s[i] != '1') {
ans++;
}
} else {
if (s[i] != '0') {
ans++;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char s[maxn];
int main() {
int n, a, b, ans = 0;
scanf("%d%d%d", &n, &a, &b);
getchar();
scanf("%s", s + 1);
for (int i = n; i > n - a; i--) {
if (s[i] != '0' && i != n - b) ans++;
}
if (s[n - b] != '1') ans++;
printf("%d", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int N = 1000005;
const long long int LG = 22;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int n, x, y;
cin >> n >> x >> y;
string s;
long long int ans = 0;
cin >> s;
reverse(s.begin(), s.end());
for (long long int i = 0; i <= x - 1; i++) {
if (s[i] == '1' && i != y) ans++;
if (i == y && s[i] != '1') ans++;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
os << "{";
for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
return os << "}";
}
[[maybe_unused]] constexpr ll MOD = 998244353;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;
int main() {
int n, x, y;
cin >> n >> y >> x;
string s;
cin >> s;
reverse(s.begin(), s.end());
int ans = 0;
for (int i = 0; i < x; ++i) ans += s[i] == '1';
ans += s[x] == '0';
for (int i = x + 1; i < y; ++i) ans += s[i] == '1';
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, y;
string s;
cin >> n >> x >> y >> s;
int ans = 0;
for (int i = n - x; i < n; ++i) {
if (i == n - y - 1)
ans += s[i] != '1';
else
ans += s[i] != '0';
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
vector<bool> a;
int main() {
ios_base::sync_with_stdio(0);
int N, x, y;
cin >> N >> x >> y;
for (int i = 0; i < N; i++) {
char o;
cin >> o;
a.push_back(o - '0');
}
int tot = 0;
reverse(a.begin(), a.end());
for (int i = 0; i < x; i++) {
if (i != y && a[i] == 1) tot++;
if (i == y && a[i] == 0) tot++;
}
cout << tot;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, sum = 0;
string s;
cin >> n >> x >> y;
cin >> s;
for (int i = n - x; i < n - y - 1; i++) {
if (s[i] == '1') {
sum++;
s[i] = '0';
}
}
if (s[n - y - 1] == '0') {
sum++;
s[n - y - 1] = '1';
}
for (int i = n - y; i < n; i++) {
if (s[i] == '1') {
sum++;
s[i] = '0';
}
}
cout << sum << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int p, q;
string s;
cin >> n >> p >> q >> s;
int index = 0;
for (int i = 0; i < p; i++) {
if (s[n - 1 - i] == '1' && i != q) {
index++;
}
if (i == q && s[n - 1 - i] == '0') {
index++;
}
}
cout << index;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, x, y;
cin >> n >> x >> y;
string second;
cin >> second;
int brojac = 0;
for (int i = n - x; i < n; i++) {
if (i == n - y - 1)
brojac += (second[i] == '0');
else
brojac += (second[i] == '1');
}
cout << brojac;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
while (tt--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, l, mx = 0, sum = 0, tired, x, y, ans = 0;
cin >> n >> x >> y;
string s;
cin >> s;
reverse(s.begin(), s.end());
for (int i = 0; i < x; i++) {
if (i == y) {
if (s[i] == '0') {
ans++;
}
} else if (s[i] == '1') {
ans++;
}
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y;
cin >> n >> x >> y;
string a;
cin >> a;
int count = 0;
for (int i = n - 1; i > n - x - 1; i--) {
if (a[i] == '1' && i != (n - y - 1)) {
a[i] == '0';
count++;
}
if (i == n - y - 1 && a[i] == '0') {
a[i] = '1';
count++;
}
}
cout << count;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.