#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
voidsol(){ string s; cin >> s; int n = s.size(); if (s[0] == '0') { cout << "0\n"; return; } int ans; if (s[0] == '?') { ans = 9; for (int i = 1; i < n; i++) { if (s[i] == '?') ans *= 10; } } else { ans = 1; for (int i = 0; i < n; i++) { if (s[i] == '?') ans *= 10; } } cout << ans << "\n"; }
#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
voidsol(){ int n; cin >> n; vector<int> a(n), b(n); for (auto& i : a) cin >> i; for (auto& i : b) cin >> i; if (a == b) { cout << "1 " << n << "\n"; return; } int l = 0, r = n - 1; while (a[l] == b[l]) l++; while (a[r] == b[r]) r--; while (l > 0 && b[l - 1] <= b[l]) l--; while (r < n - 1 && b[r] <= b[r + 1]) r++; cout << l + 1 << " " << r + 1 << "\n"; }
#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
voidsol(){ string s; cin >> s; int n = s.size(); int ans = n; for (char i = 'a'; i <= 'z'; i++) { int mx = 0; for (int j = 0; j < n;) { int p = j; while (p < n && s[p] != i) p++; mx = max(mx, p - j); j = p + 1; } int tans = 0; while (mx) { mx /= 2; tans++; } ans = min(ans, tans); } cout << ans << "\n"; }
#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
voidsol(){ ll n, k; cin >> n >> k; vector<ll> L(n), R(n); for (ll& i : L) cin >> i; for (ll& i : R) cin >> i; ll s = 0, c = 0, ans = 2e9 + 7; for (int i = 0; i < n; i++) { if (R[i] - L[i] == 0) c++; else s += R[i] - L[i] + 1; if (s >= k) { ans = min(ans, R[i] - (s - k) + 2 * (i + 1 - c)); } elseif (s + c >= k) { ans = min(ans, R[i] + 2 * (i + 1 - c + k - s)); } } if (ans == 2e9 + 7) { cout << "-1\n"; } else { cout << ans << "\n"; } }