problem_id stringlengths 6 6 | language stringclasses 2 values | original_status stringclasses 3 values | original_src stringlengths 19 243k | changed_src stringlengths 19 243k | change stringclasses 3 values | i1 int64 0 8.44k | i2 int64 0 8.44k | j1 int64 0 8.44k | j2 int64 0 8.44k | error stringclasses 270 values | stderr stringlengths 0 226k |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02893 | Python | Time Limit Exceeded | n = int(input())
a = input()
inva = "".join(map(lambda x: str(int(x) ^ 1), a))
mod = 998244353
ans = 0
p = 1
num = [0] * -~n
for i in range(n):
if i:
num[i] += (num[i - 1] * 2) % mod
if a[i] == "1":
num[i] += 1
def get_div(x):
y = []
for i in range(1, n):
if x % i == 0 and (x // i) % 2:
y.append(i)
return y
div = get_div(n)
d = [0] * -~n
tot = 0
for i in div:
now = n // i
tt = num[i - 1]
for j in get_div(i):
tt -= d[j]
k = (a[:i] + inva[:i]) * (n // (2 * i)) + a[:i]
d[i] = tt + (int(a, 2) >= int(k, 2))
tot += d[i]
d[n] = int(a, 2) + 1 - tot
for i in range(n + 1):
ans = (ans + d[i] * i * 2) % mod
print(ans % mod)
| n = int(input())
a = input()
inva = "".join(map(lambda x: str(int(x) ^ 1), a))
mod = 998244353
ans = 0
p = 1
num = [0] * -~n
for i in range(n):
if i:
num[i] += (num[i - 1] * 2) % mod
if a[i] == "1":
num[i] += 1
def get_div(x):
y = []
for i in range(1, n):
if x % i == 0 and (x // i) % 2:
y.append(i)
return y
div = get_div(n)
d = [0] * -~n
tot = 0
for i in div:
now = n // i
tt = num[i - 1]
for j in get_div(i):
tt -= d[j]
k = (a[:i] + inva[:i]) * (n // (2 * i)) + a[:i]
d[i] = tt + (a >= k)
tot += d[i]
d[n] = int(a, 2) + 1 - tot
for i in range(n + 1):
ans = (ans + d[i] * i * 2) % mod
print(ans % mod)
| replace | 32 | 33 | 32 | 33 | TLE | |
p02893 | C++ | Runtime Error | /* cerberus97 - Hanit Banga */
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define pb push_back
#define fast_cin() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 2e5 + 10, mod = 998244353;
vector<pii> g[N];
int color[N];
ll cnt[N], p2[N];
ll solve(int d, int n, string x);
bool assign(int u, int col);
int main() {
// int n = 6;
// for (int i = 0; i < (1 << n); ++i) {
// int cpy = i, steps = 0;
// while (true) {
// if (cpy % 2 == 0) {
// cpy = (cpy / 2) + (1 << (n - 1));
// } else {
// cpy = (cpy - 1) / 2;
// }
// ++steps;
// if (cpy == i) {
// break;
// }
// }
// cout << i << ' ' << steps << endl;
// }
// return 0;
fast_cin();
int n;
cin >> n;
string x;
cin >> x;
// reverse(x.begin(), x.end());
vector<int> divisors;
int sq = sqrt(2 * n);
for (int i = 1; i <= sq; ++i) {
if ((2 * n) % i == 0) {
divisors.pb(i);
if (i * i != 2 * n) {
divisors.pb((2 * n) / i);
}
}
}
p2[0] = 1;
for (int i = 1; i < N; ++i) {
p2[i] = (2 * p2[i - 1]) % mod;
}
sort(divisors.begin(), divisors.end());
ll ans = 0;
for (auto &d : divisors) {
cnt[d] += solve(d, n, x);
cnt[d] %= mod;
// cout << d << ' ' << cnt[d] << endl;
for (int i = 2 * d; i <= 2 * n; i += d) {
cnt[i] += (mod - cnt[d]);
cnt[i] %= mod;
}
ans += d * cnt[d];
ans %= mod;
}
cout << ans << endl;
}
ll solve(int d, int n, string x) {
for (int i = 0; i < n; ++i) {
g[i].clear();
}
for (int i = 0; i < n; ++i) {
if (i + d < n) {
g[i].pb({i + d, 0});
g[i + d].pb({i, 0});
} else if (d != 2 * n) {
g[i].pb({(i + d) % n, 1});
g[(i + d) % n].pb({i, 1});
} else {
// g[i].pb({(i + d) % n, 0});
// g[(i + d) % n].pb({i, 0});
}
}
memset(color, -1, sizeof(color));
ll components = 0;
for (int i = 0; i < n; ++i) {
if (color[i] == -1) {
if (!assign(i, 0)) {
return 0;
}
++components;
}
}
memset(color, -1, sizeof(color));
// cout << "comp " << d << ' ' << components << endl;
ll ans = 0, left = components;
for (int i = 0; i < n; ++i) {
// if (d == 2 * n) {
// cout << i << ' ' << x[i] << ' ' << color[i] << ' ' << left << endl;
// }
if (x[i] == '0') {
if (color[i] == 1) {
break;
} else if (color[i] == -1) {
assign(i, 0);
--left;
}
} else {
if (color[i] == -1) {
assign(i, 1);
--left;
ans += p2[left];
ans %= mod;
} else if (color[i] == 0) {
ans += p2[left];
ans %= mod;
break;
}
}
if (i == n - 1) {
++ans;
ans %= mod;
}
}
return ans;
}
bool assign(int u, int col) {
if (color[u] != -1) {
return color[u] == col;
}
color[u] = col;
for (auto &e : g[u]) {
int v = e.first, type = e.second;
if (!assign(v, col ^ type)) {
return false;
}
}
return true;
} | /* cerberus97 - Hanit Banga */
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define pb push_back
#define fast_cin() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 4e5 + 10, mod = 998244353;
vector<pii> g[N];
int color[N];
ll cnt[N], p2[N];
ll solve(int d, int n, string x);
bool assign(int u, int col);
int main() {
// int n = 6;
// for (int i = 0; i < (1 << n); ++i) {
// int cpy = i, steps = 0;
// while (true) {
// if (cpy % 2 == 0) {
// cpy = (cpy / 2) + (1 << (n - 1));
// } else {
// cpy = (cpy - 1) / 2;
// }
// ++steps;
// if (cpy == i) {
// break;
// }
// }
// cout << i << ' ' << steps << endl;
// }
// return 0;
fast_cin();
int n;
cin >> n;
string x;
cin >> x;
// reverse(x.begin(), x.end());
vector<int> divisors;
int sq = sqrt(2 * n);
for (int i = 1; i <= sq; ++i) {
if ((2 * n) % i == 0) {
divisors.pb(i);
if (i * i != 2 * n) {
divisors.pb((2 * n) / i);
}
}
}
p2[0] = 1;
for (int i = 1; i < N; ++i) {
p2[i] = (2 * p2[i - 1]) % mod;
}
sort(divisors.begin(), divisors.end());
ll ans = 0;
for (auto &d : divisors) {
cnt[d] += solve(d, n, x);
cnt[d] %= mod;
// cout << d << ' ' << cnt[d] << endl;
for (int i = 2 * d; i <= 2 * n; i += d) {
cnt[i] += (mod - cnt[d]);
cnt[i] %= mod;
}
ans += d * cnt[d];
ans %= mod;
}
cout << ans << endl;
}
ll solve(int d, int n, string x) {
for (int i = 0; i < n; ++i) {
g[i].clear();
}
for (int i = 0; i < n; ++i) {
if (i + d < n) {
g[i].pb({i + d, 0});
g[i + d].pb({i, 0});
} else if (d != 2 * n) {
g[i].pb({(i + d) % n, 1});
g[(i + d) % n].pb({i, 1});
} else {
// g[i].pb({(i + d) % n, 0});
// g[(i + d) % n].pb({i, 0});
}
}
memset(color, -1, sizeof(color));
ll components = 0;
for (int i = 0; i < n; ++i) {
if (color[i] == -1) {
if (!assign(i, 0)) {
return 0;
}
++components;
}
}
memset(color, -1, sizeof(color));
// cout << "comp " << d << ' ' << components << endl;
ll ans = 0, left = components;
for (int i = 0; i < n; ++i) {
// if (d == 2 * n) {
// cout << i << ' ' << x[i] << ' ' << color[i] << ' ' << left << endl;
// }
if (x[i] == '0') {
if (color[i] == 1) {
break;
} else if (color[i] == -1) {
assign(i, 0);
--left;
}
} else {
if (color[i] == -1) {
assign(i, 1);
--left;
ans += p2[left];
ans %= mod;
} else if (color[i] == 0) {
ans += p2[left];
ans %= mod;
break;
}
}
if (i == n - 1) {
++ans;
ans %= mod;
}
}
return ans;
}
bool assign(int u, int col) {
if (color[u] != -1) {
return color[u] == col;
}
color[u] = col;
for (auto &e : g[u]) {
int v = e.first, type = e.second;
if (!assign(v, col ^ type)) {
return false;
}
}
return true;
} | replace | 28 | 29 | 28 | 29 | 0 | |
p02893 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 998244353;
int gi() {
int x = 0, o = 1;
char ch = getchar();
while (!isdigit(ch) && ch != '-')
ch = getchar();
if (ch == '-')
o = -1, ch = getchar();
while (isdigit(ch))
x = x * 10 + ch - '0', ch = getchar();
return x * o;
}
int n, f[N], ans = 0, bin[N];
char s[N];
int main() {
cin >> n;
scanf("%s", s + 1);
reverse(s + 1, s + n + 1);
bin[0] = 1;
for (int i = 1; i <= n; i++)
bin[i] = (bin[i - 1] << 1) % mod;
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1)) {
int sum = 0;
for (int j = n; j >= n - i + 1; j--)
if (s[j] == '1')
sum = (sum + bin[j - (n - i) - 1]) % mod;
int fl = 0, fl2 = 0;
for (int j = n - i; j && !fl2; j -= i) {
fl ^= 1;
for (int k = j, l = n; k >= j - i + 1; k--, l--) {
int b = (s[l] - '0') ^ fl;
if (b < s[k] - '0') {
sum = (sum + 1) % mod;
fl2 = 1;
break;
} else if (b > s[k] - '0') {
fl2 = 1;
break;
}
}
}
if (!fl2)
sum = (sum + 1) % mod;
f[i] = sum;
}
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1))
for (int j = i + i; j <= n; j += i)
if (n % j == 0 && ((n / i) & 1))
f[j] = (f[j] - f[i] + mod) % mod;
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1))
ans = (ans + 2ll * f[i] * i) % mod;
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 998244353;
int gi() {
int x = 0, o = 1;
char ch = getchar();
while (!isdigit(ch) && ch != '-')
ch = getchar();
if (ch == '-')
o = -1, ch = getchar();
while (isdigit(ch))
x = x * 10 + ch - '0', ch = getchar();
return x * o;
}
int n, f[N], ans = 0, bin[N];
char s[N];
int main() {
cin >> n;
scanf("%s", s + 1);
reverse(s + 1, s + n + 1);
bin[0] = 1;
for (int i = 1; i <= n; i++)
bin[i] = (bin[i - 1] << 1) % mod;
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1)) {
int sum = 0;
for (int j = n; j >= n - i + 1; j--)
if (s[j] == '1')
sum = (sum + bin[j - (n - i) - 1]) % mod;
int fl = 0, fl2 = 0;
for (int j = n - i; j && !fl2; j -= i) {
fl ^= 1;
for (int k = j, l = n; k >= j - i + 1; k--, l--) {
int b = (s[l] - '0') ^ fl;
if (b < s[k] - '0') {
sum = (sum + 1) % mod;
fl2 = 1;
break;
} else if (b > s[k] - '0') {
fl2 = 1;
break;
}
}
}
if (!fl2)
sum = (sum + 1) % mod;
f[i] = sum;
}
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1))
for (int j = i + i; j <= n; j += i)
if (n % j == 0 && ((n / i) & 1))
f[j] = (f[j] - f[i] + mod) % mod;
for (int i = 1; i <= n; i++)
if (n % i == 0 && ((n / i) & 1))
ans = (ans + 2ll * f[i] * i) % mod;
cout << ans;
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02893 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <vector>
using namespace std;
#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 998244353 // 1000000007
#define N 200005
template <typename U, typename V> void Min(U &a, const V &b) {
if (a > b)
a = b;
}
template <typename U, typename V> void Max(U &a, const V &b) {
if (a < b)
a = b;
}
template <typename U, typename V> void add(U &a, const V &b) {
a = (a + b) % mod;
}
template <typename U> U gcd(U a, U b) {
if (a == 0)
return b;
if (b == 0)
return a;
if (a >= b)
return gcd(a % b, b);
else
return gcd(a, b % a);
}
int pow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1)
ans = 1LL * ans * a % mod;
a = 1LL * a * a % mod;
b >>= 1;
}
return ans;
}
int go(int x, int n) {
int z = x, m = (1 << n - 1);
rep(i, 1, inf) {
if (x & 1)
x >>= 1;
else {
x = x / 2 + m;
}
if (x == z)
return i;
if (i > N)
return -1;
}
}
int h[N], q[N], p[N], d[N];
int cal(int i, int j) {
return (h[i + j] - 1LL * h[i] * q[j] % mod + mod) % mod;
}
int cal1(int i, int j) {
return (d[i + j] - 1LL * d[i] * q[j] % mod + mod) % mod;
}
char s[N];
int main() {
int T, n, m, i, j, k, ca = 0, K;
auto to = [&](int x, int n) {
string s = "";
rep(i, 0, n) {
s.pb((x & 1) + '0');
x >>= 1;
}
return s;
};
scanf("%d%s", &n, s);
//{
// m = 0;
// ll w = 0;
// rep(i, 0, (1<<n)){
// K = go(i, n);
// w += K;
// //if(K != 2 * n)cerr << to(i, n) << " " << K << "\t";
// if(K != 2 * n)m++;
// }
// cerr << n << " " << m << " " << w % mod << "\n";
//}
vi v;
rep(i, 3, n + 1) {
if (n % i == 0) {
v.pb(n / i * 2);
}
i++;
}
sort(all(v));
q[0] = 1;
p[0] = 1;
rep(i, 0, n) {
h[i + 1] = (h[i] * 29LL + s[i]) % mod;
d[i + 1] = (d[i] * 29LL + (s[i] == '0' ? '1' : '0')) % mod;
q[i + 1] = q[i] * 29LL % mod;
p[i + 1] = p[i] * 2LL % mod;
}
ll ans = 0;
vector<ll> w(SZ(v)), res(SZ(v), 0);
rep(i, 0, n) {
if (s[i] == '1') {
h[i + 1] = (h[i] * 29LL + '0') % mod;
d[i + 1] = (d[i] * 29LL + '1') % mod;
rep(j, 0, SZ(v)) {
w[j] = 0;
if (v[j] / 2 >= i + 1) {
w[j] = p[v[j] / 2 - i - 1];
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
// cerr << i+1 << " " << v[j] << " " << w[j] << "\n";
res[j] += w[j] % mod;
} else if (v[j] >= i + 1) {
k = i + 1 - v[j] / 2;
// cerr << i+1 << " " << v[j] << "\n";
if (cal(0, k) == cal1(v[j] / 2, k)) {
w[j] = 1;
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
res[j] += w[j];
}
} else if (cal(0, v[j] / 2) == cal1(v[j] / 2, v[j] / 2)) {
k = (i + 1) / v[j] * v[j];
int r = i + 1 - k;
if (cal(0, k - v[j]) == cal(v[j], k - v[j]) &&
cal(0, r) == cal(k, r)) {
w[j] = 1;
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
res[j] += w[k];
}
}
}
h[i + 1] = (h[i] * 29LL + '1') % mod;
d[i + 1] = (d[i] * 29LL + '0') % mod;
}
}
rep(j, 0, SZ(v)) if (cal(0, v[j] / 2) == cal1(v[j] / 2, v[j] / 2)) {
k = n / v[j] * v[j];
int r = n - k;
if (cal(0, k - v[j]) == cal(v[j], k - v[j]) && cal(0, r) == cal(k, r)) {
res[j]++;
break;
}
}
ll u = 0, sum = 0;
rep(i, 0, n) u = (u * 2 + (s[i] - '0')) % mod;
u++;
rep(i, 0, SZ(v)) res[i] %= mod, sum += res[i], ans += res[i] * v[i] % mod;
sum %= mod;
u -= sum;
if (u < 0)
u += mod;
// DBG(sum)DBG(SZ(v))
ans += 2LL * n * u % mod;
ans %= mod;
if (ans < 0)
ans += mod;
printf("%lld\n", ans);
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <vector>
using namespace std;
#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 998244353 // 1000000007
#define N 200005
template <typename U, typename V> void Min(U &a, const V &b) {
if (a > b)
a = b;
}
template <typename U, typename V> void Max(U &a, const V &b) {
if (a < b)
a = b;
}
template <typename U, typename V> void add(U &a, const V &b) {
a = (a + b) % mod;
}
template <typename U> U gcd(U a, U b) {
if (a == 0)
return b;
if (b == 0)
return a;
if (a >= b)
return gcd(a % b, b);
else
return gcd(a, b % a);
}
int pow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1)
ans = 1LL * ans * a % mod;
a = 1LL * a * a % mod;
b >>= 1;
}
return ans;
}
int go(int x, int n) {
int z = x, m = (1 << n - 1);
rep(i, 1, inf) {
if (x & 1)
x >>= 1;
else {
x = x / 2 + m;
}
if (x == z)
return i;
if (i > N)
return -1;
}
}
int h[N], q[N], p[N], d[N];
int cal(int i, int j) {
return (h[i + j] - 1LL * h[i] * q[j] % mod + mod) % mod;
}
int cal1(int i, int j) {
return (d[i + j] - 1LL * d[i] * q[j] % mod + mod) % mod;
}
char s[N];
int main() {
int T, n, m, i, j, k, ca = 0, K;
auto to = [&](int x, int n) {
string s = "";
rep(i, 0, n) {
s.pb((x & 1) + '0');
x >>= 1;
}
return s;
};
scanf("%d%s", &n, s);
//{
// m = 0;
// ll w = 0;
// rep(i, 0, (1<<n)){
// K = go(i, n);
// w += K;
// //if(K != 2 * n)cerr << to(i, n) << " " << K << "\t";
// if(K != 2 * n)m++;
// }
// cerr << n << " " << m << " " << w % mod << "\n";
//}
vi v;
rep(i, 3, n + 1) {
if (n % i == 0) {
v.pb(n / i * 2);
}
i++;
}
sort(all(v));
q[0] = 1;
p[0] = 1;
rep(i, 0, n) {
h[i + 1] = (h[i] * 29LL + s[i]) % mod;
d[i + 1] = (d[i] * 29LL + (s[i] == '0' ? '1' : '0')) % mod;
q[i + 1] = q[i] * 29LL % mod;
p[i + 1] = p[i] * 2LL % mod;
}
ll ans = 0;
vector<ll> w(SZ(v)), res(SZ(v), 0);
rep(i, 0, n) {
if (s[i] == '1') {
h[i + 1] = (h[i] * 29LL + '0') % mod;
d[i + 1] = (d[i] * 29LL + '1') % mod;
rep(j, 0, SZ(v)) {
w[j] = 0;
if (v[j] / 2 >= i + 1) {
w[j] = p[v[j] / 2 - i - 1];
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
// cerr << i+1 << " " << v[j] << " " << w[j] << "\n";
res[j] += w[j] % mod;
} else if (v[j] >= i + 1) {
k = i + 1 - v[j] / 2;
// cerr << i+1 << " " << v[j] << "\n";
if (cal(0, k) == cal1(v[j] / 2, k)) {
w[j] = 1;
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
res[j] += w[j];
}
} else if (cal(0, v[j] / 2) == cal1(v[j] / 2, v[j] / 2)) {
k = (i + 1) / v[j] * v[j];
int r = i + 1 - k;
if (cal(0, k - v[j]) == cal(v[j], k - v[j]) &&
cal(0, r) == cal(k, r)) {
w[j] = 1;
rep(k, 0, j) if (v[j] % v[k] == 0) w[j] -= w[k];
res[j] += w[j];
}
}
}
h[i + 1] = (h[i] * 29LL + '1') % mod;
d[i + 1] = (d[i] * 29LL + '0') % mod;
}
}
rep(j, 0, SZ(v)) if (cal(0, v[j] / 2) == cal1(v[j] / 2, v[j] / 2)) {
k = n / v[j] * v[j];
int r = n - k;
if (cal(0, k - v[j]) == cal(v[j], k - v[j]) && cal(0, r) == cal(k, r)) {
res[j]++;
break;
}
}
ll u = 0, sum = 0;
rep(i, 0, n) u = (u * 2 + (s[i] - '0')) % mod;
u++;
rep(i, 0, SZ(v)) res[i] %= mod, sum += res[i], ans += res[i] * v[i] % mod;
sum %= mod;
u -= sum;
if (u < 0)
u += mod;
// DBG(sum)DBG(SZ(v))
ans += 2LL * n * u % mod;
ans %= mod;
if (ans < 0)
ans += mod;
printf("%lld\n", ans);
}
| replace | 149 | 150 | 149 | 150 | 0 | |
p02893 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) \
cerr << #x "[" << l << "-" << r << "] = "; \
for (int _i = l; _i <= r; ++_i) \
cerr << x[_i] << " "; \
cerr << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define gc() getchar()
// char buf[1<<23],*p1=buf,*p2=buf;
// #define gc()
// (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x) {
x = 0;
char c = gc();
int flag = 0;
while (c < '0' || c > '9')
flag |= (c == '-'), c = gc();
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = gc();
if (flag)
x = -x;
}
template <class T> T _max(T a, T b) { return a > b ? a : b; }
template <class T> T _min(T a, T b) { return a < b ? a : b; }
template <class T> bool checkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
template <class T> bool checkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
const int mod = 998244353;
int Add(int a, int b) {
a += b;
return a >= mod ? a - mod : a;
}
int Sub(int a, int b) {
a -= b;
return a < 0 ? a + mod : a;
}
int Mul(int a, int b) { return (ll)a * b % mod; }
void add(int &a, int b) { a = Add(a, b); }
void sub(int &a, int b) { a = Sub(a, b); }
void mul(int &a, int b) { a = Mul(a, b); }
int qpow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1)
mul(ans, a);
mul(a, a);
b >>= 1;
}
return ans;
}
const int N = 100005;
char a[N], A[N];
int n, b[N];
int flag[N], prime[N], cnt = 0, mu[N];
int f[N], g[N];
int calc(int x) {
int tot = n / x;
if (tot % 2 == 0)
return 0;
int ans = b[x];
for (int i = 1; i <= x; ++i) {
A[i] = a[i];
}
for (int i = x + 1; i <= n; ++i) {
A[i] = '0' + '1' - A[i - x];
}
int flag = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] < A[i]) {
flag = -1;
break;
} else if (a[i] > A[i]) {
flag = 1;
break;
}
}
if (flag >= 0)
++ans;
return ans % mod;
}
void init() {
read(n);
scanf("%s", a + 1);
for (int i = 1; i <= n; ++i) {
b[i] = Mul(b[i - 1], 2);
add(b[i], a[i] - '0');
}
mu[1] = 1;
for (int i = 2; i <= n; ++i) {
if (!flag[i]) {
prime[++cnt] = i;
mu[i] = mod - 1;
}
for (int j = 1; j <= cnt && i * prime[j] <= n; ++j) {
flag[i * prime[j]] = 1;
if (i % prime[j] == 0) {
mu[i * prime[j]] = 0;
break;
}
mu[i * prime[j]] = mod - mu[i];
}
}
for (int i = 1; i <= n; ++i) {
if (n % i)
continue;
f[i] = calc(i);
}
}
void solve() {
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; j += i) {
add(g[j], Mul(f[i], mu[j / i]));
}
}
int ans = Mul(b[n] + 1, n + n);
for (int i = 1; i <= n; ++i) {
if (!f[i])
continue;
int tmp = Mul(n + n - i - i, g[i]);
sub(ans, tmp);
}
printf("%d\n", ans);
}
#undef int
int main() {
init();
solve();
return 0;
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) \
cerr << #x "[" << l << "-" << r << "] = "; \
for (int _i = l; _i <= r; ++_i) \
cerr << x[_i] << " "; \
cerr << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define gc() getchar()
// char buf[1<<23],*p1=buf,*p2=buf;
// #define gc()
// (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x) {
x = 0;
char c = gc();
int flag = 0;
while (c < '0' || c > '9')
flag |= (c == '-'), c = gc();
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = gc();
if (flag)
x = -x;
}
template <class T> T _max(T a, T b) { return a > b ? a : b; }
template <class T> T _min(T a, T b) { return a < b ? a : b; }
template <class T> bool checkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
template <class T> bool checkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
const int mod = 998244353;
int Add(int a, int b) {
a += b;
return a >= mod ? a - mod : a;
}
int Sub(int a, int b) {
a -= b;
return a < 0 ? a + mod : a;
}
int Mul(int a, int b) { return (ll)a * b % mod; }
void add(int &a, int b) { a = Add(a, b); }
void sub(int &a, int b) { a = Sub(a, b); }
void mul(int &a, int b) { a = Mul(a, b); }
int qpow(int a, int b) {
int ans = 1;
while (b) {
if (b & 1)
mul(ans, a);
mul(a, a);
b >>= 1;
}
return ans;
}
const int N = 400005;
char a[N], A[N];
int n, b[N];
int flag[N], prime[N], cnt = 0, mu[N];
int f[N], g[N];
int calc(int x) {
int tot = n / x;
if (tot % 2 == 0)
return 0;
int ans = b[x];
for (int i = 1; i <= x; ++i) {
A[i] = a[i];
}
for (int i = x + 1; i <= n; ++i) {
A[i] = '0' + '1' - A[i - x];
}
int flag = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] < A[i]) {
flag = -1;
break;
} else if (a[i] > A[i]) {
flag = 1;
break;
}
}
if (flag >= 0)
++ans;
return ans % mod;
}
void init() {
read(n);
scanf("%s", a + 1);
for (int i = 1; i <= n; ++i) {
b[i] = Mul(b[i - 1], 2);
add(b[i], a[i] - '0');
}
mu[1] = 1;
for (int i = 2; i <= n; ++i) {
if (!flag[i]) {
prime[++cnt] = i;
mu[i] = mod - 1;
}
for (int j = 1; j <= cnt && i * prime[j] <= n; ++j) {
flag[i * prime[j]] = 1;
if (i % prime[j] == 0) {
mu[i * prime[j]] = 0;
break;
}
mu[i * prime[j]] = mod - mu[i];
}
}
for (int i = 1; i <= n; ++i) {
if (n % i)
continue;
f[i] = calc(i);
}
}
void solve() {
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; j += i) {
add(g[j], Mul(f[i], mu[j / i]));
}
}
int ans = Mul(b[n] + 1, n + n);
for (int i = 1; i <= n; ++i) {
if (!f[i])
continue;
int tmp = Mul(n + n - i - i, g[i]);
sub(ans, tmp);
}
printf("%d\n", ans);
}
#undef int
int main() {
init();
solve();
return 0;
}
| replace | 66 | 67 | 66 | 67 | 0 | |
p02893 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 100, MOD = 998244353;
int add(ll a, int b) { return (a + b + 2LL * MOD) % MOD; }
int mul(ll a, int b) { return (a * b) % MOD; }
void sadd(int &a, int b) { a = add(a, b); }
void smul(int &a, int b) { a = mul(a, b); }
vector<int> divs[N];
int cnt[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string x;
cin >> n >> x;
n *= 2;
string t = x;
for (auto &c : t)
c = (c == '0' ? '1' : '0');
x.insert(x.end(), t.begin(), t.end());
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j += i)
divs[j].push_back(i);
vector<int> ds;
for (int i = 1; i <= n; i++)
if (n % i == 0 && n % (2 * i) != 0)
ds.push_back(i);
int ans = 0;
for (auto g : ds) {
int cur = 0;
string cx;
for (int i = 0; i < g / 2; i++) {
smul(cur, 2);
if (x[i] == '1')
sadd(cur, 1);
cx.push_back(x[i]);
}
sadd(cnt[g], cur);
for (int i = 0; i < g / 2; i++)
cx.push_back((cx[i] == '0' ? '1' : '0'));
for (int i = g; i < n; i++)
cx.push_back(cx[i % g]);
if (cx <= x)
sadd(cnt[g], 1);
for (auto d : divs[g])
if (d != g)
sadd(cnt[g], -cnt[d]);
sadd(ans, mul(g, cnt[g]));
}
cout << ans << "\n";
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 100, MOD = 998244353;
int add(ll a, int b) { return (a + b + 2LL * MOD) % MOD; }
int mul(ll a, int b) { return (a * b) % MOD; }
void sadd(int &a, int b) { a = add(a, b); }
void smul(int &a, int b) { a = mul(a, b); }
vector<int> divs[N];
int cnt[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string x;
cin >> n >> x;
n *= 2;
string t = x;
for (auto &c : t)
c = (c == '0' ? '1' : '0');
x.insert(x.end(), t.begin(), t.end());
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j += i)
divs[j].push_back(i);
vector<int> ds;
for (int i = 1; i <= n; i++)
if (n % i == 0 && n % (2 * i) != 0)
ds.push_back(i);
int ans = 0;
for (auto g : ds) {
int cur = 0;
string cx;
for (int i = 0; i < g / 2; i++) {
smul(cur, 2);
if (x[i] == '1')
sadd(cur, 1);
cx.push_back(x[i]);
}
sadd(cnt[g], cur);
for (int i = 0; i < g / 2; i++)
cx.push_back((cx[i] == '0' ? '1' : '0'));
for (int i = g; i < n; i++)
cx.push_back(cx[i % g]);
if (cx <= x)
sadd(cnt[g], 1);
for (auto d : divs[g])
if (d != g)
sadd(cnt[g], -cnt[d]);
sadd(ans, mul(g, cnt[g]));
}
cout << ans << "\n";
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02893 | C++ | Runtime Error | #pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
// hloya template v26
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <bits/stdc++.h>
using namespace std;
bool dbg = 0;
clock_t start_time = clock();
#define current_time \
fixed << setprecision(6) << (ld)(clock() - start_time) / CLOCKS_PER_SEC
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))
#define ull unsigned long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define umap unordered_map<int, int>
#define files1 freopen("input.txt", "r", stdin)
#define files2 freopen("output.txt", "w", stdout)
#define files \
files1; \
files2
#define fast_io \
ios_base::sync_with_stdio(0); \
cin.tie(0)
// #define endl '\n'
#define ln(i, n) " \n"[(i) == (n)-1]
void bad(string mes = "Impossible") {
cout << mes;
exit(0);
}
void bad(int mes) {
cout << mes;
exit(0);
}
template <typename T> string bin(T x, int st = 2) {
string ans = "";
while (x > 0) {
ans += char('0' + x % st);
x /= st;
}
reverse(ans.begin(), ans.end());
return ans.empty() ? "0" : ans;
}
mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2> inline bool upmax(T1 &a, T2 b) {
return (a < b ? (a = b, true) : false);
}
template <typename T1, typename T2> inline bool upmin(T1 &a, T2 b) {
return (b < a ? (a = b, true) : false);
}
// inline int popcount(int x){
// int count = 0;
// __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
// return count;
// }
template <typename T> T input() {
T ans = 0, m = 1;
char c = ' ';
while (!((c >= '0' && c <= '9') || c == '-')) {
c = getchar();
}
if (c == '-')
m = -1, c = getchar();
while (c >= '0' && c <= '9') {
ans = ans * 10 + (c - '0'), c = getchar();
}
return ans * m;
}
template <typename T> T gcd(T a, T b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
template <typename T> void read(T &a) { a = input<T>(); }
template <typename T> void read(T &a, T &b) { read(a), read(b); }
template <typename T> void read(T &a, T &b, T &c) { read(a, b), read(c); }
template <typename T> void read(T &a, T &b, T &c, T &d) {
read(a, b), read(c, d);
}
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = (int)2e5 + 3, base = 998244353;
const ll llinf = 2e18 + 5;
int binpow(int a, int s) {
int res = 1;
while (s) {
if (s % 2) {
res = 1ll * res * a % base;
}
a = 1ll * a * a % base;
s /= 2;
}
return res;
}
int solve(int n, int k) {
int need = k;
for (int iter = 0;; iter++) {
if (need == k && iter > 0) {
return iter;
}
if (k & 1) {
k /= 2;
} else {
k /= 2;
k += 1 << (n - 1);
}
}
}
int n;
string x;
int dva[maxn];
int eval(int d) {
int l = n / d;
int ans = 0;
for (int i = 0; i < l; i++) {
if (x[i] == '1') {
ans += dva[l - i - 1];
ans %= base;
}
}
bool ok = true;
for (int i = 0; i < n; i++) {
int m = i / l;
int nd = x[i % l] - '0';
if (m % 2) {
nd ^= 1;
}
int hv = x[i] - '0';
if (hv < nd) {
ok = false;
break;
}
if (hv > nd) {
break;
}
}
return ans + ok;
}
int main() {
files1;
fast_io;
dva[0] = 1;
for (int i = 1; i < maxn; i++) {
dva[i] = 1ll * dva[i - 1] * 2 % base;
}
cin >> n >> x;
vector<pii> dp;
for (int d = 1; d * d <= n; d++) {
if (n % d == 0) {
int a = d;
int b = n / d;
if (a % 2) {
dp.pb(mp(a, eval(a)));
}
if (a != b) {
if (b % 2) {
dp.pb(mp(b, eval(b)));
}
}
}
}
sort(all(dp));
int ans = 0;
for (int i = dp.size() - 1; i >= 0; i--) {
for (int j = i + 1; j < dp.size(); j++) {
if (dp[j].f % dp[i].f == 0) {
dp[i].s = (dp[i].s - dp[j].s + base) % base;
}
}
ans += 1ll * dp[i].s * (2 * n / dp[i].f) % base;
ans %= base;
}
cout << ans;
return 0;
} | #pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
// hloya template v26
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <bits/stdc++.h>
using namespace std;
bool dbg = 0;
clock_t start_time = clock();
#define current_time \
fixed << setprecision(6) << (ld)(clock() - start_time) / CLOCKS_PER_SEC
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))
#define ull unsigned long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define umap unordered_map<int, int>
#define files1 freopen("input.txt", "r", stdin)
#define files2 freopen("output.txt", "w", stdout)
#define files \
files1; \
files2
#define fast_io \
ios_base::sync_with_stdio(0); \
cin.tie(0)
// #define endl '\n'
#define ln(i, n) " \n"[(i) == (n)-1]
void bad(string mes = "Impossible") {
cout << mes;
exit(0);
}
void bad(int mes) {
cout << mes;
exit(0);
}
template <typename T> string bin(T x, int st = 2) {
string ans = "";
while (x > 0) {
ans += char('0' + x % st);
x /= st;
}
reverse(ans.begin(), ans.end());
return ans.empty() ? "0" : ans;
}
mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2> inline bool upmax(T1 &a, T2 b) {
return (a < b ? (a = b, true) : false);
}
template <typename T1, typename T2> inline bool upmin(T1 &a, T2 b) {
return (b < a ? (a = b, true) : false);
}
// inline int popcount(int x){
// int count = 0;
// __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
// return count;
// }
template <typename T> T input() {
T ans = 0, m = 1;
char c = ' ';
while (!((c >= '0' && c <= '9') || c == '-')) {
c = getchar();
}
if (c == '-')
m = -1, c = getchar();
while (c >= '0' && c <= '9') {
ans = ans * 10 + (c - '0'), c = getchar();
}
return ans * m;
}
template <typename T> T gcd(T a, T b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
template <typename T> void read(T &a) { a = input<T>(); }
template <typename T> void read(T &a, T &b) { read(a), read(b); }
template <typename T> void read(T &a, T &b, T &c) { read(a, b), read(c); }
template <typename T> void read(T &a, T &b, T &c, T &d) {
read(a, b), read(c, d);
}
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = (int)2e5 + 3, base = 998244353;
const ll llinf = 2e18 + 5;
int binpow(int a, int s) {
int res = 1;
while (s) {
if (s % 2) {
res = 1ll * res * a % base;
}
a = 1ll * a * a % base;
s /= 2;
}
return res;
}
int solve(int n, int k) {
int need = k;
for (int iter = 0;; iter++) {
if (need == k && iter > 0) {
return iter;
}
if (k & 1) {
k /= 2;
} else {
k /= 2;
k += 1 << (n - 1);
}
}
}
int n;
string x;
int dva[maxn];
int eval(int d) {
int l = n / d;
int ans = 0;
for (int i = 0; i < l; i++) {
if (x[i] == '1') {
ans += dva[l - i - 1];
ans %= base;
}
}
bool ok = true;
for (int i = 0; i < n; i++) {
int m = i / l;
int nd = x[i % l] - '0';
if (m % 2) {
nd ^= 1;
}
int hv = x[i] - '0';
if (hv < nd) {
ok = false;
break;
}
if (hv > nd) {
break;
}
}
return ans + ok;
}
int main() {
// files1;
fast_io;
dva[0] = 1;
for (int i = 1; i < maxn; i++) {
dva[i] = 1ll * dva[i - 1] * 2 % base;
}
cin >> n >> x;
vector<pii> dp;
for (int d = 1; d * d <= n; d++) {
if (n % d == 0) {
int a = d;
int b = n / d;
if (a % 2) {
dp.pb(mp(a, eval(a)));
}
if (a != b) {
if (b % 2) {
dp.pb(mp(b, eval(b)));
}
}
}
}
sort(all(dp));
int ans = 0;
for (int i = dp.size() - 1; i >= 0; i--) {
for (int j = i + 1; j < dp.size(); j++) {
if (dp[j].f % dp[i].f == 0) {
dp[i].s = (dp[i].s - dp[j].s + base) % base;
}
}
ans += 1ll * dp[i].s * (2 * n / dp[i].f) % base;
ans %= base;
}
cout << ans;
return 0;
} | replace | 186 | 187 | 186 | 187 | 0 | |
p02893 | C++ | Runtime Error | // #define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>
namespace n91 {
using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;
constexpr usize operator"" _z(unsigned long long x) noexcept {
return static_cast<usize>(x);
}
template <class T> class integral_iterator {
public:
using difference_type = T;
using value_type = T;
using pointer = const value_type *;
using reference = value_type;
using iterator_category = std::random_access_iterator_tag;
private:
using self_type = integral_iterator<value_type>;
value_type i;
public:
constexpr integral_iterator() noexcept : i() {}
explicit constexpr integral_iterator(const value_type i) noexcept : i(i) {}
constexpr self_type operator++(int) noexcept { return self_type(i++); }
constexpr self_type operator--(int) noexcept { return self_type(i--); }
constexpr self_type operator[](const difference_type rhs) const noexcept {
return self_type(i + rhs);
}
constexpr self_type &operator++() noexcept {
++i;
return *this;
}
constexpr self_type &operator--() noexcept {
--i;
return *this;
}
constexpr reference operator*() const noexcept { return i; }
constexpr self_type operator+(const difference_type rhs) const noexcept {
return self_type(i + rhs);
}
constexpr self_type operator-(const difference_type rhs) const noexcept {
return self_type(i - rhs);
}
constexpr difference_type operator-(const self_type rhs) const noexcept {
return i - rhs.i;
}
constexpr bool operator<(const self_type rhs) const noexcept {
return i < rhs.i;
}
constexpr bool operator<=(const self_type rhs) const noexcept {
return i <= rhs.i;
}
constexpr bool operator>(const self_type rhs) const noexcept {
return i > rhs.i;
}
constexpr bool operator>=(const self_type rhs) const noexcept {
return i >= rhs.i;
}
constexpr bool operator==(const self_type rhs) const noexcept {
return i == rhs.i;
}
constexpr bool operator!=(const self_type rhs) const noexcept {
return i != rhs.i;
}
constexpr self_type &operator+=(const difference_type rhs) noexcept {
i += rhs;
return *this;
}
constexpr self_type &operator-=(const difference_type rhs) noexcept {
i -= rhs;
return *this;
}
};
template <class T>
constexpr integral_iterator<T> make_int_itr(const T i) noexcept {
return integral_iterator<T>(i);
}
class rep {
const usize f, l;
public:
constexpr rep(const usize f, const usize l) noexcept : f(f), l(l) {}
constexpr auto begin() const noexcept { return make_int_itr(f); }
constexpr auto end() const noexcept { return make_int_itr(l); }
};
class revrep {
const usize f, l;
public:
revrep(const usize f, const usize l) noexcept : f(l), l(f) {}
auto begin() const noexcept {
return std::make_reverse_iterator(make_int_itr(f));
}
auto end() const noexcept {
return std::make_reverse_iterator(make_int_itr(l));
}
};
template <class T> auto md_vec(const usize n, const T &value) {
return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
return a < b ? b - a : a - b;
}
template <class T> T scan() {
T ret;
std::cin >> ret;
return ret;
}
} // namespace n91
#include <cstdint>
namespace n91 {
constexpr std::uint_fast64_t totient(std::uint_fast64_t x) noexcept {
using u64 = std::uint_fast64_t;
u64 ret = x;
for (u64 i = static_cast<u64>(2); i * i <= x; ++i) {
if (x % i == static_cast<u64>(0)) {
ret -= ret / i;
x /= i;
while (x % i == static_cast<u64>(0)) {
x /= i;
}
}
}
if (x != static_cast<u64>(1)) {
ret -= ret / x;
}
return ret;
}
template <std::uint_fast64_t Modulus,
std::uint_fast64_t InverseExp =
totient(Modulus) - static_cast<std::uint_fast64_t>(1)>
class modint {
using u64 = std::uint_fast64_t;
static_assert(Modulus < static_cast<u64>(1) << static_cast<u64>(32),
"Modulus must be less than 2**32");
u64 a;
constexpr modint &negate() noexcept {
if (a != static_cast<u64>(0)) {
a = Modulus - a;
}
return *this;
}
public:
constexpr modint(const u64 x = static_cast<u64>(0)) noexcept
: a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+() const noexcept { return modint(*this); }
constexpr modint operator-() const noexcept { return modint(*this).negate(); }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = InverseExp;
while (exp) {
if (exp % static_cast<u64>(2) != static_cast<u64>(0)) {
*this *= rhs;
}
rhs *= rhs;
exp /= static_cast<u64>(2);
}
return *this;
}
constexpr bool operator==(const modint rhs) const noexcept {
return a == rhs.a;
}
constexpr bool operator!=(const modint rhs) const noexcept {
return a != rhs.a;
}
};
template <class T, std::uint_fast64_t v> class modint_constant {
public:
static constexpr T value = static_cast<T>(v);
using value_type = T;
};
} // namespace n91
#include <cassert>
#include <cstddef>
#include <utility>
#include <vector>
namespace n91 {
class prime_sieve {
public:
using size_type = std::size_t;
private:
std::vector<size_type> prime, factor;
public:
prime_sieve() {}
explicit prime_sieve(const size_type size) : prime(), factor(size, 0) {
assert(size > 2);
factor[0] = 1;
for (size_type i{2}; i != size; ++i) {
if (factor[i] == 0) {
factor[i] = i;
prime.push_back(i);
}
for (size_type j{0};
j != prime.size() && prime[j] <= factor[i] && i * prime[j] < size;
++j) {
factor[i * prime[j]] = prime[j];
}
}
}
size_type len() const noexcept { return factor.size(); }
bool is_prime(const size_type i) const noexcept {
assert(i < len());
return factor[i] == i;
}
std::vector<size_type> factorize(size_type i) const noexcept {
assert(i != 0);
std::vector<size_type> ret;
while (i != 1) {
ret.push_back(factor[i]);
i /= factor[i];
}
return std::move(ret);
}
template <class C> void divisor_zeta(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{1}; j * prime[i] < n; ++j) {
c[j * prime[i]] += c[j];
}
}
}
template <class C> void divisor_mobius(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{(n - 1) / prime[i]}; j != 0; --j) {
c[j * prime[i]] -= c[j];
}
}
}
template <class C> void multiple_zeta(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{(n - 1) / prime[i]}; j != 0; --j) {
c[j] += c[j * prime[i]];
}
}
}
template <class C> void multiple_mobius(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{1}; j * prime[i] < n; ++j) {
c[j] -= c[j * prime[i]];
}
}
}
};
} // namespace n91
#include <algorithm>
#include <iostream>
#include <utility>
namespace n91 {
void main_() {
using mint = modint<static_cast<u64>(998244353)>;
const usize n = scan<usize>();
std::vector<int> x(n);
for (auto &e : x) {
e = scan<char>() - '0';
}
std::vector<mint> pow2(n + 1_z);
pow2[0_z] = static_cast<mint>(1);
for (const auto i : rep(0_z, n)) {
pow2[i + 1_z] = pow2[i] + pow2[i];
}
const auto solve = [&](const usize block) -> mint {
mint ret = static_cast<mint>(0);
for (const auto i : rep(0_z, block)) {
if (x[i]) {
ret += pow2[block - i - 1_z];
}
}
for (const auto i : rep(0_z, n)) {
const int ex = x[i % block] ^ (i / block % 2_z);
if (ex < x[i]) {
return ret + static_cast<mint>(1);
}
if (ex > x[i]) {
return ret;
}
}
return ret + static_cast<mint>(1);
};
std::vector<mint> vec(n + 1_z);
mint ans = static_cast<mint>(0);
for (const auto i : rep(1_z, n + 1_z)) {
if (n % i == 0_z && i % 2_z == 1_z) {
vec[i] += solve(n / i);
}
}
const prime_sieve s{200000};
s.multiple_mobius(vec);
for (const auto i : rep(1_z, n + 1_z)) {
ans += vec[i] * static_cast<mint>(n / i);
}
std::cout << (ans * static_cast<mint>(2)).value() << std::endl;
}
} // namespace n91
int main() {
n91::main_();
return 0;
}
| // #define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>
namespace n91 {
using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;
constexpr usize operator"" _z(unsigned long long x) noexcept {
return static_cast<usize>(x);
}
template <class T> class integral_iterator {
public:
using difference_type = T;
using value_type = T;
using pointer = const value_type *;
using reference = value_type;
using iterator_category = std::random_access_iterator_tag;
private:
using self_type = integral_iterator<value_type>;
value_type i;
public:
constexpr integral_iterator() noexcept : i() {}
explicit constexpr integral_iterator(const value_type i) noexcept : i(i) {}
constexpr self_type operator++(int) noexcept { return self_type(i++); }
constexpr self_type operator--(int) noexcept { return self_type(i--); }
constexpr self_type operator[](const difference_type rhs) const noexcept {
return self_type(i + rhs);
}
constexpr self_type &operator++() noexcept {
++i;
return *this;
}
constexpr self_type &operator--() noexcept {
--i;
return *this;
}
constexpr reference operator*() const noexcept { return i; }
constexpr self_type operator+(const difference_type rhs) const noexcept {
return self_type(i + rhs);
}
constexpr self_type operator-(const difference_type rhs) const noexcept {
return self_type(i - rhs);
}
constexpr difference_type operator-(const self_type rhs) const noexcept {
return i - rhs.i;
}
constexpr bool operator<(const self_type rhs) const noexcept {
return i < rhs.i;
}
constexpr bool operator<=(const self_type rhs) const noexcept {
return i <= rhs.i;
}
constexpr bool operator>(const self_type rhs) const noexcept {
return i > rhs.i;
}
constexpr bool operator>=(const self_type rhs) const noexcept {
return i >= rhs.i;
}
constexpr bool operator==(const self_type rhs) const noexcept {
return i == rhs.i;
}
constexpr bool operator!=(const self_type rhs) const noexcept {
return i != rhs.i;
}
constexpr self_type &operator+=(const difference_type rhs) noexcept {
i += rhs;
return *this;
}
constexpr self_type &operator-=(const difference_type rhs) noexcept {
i -= rhs;
return *this;
}
};
template <class T>
constexpr integral_iterator<T> make_int_itr(const T i) noexcept {
return integral_iterator<T>(i);
}
class rep {
const usize f, l;
public:
constexpr rep(const usize f, const usize l) noexcept : f(f), l(l) {}
constexpr auto begin() const noexcept { return make_int_itr(f); }
constexpr auto end() const noexcept { return make_int_itr(l); }
};
class revrep {
const usize f, l;
public:
revrep(const usize f, const usize l) noexcept : f(l), l(f) {}
auto begin() const noexcept {
return std::make_reverse_iterator(make_int_itr(f));
}
auto end() const noexcept {
return std::make_reverse_iterator(make_int_itr(l));
}
};
template <class T> auto md_vec(const usize n, const T &value) {
return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
return a < b ? b - a : a - b;
}
template <class T> T scan() {
T ret;
std::cin >> ret;
return ret;
}
} // namespace n91
#include <cstdint>
namespace n91 {
constexpr std::uint_fast64_t totient(std::uint_fast64_t x) noexcept {
using u64 = std::uint_fast64_t;
u64 ret = x;
for (u64 i = static_cast<u64>(2); i * i <= x; ++i) {
if (x % i == static_cast<u64>(0)) {
ret -= ret / i;
x /= i;
while (x % i == static_cast<u64>(0)) {
x /= i;
}
}
}
if (x != static_cast<u64>(1)) {
ret -= ret / x;
}
return ret;
}
template <std::uint_fast64_t Modulus,
std::uint_fast64_t InverseExp =
totient(Modulus) - static_cast<std::uint_fast64_t>(1)>
class modint {
using u64 = std::uint_fast64_t;
static_assert(Modulus < static_cast<u64>(1) << static_cast<u64>(32),
"Modulus must be less than 2**32");
u64 a;
constexpr modint &negate() noexcept {
if (a != static_cast<u64>(0)) {
a = Modulus - a;
}
return *this;
}
public:
constexpr modint(const u64 x = static_cast<u64>(0)) noexcept
: a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+() const noexcept { return modint(*this); }
constexpr modint operator-() const noexcept { return modint(*this).negate(); }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = InverseExp;
while (exp) {
if (exp % static_cast<u64>(2) != static_cast<u64>(0)) {
*this *= rhs;
}
rhs *= rhs;
exp /= static_cast<u64>(2);
}
return *this;
}
constexpr bool operator==(const modint rhs) const noexcept {
return a == rhs.a;
}
constexpr bool operator!=(const modint rhs) const noexcept {
return a != rhs.a;
}
};
template <class T, std::uint_fast64_t v> class modint_constant {
public:
static constexpr T value = static_cast<T>(v);
using value_type = T;
};
} // namespace n91
#include <cassert>
#include <cstddef>
#include <utility>
#include <vector>
namespace n91 {
class prime_sieve {
public:
using size_type = std::size_t;
private:
std::vector<size_type> prime, factor;
public:
prime_sieve() {}
explicit prime_sieve(const size_type size) : prime(), factor(size, 0) {
assert(size > 2);
factor[0] = 1;
for (size_type i{2}; i != size; ++i) {
if (factor[i] == 0) {
factor[i] = i;
prime.push_back(i);
}
for (size_type j{0};
j != prime.size() && prime[j] <= factor[i] && i * prime[j] < size;
++j) {
factor[i * prime[j]] = prime[j];
}
}
}
size_type len() const noexcept { return factor.size(); }
bool is_prime(const size_type i) const noexcept {
assert(i < len());
return factor[i] == i;
}
std::vector<size_type> factorize(size_type i) const noexcept {
assert(i != 0);
std::vector<size_type> ret;
while (i != 1) {
ret.push_back(factor[i]);
i /= factor[i];
}
return std::move(ret);
}
template <class C> void divisor_zeta(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{1}; j * prime[i] < n; ++j) {
c[j * prime[i]] += c[j];
}
}
}
template <class C> void divisor_mobius(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{(n - 1) / prime[i]}; j != 0; --j) {
c[j * prime[i]] -= c[j];
}
}
}
template <class C> void multiple_zeta(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{(n - 1) / prime[i]}; j != 0; --j) {
c[j] += c[j * prime[i]];
}
}
}
template <class C> void multiple_mobius(C &c) const noexcept {
const size_type n{c.size()};
assert(n <= len());
for (size_type i{0}; i != prime.size() && prime[i] < n; ++i) {
for (size_type j{1}; j * prime[i] < n; ++j) {
c[j] -= c[j * prime[i]];
}
}
}
};
} // namespace n91
#include <algorithm>
#include <iostream>
#include <utility>
namespace n91 {
void main_() {
using mint = modint<static_cast<u64>(998244353)>;
const usize n = scan<usize>();
std::vector<int> x(n);
for (auto &e : x) {
e = scan<char>() - '0';
}
std::vector<mint> pow2(n + 1_z);
pow2[0_z] = static_cast<mint>(1);
for (const auto i : rep(0_z, n)) {
pow2[i + 1_z] = pow2[i] + pow2[i];
}
const auto solve = [&](const usize block) -> mint {
mint ret = static_cast<mint>(0);
for (const auto i : rep(0_z, block)) {
if (x[i]) {
ret += pow2[block - i - 1_z];
}
}
for (const auto i : rep(0_z, n)) {
const int ex = x[i % block] ^ (i / block % 2_z);
if (ex < x[i]) {
return ret + static_cast<mint>(1);
}
if (ex > x[i]) {
return ret;
}
}
return ret + static_cast<mint>(1);
};
std::vector<mint> vec(n + 1_z);
mint ans = static_cast<mint>(0);
for (const auto i : rep(1_z, n + 1_z)) {
if (n % i == 0_z && i % 2_z == 1_z) {
vec[i] += solve(n / i);
}
}
const prime_sieve s{300000_z};
s.multiple_mobius(vec);
for (const auto i : rep(1_z, n + 1_z)) {
ans += vec[i] * static_cast<mint>(n / i);
}
std::cout << (ans * static_cast<mint>(2)).value() << std::endl;
}
} // namespace n91
int main() {
n91::main_();
return 0;
}
| replace | 361 | 362 | 361 | 362 | 0 | |
p02893 | C++ | Time Limit Exceeded | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
constexpr char ln = '\n';
// constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;
template <class T1, class T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T1, class T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return true;
}
return false;
}
inline int popcount(int x) { return __builtin_popcount(x); }
inline int popcount(long long x) { return __builtin_popcountll(x); }
void print() { cout << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &...args) {
cout << x << " ";
print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
vector<long long> divisor(long long x) {
assert(x);
vector<long long> ret;
for (long long i = 1; i * i <= x; i++) {
if (x % i == 0) {
ret.emplace_back(i);
ret.emplace_back(x / i);
}
}
sort(ret.begin(), ret.end());
ret.erase(unique(begin(ret), end(ret)), end(ret));
return ret;
}
template <uint_fast64_t Modulus> struct ModInt {
using u64 = uint_fast64_t;
u64 a;
constexpr ModInt(const long long x = 0) noexcept
: a(x >= 0 ? x % Modulus : (Modulus - (-x) % Modulus) % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr ModInt operator+(const ModInt rhs) const noexcept {
return ModInt(*this) += rhs;
}
constexpr ModInt operator-(const ModInt rhs) const noexcept {
return ModInt(*this) -= rhs;
}
constexpr ModInt operator*(const ModInt rhs) const noexcept {
return ModInt(*this) *= rhs;
}
constexpr ModInt operator/(const ModInt rhs) const noexcept {
return ModInt(*this) /= rhs;
}
constexpr ModInt operator^(const long long rhs) const noexcept {
return ModInt(*this) ^= rhs;
}
constexpr bool operator==(const ModInt &rhs) const noexcept {
return a == rhs.a;
}
constexpr bool operator!=(const ModInt &rhs) const noexcept {
return a != rhs.a;
}
constexpr ModInt &operator+=(const ModInt rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr ModInt &operator-=(const ModInt rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr ModInt &operator*=(const ModInt rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr ModInt &operator/=(ModInt rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp & 1)
*this *= rhs;
exp >>= 1;
rhs *= rhs;
}
return *this;
}
constexpr ModInt &operator^=(long long exp) noexcept {
ModInt rhs = a;
a = 1;
while (exp) {
if (exp & 1)
*this *= rhs;
exp >>= 1;
rhs *= rhs;
}
return *this;
}
friend ostream &operator<<(ostream &os, const ModInt &rhs) noexcept {
return os << rhs.a;
}
friend istream &operator>>(istream &is, ModInt &rhs) noexcept {
long long a;
is >> a;
rhs = a;
return is;
}
};
using mint = ModInt<MOD>;
template <typename S> vector<int> Z_Algorithm(const S &s) {
// 先頭i文字目(0-indexed)から見て一致した文字数
vector<int> prefix(s.size());
prefix[0] = s.size();
int i = 1, j = 0;
while (i < s.size()) {
while (i + j < s.size() && (s[j] == s[i + j]))
++j;
prefix[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < s.size() && k + prefix[k] < j)
prefix[i + k] = prefix[k], ++k;
i += k;
j -= k;
}
return prefix;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
string S;
cin >> S;
auto A = divisor(N);
vector<int> B;
for (auto i : A) {
if (i & 1)
B.emplace_back(i);
}
reverse(all(B));
int M = B.size();
vector<mint> cnt(M);
mint ans = 0;
rep(i, M) {
int n = N / B[i];
string T = S;
string I = S.substr(0, n);
string R = "";
rep(j, n) {
if (I[j] == '0')
R += '1';
else
R += '0';
}
mint val = 0;
rep(j, n) {
val *= 2;
if (I[j] == '1')
val += 1;
}
rep(j, N) {
if (j & 1)
T += R;
else
T += I;
}
auto Z = Z_Algorithm<string>(T);
if (Z[N] == N)
val += 1;
else {
if (S[Z[N]] == '1')
val += 1;
}
cnt[i] += val;
for (int j = i + 1; j < M; j++) {
if (B[i] % B[j] == 0)
cnt[j] -= cnt[i];
}
ans += cnt[i] * n * 2;
}
cout << ans << ln;
}
| #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
constexpr char ln = '\n';
// constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;
template <class T1, class T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T1, class T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return true;
}
return false;
}
inline int popcount(int x) { return __builtin_popcount(x); }
inline int popcount(long long x) { return __builtin_popcountll(x); }
void print() { cout << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &...args) {
cout << x << " ";
print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
vector<long long> divisor(long long x) {
assert(x);
vector<long long> ret;
for (long long i = 1; i * i <= x; i++) {
if (x % i == 0) {
ret.emplace_back(i);
ret.emplace_back(x / i);
}
}
sort(ret.begin(), ret.end());
ret.erase(unique(begin(ret), end(ret)), end(ret));
return ret;
}
template <uint_fast64_t Modulus> struct ModInt {
using u64 = uint_fast64_t;
u64 a;
constexpr ModInt(const long long x = 0) noexcept
: a(x >= 0 ? x % Modulus : (Modulus - (-x) % Modulus) % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr ModInt operator+(const ModInt rhs) const noexcept {
return ModInt(*this) += rhs;
}
constexpr ModInt operator-(const ModInt rhs) const noexcept {
return ModInt(*this) -= rhs;
}
constexpr ModInt operator*(const ModInt rhs) const noexcept {
return ModInt(*this) *= rhs;
}
constexpr ModInt operator/(const ModInt rhs) const noexcept {
return ModInt(*this) /= rhs;
}
constexpr ModInt operator^(const long long rhs) const noexcept {
return ModInt(*this) ^= rhs;
}
constexpr bool operator==(const ModInt &rhs) const noexcept {
return a == rhs.a;
}
constexpr bool operator!=(const ModInt &rhs) const noexcept {
return a != rhs.a;
}
constexpr ModInt &operator+=(const ModInt rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr ModInt &operator-=(const ModInt rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr ModInt &operator*=(const ModInt rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr ModInt &operator/=(ModInt rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp & 1)
*this *= rhs;
exp >>= 1;
rhs *= rhs;
}
return *this;
}
constexpr ModInt &operator^=(long long exp) noexcept {
ModInt rhs = a;
a = 1;
while (exp) {
if (exp & 1)
*this *= rhs;
exp >>= 1;
rhs *= rhs;
}
return *this;
}
friend ostream &operator<<(ostream &os, const ModInt &rhs) noexcept {
return os << rhs.a;
}
friend istream &operator>>(istream &is, ModInt &rhs) noexcept {
long long a;
is >> a;
rhs = a;
return is;
}
};
using mint = ModInt<MOD>;
template <typename S> vector<int> Z_Algorithm(const S &s) {
// 先頭i文字目(0-indexed)から見て一致した文字数
vector<int> prefix(s.size());
prefix[0] = s.size();
int i = 1, j = 0;
while (i < s.size()) {
while (i + j < s.size() && (s[j] == s[i + j]))
++j;
prefix[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < s.size() && k + prefix[k] < j)
prefix[i + k] = prefix[k], ++k;
i += k;
j -= k;
}
return prefix;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
string S;
cin >> S;
auto A = divisor(N);
vector<int> B;
for (auto i : A) {
if (i & 1)
B.emplace_back(i);
}
reverse(all(B));
int M = B.size();
vector<mint> cnt(M);
mint ans = 0;
rep(i, M) {
int n = N / B[i];
string T = S;
string I = S.substr(0, n);
string R = "";
rep(j, n) {
if (I[j] == '0')
R += '1';
else
R += '0';
}
mint val = 0;
rep(j, n) {
val *= 2;
if (I[j] == '1')
val += 1;
}
rep(j, B[i]) {
if (j & 1)
T += R;
else
T += I;
}
auto Z = Z_Algorithm<string>(T);
if (Z[N] == N)
val += 1;
else {
if (S[Z[N]] == '1')
val += 1;
}
cnt[i] += val;
for (int j = i + 1; j < M; j++) {
if (B[i] % B[j] == 0)
cnt[j] -= cnt[i];
}
ans += cnt[i] * n * 2;
}
cout << ans << ln;
}
| replace | 197 | 198 | 197 | 198 | TLE | |
p02893 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
template <typename T> T inverse(T a, T m) {
T u = 0, v = 1;
while (a != 0) {
T t = m / a;
m -= t * a;
swap(a, m);
u -= t * v;
swap(u, v);
}
assert(m == 1);
return u;
}
template <typename T> class Modular {
public:
using Type = typename decay<decltype(T::value)>::type;
constexpr Modular() : value() {}
template <typename U> Modular(const U &x) { value = normalize(x); }
template <typename U> static Type normalize(const U &x) {
Type v;
if (-mod() <= x && x < mod())
v = static_cast<Type>(x);
else
v = static_cast<Type>(x % mod());
if (v < 0)
v += mod();
return v;
}
const Type &operator()() const { return value; }
template <typename U> explicit operator U() const {
return static_cast<U>(value);
}
constexpr static Type mod() { return T::value; }
Modular &operator+=(const Modular &other) {
if ((value += other.value) >= mod())
value -= mod();
return *this;
}
Modular &operator-=(const Modular &other) {
if ((value -= other.value) < 0)
value += mod();
return *this;
}
template <typename U> Modular &operator+=(const U &other) {
return *this += Modular(other);
}
template <typename U> Modular &operator-=(const U &other) {
return *this -= Modular(other);
}
Modular &operator++() { return *this += 1; }
Modular &operator--() { return *this -= 1; }
Modular operator++(int) {
Modular result(*this);
*this += 1;
return result;
}
Modular operator--(int) {
Modular result(*this);
*this -= 1;
return result;
}
Modular operator-() const { return Modular(-value); }
template <typename U = T>
typename enable_if<is_same<typename Modular<U>::Type, int>::value,
Modular>::type &
operator*=(const Modular &rhs) {
value = normalize(static_cast<int64_t>(value) *
static_cast<int64_t>(rhs.value));
return *this;
}
template <typename U = T>
typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value,
Modular>::type &
operator*=(const Modular &rhs) {
int64_t q = static_cast<int64_t>(static_cast<long double>(value) *
rhs.value / mod());
value = normalize(value * rhs.value - q * mod());
return *this;
}
template <typename U = T>
typename enable_if<!is_integral<typename Modular<U>::Type>::value,
Modular>::type &
operator*=(const Modular &rhs) {
value = normalize(value * rhs.value);
return *this;
}
Modular &operator/=(const Modular &other) {
return *this *= Modular(inverse(other.value, mod()));
}
template <typename U> friend const Modular<U> &abs(const Modular<U> &v) {
return v;
}
template <typename U>
friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs);
template <typename U>
friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs);
template <typename U>
friend std::istream &operator>>(std::istream &stream, Modular<U> &number);
private:
Type value;
};
template <typename T>
bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) {
return lhs.value == rhs.value;
}
template <typename T, typename U>
bool operator==(const Modular<T> &lhs, U rhs) {
return lhs == Modular<T>(rhs);
}
template <typename T, typename U>
bool operator==(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) == rhs;
}
template <typename T>
bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) {
return !(lhs == rhs);
}
template <typename T, typename U>
bool operator!=(const Modular<T> &lhs, U rhs) {
return !(lhs == rhs);
}
template <typename T, typename U>
bool operator!=(U lhs, const Modular<T> &rhs) {
return !(lhs == rhs);
}
template <typename T>
bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) {
return lhs.value < rhs.value;
}
template <typename T>
Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T, typename U>
Modular<T> operator+(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T, typename U>
Modular<T> operator+(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T>
Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T, typename U>
Modular<T> operator-(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T, typename U>
Modular<T> operator-(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T>
Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T, typename U>
Modular<T> operator*(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T, typename U>
Modular<T> operator*(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T>
Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> operator/(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> operator/(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> power(const Modular<T> &a, const U &b) {
assert(b >= 0);
Modular<T> x = a, res = 1;
U p = b;
while (p > 0) {
if (p & 1)
res *= x;
x *= x;
p >>= 1;
}
return res;
}
template <typename T> bool IsZero(const Modular<T> &number) {
return number() == 0;
}
template <typename T> string to_string(const Modular<T> &number) {
return to_string(number());
}
template <typename T>
std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) {
return stream << number();
}
template <typename T>
std::istream &operator>>(std::istream &stream, Modular<T> &number) {
typename common_type<typename Modular<T>::Type, int64_t>::type x;
stream >> x;
number.value = Modular<T>::normalize(x);
return stream;
}
constexpr int md = 998244353;
using Mint = Modular<std::integral_constant<decay<decltype(md)>::type, md>>;
template <typename... Args> void read(Args &...args) { (cin >> ... >> args); }
template <typename... Args> void writeln(const Args &...args) {
((cout << args << " "), ...), cout << "\n";
}
template <typename... Args> void write(const Args &...args) {
((cout << args), ...);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
typename enable_if<is_same<decltype(declval<T>().size()), size_t>::value,
int>::type
operator~(const T &ct) {
return (int)ct.size();
}
template <typename T, typename... Args> bool ckmax(T &a, const Args &...b) {
return (a < max({b...})) ? (a = max({b...}), true) : false;
}
template <typename T, typename... Args> bool ckmin(T &a, const Args &...b) {
return (a > min({b...})) ? (a = min({b...}), true) : false;
}
template <typename T> struct range {
T u, v;
bool inclusive;
range(const T &_u, const T &_v, const bool &_inclusive = false)
: u(_u), v(_v), inclusive(_inclusive) {}
bool has(const T &w) { return (u <= w) and (inclusive ? (w <= v) : (w < v)); }
};
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vpii = vector<pii>;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
template <typename T> using vv = vector<vector<T>>;
template <typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using max_heap = priority_queue<T, vector<T>, less<T>>;
const int N = 200'010;
vi odd_divs(int n) {
vi res;
for (int i = 1; i <= n; ++i) {
if (!(n % i) and i % 2) {
res.push_back(i);
}
}
return res;
}
Mint bintuMintu(const string &s) {
Mint res = 0;
for (int i = 0; i < ~s; ++i) {
res = 2 * res + (s[i] - '0');
};
;
return res;
}
Mint compute(int hf, int d, const string &x) {
int n = ~x;
string s = x.substr(0, hf), t(n, '0');
for (int i = 0; i < ~s; ++i) {
t[i] = s[i] ^ 1;
};
;
Mint res = bintuMintu(s);
string st;
for (int i = 0; i < (d >> 1); ++i) {
st += s, st += t;
}
st += s;
res += (st <= x);
return res;
}
auto soln() {
int n;
string x;
cin >> n >> x;
map<int, Mint> C;
for (auto d : odd_divs(n)) {
int hf = n / d, k = 2 * hf;
C[k] = compute(hf, d, x);
};
;
for (int i = 1; i <= n; ++i) {
if (C.find(i) != C.end()) {
for (int j = 2 * i; j <= 2 * n; j += i) {
if (C.find(j) != C.end())
C[j] -= C[i];
}
}
};
;
Mint res;
for (auto &[k, v] : C) {
res += k * v;
}
cout << res << "\n";
}
signed main() {
int t = 1;
{ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
while (t--)
soln();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
template <typename T> T inverse(T a, T m) {
T u = 0, v = 1;
while (a != 0) {
T t = m / a;
m -= t * a;
swap(a, m);
u -= t * v;
swap(u, v);
}
assert(m == 1);
return u;
}
template <typename T> class Modular {
public:
using Type = typename decay<decltype(T::value)>::type;
constexpr Modular() : value() {}
template <typename U> Modular(const U &x) { value = normalize(x); }
template <typename U> static Type normalize(const U &x) {
Type v;
if (-mod() <= x && x < mod())
v = static_cast<Type>(x);
else
v = static_cast<Type>(x % mod());
if (v < 0)
v += mod();
return v;
}
const Type &operator()() const { return value; }
template <typename U> explicit operator U() const {
return static_cast<U>(value);
}
constexpr static Type mod() { return T::value; }
Modular &operator+=(const Modular &other) {
if ((value += other.value) >= mod())
value -= mod();
return *this;
}
Modular &operator-=(const Modular &other) {
if ((value -= other.value) < 0)
value += mod();
return *this;
}
template <typename U> Modular &operator+=(const U &other) {
return *this += Modular(other);
}
template <typename U> Modular &operator-=(const U &other) {
return *this -= Modular(other);
}
Modular &operator++() { return *this += 1; }
Modular &operator--() { return *this -= 1; }
Modular operator++(int) {
Modular result(*this);
*this += 1;
return result;
}
Modular operator--(int) {
Modular result(*this);
*this -= 1;
return result;
}
Modular operator-() const { return Modular(-value); }
template <typename U = T>
typename enable_if<is_same<typename Modular<U>::Type, int>::value,
Modular>::type &
operator*=(const Modular &rhs) {
value = normalize(static_cast<int64_t>(value) *
static_cast<int64_t>(rhs.value));
return *this;
}
template <typename U = T>
typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value,
Modular>::type &
operator*=(const Modular &rhs) {
int64_t q = static_cast<int64_t>(static_cast<long double>(value) *
rhs.value / mod());
value = normalize(value * rhs.value - q * mod());
return *this;
}
template <typename U = T>
typename enable_if<!is_integral<typename Modular<U>::Type>::value,
Modular>::type &
operator*=(const Modular &rhs) {
value = normalize(value * rhs.value);
return *this;
}
Modular &operator/=(const Modular &other) {
return *this *= Modular(inverse(other.value, mod()));
}
template <typename U> friend const Modular<U> &abs(const Modular<U> &v) {
return v;
}
template <typename U>
friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs);
template <typename U>
friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs);
template <typename U>
friend std::istream &operator>>(std::istream &stream, Modular<U> &number);
private:
Type value;
};
template <typename T>
bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) {
return lhs.value == rhs.value;
}
template <typename T, typename U>
bool operator==(const Modular<T> &lhs, U rhs) {
return lhs == Modular<T>(rhs);
}
template <typename T, typename U>
bool operator==(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) == rhs;
}
template <typename T>
bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) {
return !(lhs == rhs);
}
template <typename T, typename U>
bool operator!=(const Modular<T> &lhs, U rhs) {
return !(lhs == rhs);
}
template <typename T, typename U>
bool operator!=(U lhs, const Modular<T> &rhs) {
return !(lhs == rhs);
}
template <typename T>
bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) {
return lhs.value < rhs.value;
}
template <typename T>
Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T, typename U>
Modular<T> operator+(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T, typename U>
Modular<T> operator+(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) += rhs;
}
template <typename T>
Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T, typename U>
Modular<T> operator-(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T, typename U>
Modular<T> operator-(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) -= rhs;
}
template <typename T>
Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T, typename U>
Modular<T> operator*(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T, typename U>
Modular<T> operator*(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) *= rhs;
}
template <typename T>
Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> operator/(const Modular<T> &lhs, U rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> operator/(U lhs, const Modular<T> &rhs) {
return Modular<T>(lhs) /= rhs;
}
template <typename T, typename U>
Modular<T> power(const Modular<T> &a, const U &b) {
assert(b >= 0);
Modular<T> x = a, res = 1;
U p = b;
while (p > 0) {
if (p & 1)
res *= x;
x *= x;
p >>= 1;
}
return res;
}
template <typename T> bool IsZero(const Modular<T> &number) {
return number() == 0;
}
template <typename T> string to_string(const Modular<T> &number) {
return to_string(number());
}
template <typename T>
std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) {
return stream << number();
}
template <typename T>
std::istream &operator>>(std::istream &stream, Modular<T> &number) {
typename common_type<typename Modular<T>::Type, int64_t>::type x;
stream >> x;
number.value = Modular<T>::normalize(x);
return stream;
}
constexpr int md = 998244353;
using Mint = Modular<std::integral_constant<decay<decltype(md)>::type, md>>;
template <typename... Args> void read(Args &...args) { (cin >> ... >> args); }
template <typename... Args> void writeln(const Args &...args) {
((cout << args << " "), ...), cout << "\n";
}
template <typename... Args> void write(const Args &...args) {
((cout << args), ...);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
typename enable_if<is_same<decltype(declval<T>().size()), size_t>::value,
int>::type
operator~(const T &ct) {
return (int)ct.size();
}
template <typename T, typename... Args> bool ckmax(T &a, const Args &...b) {
return (a < max({b...})) ? (a = max({b...}), true) : false;
}
template <typename T, typename... Args> bool ckmin(T &a, const Args &...b) {
return (a > min({b...})) ? (a = min({b...}), true) : false;
}
template <typename T> struct range {
T u, v;
bool inclusive;
range(const T &_u, const T &_v, const bool &_inclusive = false)
: u(_u), v(_v), inclusive(_inclusive) {}
bool has(const T &w) { return (u <= w) and (inclusive ? (w <= v) : (w < v)); }
};
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vpii = vector<pii>;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
template <typename T> using vv = vector<vector<T>>;
template <typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using max_heap = priority_queue<T, vector<T>, less<T>>;
const int N = 200'010;
vi odd_divs(int n) {
vi res;
for (int i = 1; i <= n; ++i) {
if (!(n % i) and i % 2) {
res.push_back(i);
}
}
return res;
}
Mint bintuMintu(const string &s) {
Mint res = 0;
for (int i = 0; i < ~s; ++i) {
res = 2 * res + (s[i] - '0');
};
;
return res;
}
Mint compute(int hf, int d, const string &x) {
int n = ~x;
string s = x.substr(0, hf), t(hf, '0');
for (int i = 0; i < ~s; ++i) {
t[i] = s[i] ^ 1;
};
;
Mint res = bintuMintu(s);
string st;
for (int i = 0; i < (d >> 1); ++i) {
st += s, st += t;
}
st += s;
res += (st <= x);
return res;
}
auto soln() {
int n;
string x;
cin >> n >> x;
map<int, Mint> C;
for (auto d : odd_divs(n)) {
int hf = n / d, k = 2 * hf;
C[k] = compute(hf, d, x);
};
;
for (int i = 1; i <= n; ++i) {
if (C.find(i) != C.end()) {
for (int j = 2 * i; j <= 2 * n; j += i) {
if (C.find(j) != C.end())
C[j] -= C[i];
}
}
};
;
Mint res;
for (auto &[k, v] : C) {
res += k * v;
}
cout << res << "\n";
}
signed main() {
int t = 1;
{ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
while (t--)
soln();
return 0;
}
| replace | 273 | 274 | 273 | 274 | TLE | |
p02894 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
typedef long double db;
typedef long long ll;
const db pi = acos(-1.0);
int n, L, a[maxn];
ll w;
db x, y, X, Y;
int main() {
cin >> n >> L;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a, a + n);
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++) {
x = cos(pi * (a[i] + a[j]) / L);
y = sin(pi * (a[i] + a[j]) / L);
int r = ((n - 2) - (j - i - 1)) - (j - i - 1);
X += x * r;
Y += y * r;
}
w = 1ll * n * (n - 1) * (n - 2) / 6;
printf("%.15Lf %.15Lf\n", X / w, Y / w);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
typedef long double db;
typedef long long ll;
const db pi = acos(-1.0);
int n, L, a[maxn];
ll w;
db x, y, X, Y;
int main() {
cin >> n >> L;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a, a + n);
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++) {
x = cos(pi * (a[i] + a[j]) / L);
y = sin(pi * (a[i] + a[j]) / L);
int r = ((n - 2) - (j - i - 1)) - (j - i - 1);
X += x * r;
Y += y * r;
}
w = 1ll * n * (n - 1) * (n - 2) / 6;
printf("%.15Lf %.15Lf\n", X / w, Y / w);
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02894 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
int a[3333];
ll nc3(ll n) { return ((n * (n - 1) * (n - 2))) / 6; }
ll n, L;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
const ld inf = 1e20;
const int maxp = 111111;
int dblcmp(ld d) {
if (fabs(d) < eps)
return 0;
return d > eps ? 1 : -1;
}
inline ld sqr(ld x) { return x * x; }
struct point {
ld x, y;
point() {}
point(ld _x, ld _y) : x(_x), y(_y){};
void input() { scanf("%lf%lf", &x, &y); }
void output() { printf("%.2f %.2f\n", x, y); }
bool operator==(point a) const {
return dblcmp(a.x - x) == 0 && dblcmp(a.y - y) == 0;
}
bool operator<(point a) const {
return dblcmp(a.x - x) == 0 ? dblcmp(y - a.y) < 0 : x < a.x;
}
ld len() { return hypot(x, y); }
ld len2() { return x * x + y * y; }
ld distance(point p) { return hypot(x - p.x, y - p.y); }
point add(point p) { return point(x + p.x, y + p.y); }
point sub(point p) { return point(x - p.x, y - p.y); }
point mul(ld b) { return point(x * b, y * b); }
point div(ld b) { return point(x / b, y / b); }
ld dot(point p) { return x * p.x + y * p.y; }
ld det(point p) { return x * p.y - y * p.x; }
ld rad(point a, point b) {
point p = *this;
return fabs(atan2(fabs(a.sub(p).det(b.sub(p))), a.sub(p).dot(b.sub(p))));
}
point trunc(ld r) {
ld l = len();
if (!dblcmp(l))
return *this;
r /= l;
return point(x * r, y * r);
}
point rotleft() { return point(-y, x); }
point rotright() { return point(y, -x); }
point rotate(point p, ld angle) // 绕点p逆时针旋转angle角度
{
point v = this->sub(p);
ld c = cos(angle), s = sin(angle);
return point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
};
const ld PI = acos(-1);
point F(ll a, ll N) {
return {cos(2 * PI * ld(a) / ld(N)), sin(2 * PI * ld(a) / ld(N))};
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> L;
L *= 2;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] *= 2;
}
ld ans[2] = {0, 0};
for (int i = 0; i < n; i++) {
vector<point> sum(n + 1, point(0, 0));
ll l = a[i];
for (int j = i + 1; j < n; j++) {
sum[j] = sum[j - 1];
point tp = F(a[j] - l, 2 * L);
sum[j].x += tp.x;
sum[j].y += tp.y;
}
for (int j = i + 2; j < n; j++) {
ll r = a[j];
ll m = (r + l + L) / 2;
//<<m<<'\n';
ll cnt = j - i - 1;
ld tmp[2] = {sum[j - 1].x - sum[i].x, sum[j - 1].y - sum[i].y};
/*for(int k=i+1;k<j;k++)
{
point pt = F(a[k]-l,2*L);
//<<a[k]-l<<' '<<2*L<<'\n';
tmp[0]+=pt.x; tmp[1]+=pt.y;
}*/
tmp[0] /= cnt;
tmp[1] /= cnt;
// centre of gravity in tmp
point cent = F(m, L);
point lpt = F(l, L);
point newpt;
newpt.x = tmp[0];
newpt.y = tmp[1];
point disp;
disp.x = lpt.x - cent.x;
disp.y = lpt.y - cent.y;
////<<disp.x<<' '<<disp.y<<' '<<disp.y/disp.x<<'
///'<<atan2(disp.x,disp.y)*180/PI<<'\n';
//<<"ANGLE ROT: "<<atan2(disp.y,disp.x)<<'\n';
newpt = newpt.rotate(point(0, 0), atan2(disp.y, disp.x));
tmp[0] = newpt.x;
tmp[1] = newpt.y;
ld R = F(l, L).distance(F(m, L));
//<<tmp[0]<<' '<<tmp[1]<<' '<<cent.x<<' '<<cent.y<<' '<<R<<'\n';
tmp[0] *= R;
tmp[1] *= R;
tmp[0] += cent.x;
tmp[1] += cent.y;
tmp[0] *= cnt;
tmp[1] *= cnt;
//<<tmp[0]<<' '<<tmp[1]<<' '<<cent.x<<' '<<cent.y<<' '<<R<<'\n';
ans[0] += tmp[0];
ans[1] += tmp[1];
}
}
ans[0] /= ld(nc3(n));
ans[1] /= ld(nc3(n));
cout << fixed << setprecision(15) << ans[0] << ' ' << ans[1] << '\n';
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
int a[3333];
ll nc3(ll n) { return ((n * (n - 1) * (n - 2))) / 6; }
ll n, L;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
const ld inf = 1e20;
const int maxp = 111111;
int dblcmp(ld d) {
if (fabs(d) < eps)
return 0;
return d > eps ? 1 : -1;
}
inline ld sqr(ld x) { return x * x; }
struct point {
ld x, y;
point() {}
point(ld _x, ld _y) : x(_x), y(_y){};
void input() { scanf("%lf%lf", &x, &y); }
void output() { printf("%.2f %.2f\n", x, y); }
bool operator==(point a) const {
return dblcmp(a.x - x) == 0 && dblcmp(a.y - y) == 0;
}
bool operator<(point a) const {
return dblcmp(a.x - x) == 0 ? dblcmp(y - a.y) < 0 : x < a.x;
}
ld len() { return hypot(x, y); }
ld len2() { return x * x + y * y; }
ld distance(point p) { return hypot(x - p.x, y - p.y); }
point add(point p) { return point(x + p.x, y + p.y); }
point sub(point p) { return point(x - p.x, y - p.y); }
point mul(ld b) { return point(x * b, y * b); }
point div(ld b) { return point(x / b, y / b); }
ld dot(point p) { return x * p.x + y * p.y; }
ld det(point p) { return x * p.y - y * p.x; }
ld rad(point a, point b) {
point p = *this;
return fabs(atan2(fabs(a.sub(p).det(b.sub(p))), a.sub(p).dot(b.sub(p))));
}
point trunc(ld r) {
ld l = len();
if (!dblcmp(l))
return *this;
r /= l;
return point(x * r, y * r);
}
point rotleft() { return point(-y, x); }
point rotright() { return point(y, -x); }
point rotate(point p, ld angle) // 绕点p逆时针旋转angle角度
{
point v = this->sub(p);
ld c = cos(angle), s = sin(angle);
return point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
};
const ld PI = acos(-1);
point F(ll a, ll N) {
return {cos(2 * PI * ld(a) / ld(N)), sin(2 * PI * ld(a) / ld(N))};
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> L;
L *= 2;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] *= 2;
}
ld ans[2] = {0, 0};
for (int i = 0; i < n; i++) {
vector<point> sum(n + 1, point(0, 0));
ll l = a[i];
for (int j = i + 1; j < n; j++) {
sum[j] = sum[j - 1];
point tp = F(a[j] - l, 2 * L);
sum[j].x += tp.x;
sum[j].y += tp.y;
}
for (int j = i + 2; j < n; j++) {
ll r = a[j];
ll m = (r + l + L) / 2;
//<<m<<'\n';
ll cnt = j - i - 1;
ld tmp[2] = {sum[j - 1].x - sum[i].x, sum[j - 1].y - sum[i].y};
/*for(int k=i+1;k<j;k++)
{
point pt = F(a[k]-l,2*L);
//<<a[k]-l<<' '<<2*L<<'\n';
tmp[0]+=pt.x; tmp[1]+=pt.y;
}*/
tmp[0] /= cnt;
tmp[1] /= cnt;
// centre of gravity in tmp
point cent = F(m, L);
point lpt = F(l, L);
point newpt;
newpt.x = tmp[0];
newpt.y = tmp[1];
point disp;
disp.x = lpt.x - cent.x;
disp.y = lpt.y - cent.y;
////<<disp.x<<' '<<disp.y<<' '<<disp.y/disp.x<<'
///'<<atan2(disp.x,disp.y)*180/PI<<'\n';
//<<"ANGLE ROT: "<<atan2(disp.y,disp.x)<<'\n';
newpt = newpt.rotate(point(0, 0), atan2(disp.y, disp.x));
tmp[0] = newpt.x;
tmp[1] = newpt.y;
ld R = F(l, L).distance(F(m, L));
//<<tmp[0]<<' '<<tmp[1]<<' '<<cent.x<<' '<<cent.y<<' '<<R<<'\n';
tmp[0] *= R;
tmp[1] *= R;
tmp[0] += cent.x;
tmp[1] += cent.y;
tmp[0] *= cnt;
tmp[1] *= cnt;
//<<tmp[0]<<' '<<tmp[1]<<' '<<cent.x<<' '<<cent.y<<' '<<R<<'\n';
ans[0] += tmp[0];
ans[1] += tmp[1];
}
}
ans[0] /= ld(nc3(n));
ans[1] /= ld(nc3(n));
cout << fixed << setprecision(15) << ans[0] << ' ' << ans[1] << '\n';
}
| replace | 16 | 17 | 16 | 17 | TLE | |
p02894 | C++ | Runtime Error | #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define N 2005
const double PI = acos(-1.0);
typedef long long ll;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}
return x * f;
}
int n, L, t[N];
double X, Y;
int main() {
n = read(), L = read();
for (int i = 1; i <= n; ++i) {
t[i] = read();
}
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j) {
X += (n - 2 * (j - i)) * cos(PI * (t[i] + t[j]) / L);
Y += (n - 2 * (j - i)) * sin(PI * (t[i] + t[j]) / L);
}
}
ll all = 1LL * n * (n - 1) * (n - 2) / 6;
printf("%.12lf %.12lf\n", X / all, Y / all);
return 0;
}
| #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define N 3005
const double PI = acos(-1.0);
typedef long long ll;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}
return x * f;
}
int n, L, t[N];
double X, Y;
int main() {
n = read(), L = read();
for (int i = 1; i <= n; ++i) {
t[i] = read();
}
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j) {
X += (n - 2 * (j - i)) * cos(PI * (t[i] + t[j]) / L);
Y += (n - 2 * (j - i)) * sin(PI * (t[i] + t[j]) / L);
}
}
ll all = 1LL * n * (n - 1) * (n - 2) / 6;
printf("%.12lf %.12lf\n", X / all, Y / all);
return 0;
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p02894 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long long ll;
template <typename _T> inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
fu = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getchar();
}
f *= fu;
}
template <typename T> void print(T x) {
if (x < 0)
putchar('-'), x = -x;
if (x < 10)
putchar(x + 48);
else
print(x / 10), putchar(x % 10 + 48);
}
template <typename T> void print(T x, char t) {
print(x);
putchar(t);
}
const double PI = acos(-1.0);
const int N = 1005;
int a[N];
double sx, sy;
int n, L;
int main() {
read(n);
read(L);
for (register int i = 1; i <= n; i++)
read(a[i]);
for (register int i = 1; i <= n; i++) {
for (register int j = i + 1; j <= n; j++) {
double a1 = (double)(a[i] + a[j]) / 2 / L, a2 = a1 + 0.5;
if (a2 >= 1)
a2 -= 1;
sx += cos(a1 * 2 * PI) * (n - (j - i + 1));
sy += sin(a1 * 2 * PI) * (n - (j - i + 1));
sx += cos(a2 * 2 * PI) * (j - i - 1);
sy += sin(a2 * 2 * PI) * (j - i - 1);
}
}
ll cnt = 1ll * n * (n - 1) * (n - 2) / 6;
printf("%.9lf %.9lf\n", sx / cnt, sy / cnt);
return 0;
} | #include <bits/stdc++.h>
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long long ll;
template <typename _T> inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
fu = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getchar();
}
f *= fu;
}
template <typename T> void print(T x) {
if (x < 0)
putchar('-'), x = -x;
if (x < 10)
putchar(x + 48);
else
print(x / 10), putchar(x % 10 + 48);
}
template <typename T> void print(T x, char t) {
print(x);
putchar(t);
}
const double PI = acos(-1.0);
const int N = 3005;
int a[N];
double sx, sy;
int n, L;
int main() {
read(n);
read(L);
for (register int i = 1; i <= n; i++)
read(a[i]);
for (register int i = 1; i <= n; i++) {
for (register int j = i + 1; j <= n; j++) {
double a1 = (double)(a[i] + a[j]) / 2 / L, a2 = a1 + 0.5;
if (a2 >= 1)
a2 -= 1;
sx += cos(a1 * 2 * PI) * (n - (j - i + 1));
sy += sin(a1 * 2 * PI) * (n - (j - i + 1));
sx += cos(a2 * 2 * PI) * (j - i - 1);
sy += sin(a2 * 2 * PI) * (j - i - 1);
}
}
ll cnt = 1ll * n * (n - 1) * (n - 2) / 6;
printf("%.9lf %.9lf\n", sx / cnt, sy / cnt);
return 0;
} | replace | 40 | 41 | 40 | 41 | 0 | |
p02894 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)
using namespace std;
typedef double db;
const db pi = acos(-1.0);
int n, L, a[2010];
db A, B;
int main() {
scanf("%d%d", &n, &L);
rep(i, 1, n) scanf("%d", a + i);
sort(a + 1, a + n + 1);
rep(i, 1, n) rep(j, i + 1, n) {
db x = cos(db(a[i] + a[j]) / L * pi), y = sin(db(a[i] + a[j]) / L * pi);
int k1 = j - i - 1, k2 = n - 2 - k1;
A += (k2 - k1) * x, B += (k2 - k1) * y;
}
A = A / n / (n - 1) / (n - 2) * 6;
B = B / n / (n - 1) / (n - 2) * 6;
printf("%.15lf %.15lf", A, B);
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)
using namespace std;
typedef double db;
const db pi = acos(-1.0);
int n, L, a[3010];
db A, B;
int main() {
scanf("%d%d", &n, &L);
rep(i, 1, n) scanf("%d", a + i);
sort(a + 1, a + n + 1);
rep(i, 1, n) rep(j, i + 1, n) {
db x = cos(db(a[i] + a[j]) / L * pi), y = sin(db(a[i] + a[j]) / L * pi);
int k1 = j - i - 1, k2 = n - 2 - k1;
A += (k2 - k1) * x, B += (k2 - k1) * y;
}
A = A / n / (n - 1) / (n - 2) * 6;
B = B / n / (n - 1) / (n - 2) * 6;
printf("%.15lf %.15lf", A, B);
return 0;
} | replace | 16 | 17 | 16 | 17 | 0 | |
p02894 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
template <class T> void debug(T itr1, T itr2) {
auto now = itr1;
while (now < itr2) {
cout << *now << " ";
now++;
}
cout << endl;
}
#define repr(i, from, to) for (int i = (int)from; i < (int)to; i++)
#define rep(i, N) repr(i, 0, N)
#define per(i, N) for (int i = (int)N - 1; i >= 0; i--)
const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
int main() {
ll N;
cin >> N;
double L;
cin >> L;
double T[(int)L];
rep(i, N) cin >> T[i];
double rx = 0, ry = 0;
rep(i, N) repr(j, i + 1, N) {
double theta1 = ((double)(T[i] + T[j]) / 2) * M_PI * 2 / L;
double theta2 = (theta1 < M_PI) ? theta1 + M_PI : theta1 - M_PI;
// cout << theta1 << "->" << (N+i)-j-1 << " ";
// cout << theta2 << "->" << j-i-1 << endl;
rx += cos(theta1) * ((N + i) - j - 1) + cos(theta2) * (j - i - 1);
ry += sin(theta1) * ((N + i) - j - 1) + sin(theta2) * (j - i - 1);
}
rx /= N * (N - 1) * (N - 2) / 6;
ry /= N * (N - 1) * (N - 2) / 6;
cout << fixed << setprecision(10) << rx << " " << ry << endl;
// cout << result << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
template <class T> void debug(T itr1, T itr2) {
auto now = itr1;
while (now < itr2) {
cout << *now << " ";
now++;
}
cout << endl;
}
#define repr(i, from, to) for (int i = (int)from; i < (int)to; i++)
#define rep(i, N) repr(i, 0, N)
#define per(i, N) for (int i = (int)N - 1; i >= 0; i--)
const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
int main() {
ll N;
cin >> N;
double L;
cin >> L;
double T[N];
rep(i, N) cin >> T[i];
double rx = 0, ry = 0;
rep(i, N) repr(j, i + 1, N) {
double theta1 = ((double)(T[i] + T[j]) / 2) * M_PI * 2 / L;
double theta2 = (theta1 < M_PI) ? theta1 + M_PI : theta1 - M_PI;
// cout << theta1 << "->" << (N+i)-j-1 << " ";
// cout << theta2 << "->" << j-i-1 << endl;
rx += cos(theta1) * ((N + i) - j - 1) + cos(theta2) * (j - i - 1);
ry += sin(theta1) * ((N + i) - j - 1) + sin(theta2) * (j - i - 1);
}
rx /= N * (N - 1) * (N - 2) / 6;
ry /= N * (N - 1) * (N - 2) / 6;
cout << fixed << setprecision(10) << rx << " " << ry << endl;
// cout << result << endl;
return 0;
} | replace | 27 | 28 | 27 | 28 | 0 | |
p02895 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for (int i = s; i < t; i++)
typedef long long ll;
ll dp[22][22][22], isused[22][22][22];
char isok[22][22];
ll solve(int l, int mid, int r) {
if (r - l <= 0)
return 1;
if (mid <= l || mid >= r)
return 0;
if (isused[l][mid][r])
return dp[l][mid][r];
isused[l][mid][r] = 1;
rep(i, l, mid) rep(j, mid + 1, r + 1) if (isok[i][j] == '1') rep(k1, i, mid)
rep(k2, mid, j) dp[l][mid][r] +=
solve(l, i, k1) * solve(k1 + 1, mid, k2) * solve(k2 + 1, j, r);
return dp[l][mid][r];
}
int main() {
int n;
scanf("%d", &n);
rep(i, 1, n * 2 + 1) scanf("%s", isok[i] + 1);
ll res = 0;
rep(i, 2, n * 2 + 1) if (isok[1][i] == '1') res += solve(2, i, n * 2);
printf("%lld\n", res);
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for (int i = s; i < t; i++)
typedef long long ll;
ll dp[44][44][44], isused[44][44][44];
char isok[44][44];
ll solve(int l, int mid, int r) {
if (r - l <= 0)
return 1;
if (mid <= l || mid >= r)
return 0;
if (isused[l][mid][r])
return dp[l][mid][r];
isused[l][mid][r] = 1;
rep(i, l, mid) rep(j, mid + 1, r + 1) if (isok[i][j] == '1') rep(k1, i, mid)
rep(k2, mid, j) dp[l][mid][r] +=
solve(l, i, k1) * solve(k1 + 1, mid, k2) * solve(k2 + 1, j, r);
return dp[l][mid][r];
}
int main() {
int n;
scanf("%d", &n);
rep(i, 1, n * 2 + 1) scanf("%s", isok[i] + 1);
ll res = 0;
rep(i, 2, n * 2 + 1) if (isok[1][i] == '1') res += solve(2, i, n * 2);
printf("%lld\n", res);
} | replace | 4 | 6 | 4 | 6 | 0 | |
p02895 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
const int N = 45;
char e[N][N];
int n;
ll f[N][N][N], g[N][N][N];
inline void modify(ri i, ri j, ri k) {
for (ri p = j + 1; p < n; ++p)
if (e[p][k])
g[i][j][p] += f[i][j][k];
}
int main() {
ri l, i, j, k, p, q, y;
rll res, ans;
scanf("%d", &n);
n <<= 1;
for (i = 1; i <= n; ++i) {
scanf("%s", e[i] + 1);
for (j = 1; j <= n; ++j)
e[i][j] &= 15;
}
if (n == 2)
return printf("%d\n", e[1][2]);
for (i = 1; i <= n; ++i)
f[i][i][i] = 1, modify(i, i, i);
for (i = 1; i + 2 <= n; ++i)
if (e[i][i + 2])
f[i][i + 2][i + 1] = 1, modify(i, i + 2, i + 1);
for (l = 4; l < n; ++l)
for (i = 1; (j = i + l - 1) <= n; ++i) {
for (p = i; p <= j - 2; ++p)
for (q = p + 2; q <= j; ++q) {
res = 0;
for (y = (q != j); y <= j - (q != j); ++y)
res += g[i][p][y] * f[q][j][y];
for (k = p + 1; k < q; ++k)
f[i][j][k] += res * f[p + 1][q - 1][k];
}
for (k = i + 1; k < j; ++k)
modify(i, j, k);
}
ans = 0;
for (i = 1; i < n; ++i)
if (e[n][i])
ans += f[1][n - 1][i];
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
const int N = 45;
char e[N][N];
int n;
ll f[N][N][N], g[N][N][N];
inline void modify(ri i, ri j, ri k) {
for (ri p = j + 1; p < n; ++p)
if (e[p][k])
g[i][j][p] += f[i][j][k];
}
int main() {
ri l, i, j, k, p, q, y;
rll res, ans;
scanf("%d", &n);
n <<= 1;
for (i = 1; i <= n; ++i) {
scanf("%s", e[i] + 1);
for (j = 1; j <= n; ++j)
e[i][j] &= 15;
}
if (n == 2)
return printf("%d\n", e[1][2]), 0;
for (i = 1; i <= n; ++i)
f[i][i][i] = 1, modify(i, i, i);
for (i = 1; i + 2 <= n; ++i)
if (e[i][i + 2])
f[i][i + 2][i + 1] = 1, modify(i, i + 2, i + 1);
for (l = 4; l < n; ++l)
for (i = 1; (j = i + l - 1) <= n; ++i) {
for (p = i; p <= j - 2; ++p)
for (q = p + 2; q <= j; ++q) {
res = 0;
for (y = (q != j); y <= j - (q != j); ++y)
res += g[i][p][y] * f[q][j][y];
for (k = p + 1; k < q; ++k)
f[i][j][k] += res * f[p + 1][q - 1][k];
}
for (k = i + 1; k < j; ++k)
modify(i, j, k);
}
ans = 0;
for (i = 1; i < n; ++i)
if (e[n][i])
ans += f[1][n - 1][i];
printf("%lld\n", ans);
return 0;
} | replace | 25 | 26 | 25 | 26 | 0 | |
p02895 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 22;
int n;
string s[N];
typedef long long ll;
ll ans, f[N][N][N], g[N][N][N][N];
ll F(int l, int r, int p);
ll G(int a, int b, int c, int d) {
if (~g[a][b][c][d])
return g[a][b][c][d];
ll ret = 0;
for (int i = a; i <= b; i++) {
for (int j = c; j <= d; j++)
if (s[i][j] == '1') {
ret += F(a, b, i) * F(c, d, j);
}
}
return g[a][b][c][d] = ret;
}
ll F(int l, int r, int p) {
if (l == r)
return 1;
if (~f[l][r][p])
return f[l][r][p];
ll ret = 0;
for (int i = l + 1; i <= p; i++) {
for (int j = p; j < r; j++) {
ret += G(l, i - 1, j + 1, r) * F(i, j, p);
}
}
return f[l][r][p] = ret;
}
int main() {
memset(f, -1, sizeof f);
memset(g, -1, sizeof g);
cin >> n;
n <<= 1;
for (int i = 0; i < n; i++) {
cin >> s[i];
}
for (int p = 1; p < n; p++)
if (s[0][p] == '1') {
ans += F(1, n - 1, p);
}
printf("%lld\n", ans);
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 42;
int n;
string s[N];
typedef long long ll;
ll ans, f[N][N][N], g[N][N][N][N];
ll F(int l, int r, int p);
ll G(int a, int b, int c, int d) {
if (~g[a][b][c][d])
return g[a][b][c][d];
ll ret = 0;
for (int i = a; i <= b; i++) {
for (int j = c; j <= d; j++)
if (s[i][j] == '1') {
ret += F(a, b, i) * F(c, d, j);
}
}
return g[a][b][c][d] = ret;
}
ll F(int l, int r, int p) {
if (l == r)
return 1;
if (~f[l][r][p])
return f[l][r][p];
ll ret = 0;
for (int i = l + 1; i <= p; i++) {
for (int j = p; j < r; j++) {
ret += G(l, i - 1, j + 1, r) * F(i, j, p);
}
}
return f[l][r][p] = ret;
}
int main() {
memset(f, -1, sizeof f);
memset(g, -1, sizeof g);
cin >> n;
n <<= 1;
for (int i = 0; i < n; i++) {
cin >> s[i];
}
for (int p = 1; p < n; p++)
if (s[0][p] == '1') {
ans += F(1, n - 1, p);
}
printf("%lld\n", ans);
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02895 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
char mp[41][45];
int n;
long long dp[41][41][41][41], dp2[41][41][41][41];
long long calc_dp2(int l, int r, int ll, int rr);
long long calc_dp(int l, int r, int ll, int rr);
long long calc_dp(int l, int r, int ll, int rr) {
if (dp[l][r][ll][rr] != -1)
return dp[l][r][ll][rr];
// do something plz
dp[l][r][ll][rr] = 0;
for (int p = l; p <= r; ++p)
for (int q = ll; q <= rr; ++q)
dp[l][r][ll][rr] += (mp[p][q] - '0') * calc_dp2(l, p - 1, p + 1, r) *
calc_dp2(ll, q - 1, q + 1, rr);
return dp[l][r][ll][rr];
}
long long calc_dp2(int l, int r, int ll, int rr) {
if (dp2[l][r][ll][rr] != -1)
return dp2[l][r][ll][rr];
// also do something plz
dp2[l][r][ll][rr] = 0;
for (int p = l; p <= r; ++p)
for (int q = ll; q <= rr; ++q)
dp2[l][r][ll][rr] += calc_dp(l, p, q, rr) * calc_dp2(p + 1, r, ll, q - 1);
return dp2[l][r][ll][rr];
}
int main() {
scanf("%d", &n);
n *= 2;
for (int i = 1; i <= n; ++i)
scanf("%s", mp[i] + 1);
memset(dp, -1, sizeof(dp));
memset(dp2, -1, sizeof(dp2));
for (int i = 1; i <= n + 1; ++i)
for (int j = 1; j <= n + 1; ++j)
dp[i][i - 1][j][j - 1] = dp2[i][i - 1][j][j - 1] = 1;
long long as = 0;
for (int i = 2; i <= n; ++i)
if (mp[1][i] == '1')
as += calc_dp2(2, i - 1, i + 1, n);
printf("%lld\n", as);
} | #include <bits/stdc++.h>
using namespace std;
char mp[41][45];
int n;
long long dp[42][42][42][42], dp2[42][42][42][42];
long long calc_dp2(int l, int r, int ll, int rr);
long long calc_dp(int l, int r, int ll, int rr);
long long calc_dp(int l, int r, int ll, int rr) {
if (dp[l][r][ll][rr] != -1)
return dp[l][r][ll][rr];
// do something plz
dp[l][r][ll][rr] = 0;
for (int p = l; p <= r; ++p)
for (int q = ll; q <= rr; ++q)
dp[l][r][ll][rr] += (mp[p][q] - '0') * calc_dp2(l, p - 1, p + 1, r) *
calc_dp2(ll, q - 1, q + 1, rr);
return dp[l][r][ll][rr];
}
long long calc_dp2(int l, int r, int ll, int rr) {
if (dp2[l][r][ll][rr] != -1)
return dp2[l][r][ll][rr];
// also do something plz
dp2[l][r][ll][rr] = 0;
for (int p = l; p <= r; ++p)
for (int q = ll; q <= rr; ++q)
dp2[l][r][ll][rr] += calc_dp(l, p, q, rr) * calc_dp2(p + 1, r, ll, q - 1);
return dp2[l][r][ll][rr];
}
int main() {
scanf("%d", &n);
n *= 2;
for (int i = 1; i <= n; ++i)
scanf("%s", mp[i] + 1);
memset(dp, -1, sizeof(dp));
memset(dp2, -1, sizeof(dp2));
for (int i = 1; i <= n + 1; ++i)
for (int j = 1; j <= n + 1; ++j)
dp[i][i - 1][j][j - 1] = dp2[i][i - 1][j][j - 1] = 1;
long long as = 0;
for (int i = 2; i <= n; ++i)
if (mp[1][i] == '1')
as += calc_dp2(2, i - 1, i + 1, n);
printf("%lld\n", as);
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02895 | C++ | Runtime Error | #include <iostream>
using namespace std;
typedef long long ll;
const int MAX_N = 25;
ll dp[MAX_N][MAX_N][MAX_N];
ll can[MAX_N][MAX_N];
int main() {
int n;
cin >> n;
n *= 2;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
char c;
cin >> c;
can[i][j] = c - '0';
}
}
for (int k = 0; k < n; k += 2) {
for (int l = 0; l < n; l++) {
int r = (l + k) % n;
for (int m = l; true; m = (m + 1) % n) {
if (m == l || m == r) {
if (l == r) {
dp[l][r][m] = 1;
}
} else {
for (int p = l; p != m && (m + 1) % n != p; p = (p + 2) % n) {
int sq = m;
if (sq % 2 == l % 2) {
sq = (sq + 1) % n;
}
for (int q = sq; true; q = (q + 2) % n) {
for (int a = l; true; a = (a + 1) % n) {
for (int b = (q + 1) % n; true; b = (b + 1) % n) {
if (can[a][b]) {
dp[l][r][m] += dp[l][p][a] * dp[(p + 1) % n][q][m] *
dp[(q + 1) % n][r][b];
}
if (b == r)
break;
}
if (a == p)
break;
}
if (q == r || (q + 1) % n == r)
break;
}
}
}
if (m == r)
break;
}
}
}
ll ans = 0;
for (int m = 1; m < n; m++) {
if (can[0][m]) {
ans += dp[1][n - 1][m];
}
}
cout << ans << endl;
}
| #include <iostream>
using namespace std;
typedef long long ll;
const int MAX_N = 45;
ll dp[MAX_N][MAX_N][MAX_N];
ll can[MAX_N][MAX_N];
int main() {
int n;
cin >> n;
n *= 2;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
char c;
cin >> c;
can[i][j] = c - '0';
}
}
for (int k = 0; k < n; k += 2) {
for (int l = 0; l < n; l++) {
int r = (l + k) % n;
for (int m = l; true; m = (m + 1) % n) {
if (m == l || m == r) {
if (l == r) {
dp[l][r][m] = 1;
}
} else {
for (int p = l; p != m && (m + 1) % n != p; p = (p + 2) % n) {
int sq = m;
if (sq % 2 == l % 2) {
sq = (sq + 1) % n;
}
for (int q = sq; true; q = (q + 2) % n) {
for (int a = l; true; a = (a + 1) % n) {
for (int b = (q + 1) % n; true; b = (b + 1) % n) {
if (can[a][b]) {
dp[l][r][m] += dp[l][p][a] * dp[(p + 1) % n][q][m] *
dp[(q + 1) % n][r][b];
}
if (b == r)
break;
}
if (a == p)
break;
}
if (q == r || (q + 1) % n == r)
break;
}
}
}
if (m == r)
break;
}
}
}
ll ans = 0;
for (int m = 1; m < n; m++) {
if (can[0][m]) {
ans += dp[1][n - 1][m];
}
}
cout << ans << endl;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02895 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 25;
long long dp[MAXN][MAXN][MAXN];
int A[MAXN][MAXN];
char S[MAXN];
int n;
long long ans;
long long getAns(int l, int r, int c) {
if (dp[l][r][c] != -1)
return dp[l][r][c];
if (l == r)
return dp[l][r][c] = 1;
if (l == c || r == c)
return dp[l][r][c] = 0;
long long &res = dp[l][r][c];
res = 0;
for (int limL = l; limL < c; ++limL)
for (int limR = c + 1; limR <= r; ++limR)
if (A[limL][limR])
for (int lP = limL; lP < c; ++lP)
for (int rP = c + 1; rP <= limR; ++rP)
res += getAns(l, lP, limL) * getAns(lP + 1, rP - 1, c) *
getAns(rP, r, limR);
// printf("(%d, %d, %d, %lld)\n", l, r, c, res);
return res;
}
int main(void) {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
n <<= 1;
for (int i = 1; i <= n && (cin >> (S + 1)); ++i)
for (int j = 1; j <= n; ++j)
A[i][j] = S[j] - '0';
memset(dp, -1, sizeof dp);
for (int i = 2; i <= n; ++i)
if (A[1][i])
ans += getAns(2, n, i);
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
long long dp[MAXN][MAXN][MAXN];
int A[MAXN][MAXN];
char S[MAXN];
int n;
long long ans;
long long getAns(int l, int r, int c) {
if (dp[l][r][c] != -1)
return dp[l][r][c];
if (l == r)
return dp[l][r][c] = 1;
if (l == c || r == c)
return dp[l][r][c] = 0;
long long &res = dp[l][r][c];
res = 0;
for (int limL = l; limL < c; ++limL)
for (int limR = c + 1; limR <= r; ++limR)
if (A[limL][limR])
for (int lP = limL; lP < c; ++lP)
for (int rP = c + 1; rP <= limR; ++rP)
res += getAns(l, lP, limL) * getAns(lP + 1, rP - 1, c) *
getAns(rP, r, limR);
// printf("(%d, %d, %d, %lld)\n", l, r, c, res);
return res;
}
int main(void) {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
n <<= 1;
for (int i = 1; i <= n && (cin >> (S + 1)); ++i)
for (int j = 1; j <= n; ++j)
A[i][j] = S[j] - '0';
memset(dp, -1, sizeof dp);
for (int i = 2; i <= n; ++i)
if (A[1][i])
ans += getAns(2, n, i);
cout << ans << '\n';
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02895 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
struct Debug {
int cnt = 0;
bool on = false;
char debug[10] = "debug";
template <class T> Debug &operator<<(const T &v) {
if (on && cnt++ == 0)
cerr << "debug: ";
if (on)
cerr << v << ' ';
return *this;
}
Debug &operator<<(ostream &(*pManip)(ostream &)) {
if (on)
cerr << (*pManip);
cnt = 0;
return *this;
}
} debug;
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep(i, a, b) for (auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) \
{ \
if (debug.on) { \
for (auto x : v) \
debug << x; \
debug << endl; \
} \
}
#define printn(v, n) \
{ \
if (debug.on) { \
for (int _i = 0; _i < n; _i++) \
debug << *(v + _i); \
debug << endl; \
} \
}
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
const int MAXN = 20 + 10;
int n;
string a[MAXN];
long long dp[MAXN][MAXN][MAXN];
long long dp_cal(int i, int j, int k) {
if (dp[i][j][k] >= 0)
return dp[i][j][k];
if (i == j && k == j)
return dp[i][j][k] = 1;
// if(i + 1 >= j || k - 1 <= j) return dp[i][j][k] = 0;
long long res = 0;
for (int ii = i; ii < j; ii++) {
for (int jj = k; jj > j; jj--) {
if (a[ii][jj] == '0')
continue;
for (int iii = ii; iii < j; iii++) {
for (int jjj = jj; jjj > j; jjj--) {
res += dp_cal(i, ii, iii) * dp_cal(iii + 1, j, jjj - 1) *
dp_cal(jjj, jj, k);
}
}
}
}
// debug << i << j << k << res << endl;
return dp[i][j][k] = res;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
if (argc > 1 && !strcmp(argv[1], debug.debug))
debug.on = true;
cin >> n;
n *= 2;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
dp[i][j][k] = -1;
long long res = 0;
for (int i = 1; i <= n - 1; i++) {
// debug << 0 << i << n - 1 << endl;
if (a[0][i] == '1')
res += dp_cal(1, i, n - 1);
}
cout << res << endl;
return 0;
}
| #include <algorithm>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
struct Debug {
int cnt = 0;
bool on = false;
char debug[10] = "debug";
template <class T> Debug &operator<<(const T &v) {
if (on && cnt++ == 0)
cerr << "debug: ";
if (on)
cerr << v << ' ';
return *this;
}
Debug &operator<<(ostream &(*pManip)(ostream &)) {
if (on)
cerr << (*pManip);
cnt = 0;
return *this;
}
} debug;
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep(i, a, b) for (auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) \
{ \
if (debug.on) { \
for (auto x : v) \
debug << x; \
debug << endl; \
} \
}
#define printn(v, n) \
{ \
if (debug.on) { \
for (int _i = 0; _i < n; _i++) \
debug << *(v + _i); \
debug << endl; \
} \
}
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
const int MAXN = 40 + 5;
int n;
string a[MAXN];
long long dp[MAXN][MAXN][MAXN];
long long dp_cal(int i, int j, int k) {
if (dp[i][j][k] >= 0)
return dp[i][j][k];
if (i == j && k == j)
return dp[i][j][k] = 1;
// if(i + 1 >= j || k - 1 <= j) return dp[i][j][k] = 0;
long long res = 0;
for (int ii = i; ii < j; ii++) {
for (int jj = k; jj > j; jj--) {
if (a[ii][jj] == '0')
continue;
for (int iii = ii; iii < j; iii++) {
for (int jjj = jj; jjj > j; jjj--) {
res += dp_cal(i, ii, iii) * dp_cal(iii + 1, j, jjj - 1) *
dp_cal(jjj, jj, k);
}
}
}
}
// debug << i << j << k << res << endl;
return dp[i][j][k] = res;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
if (argc > 1 && !strcmp(argv[1], debug.debug))
debug.on = true;
cin >> n;
n *= 2;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
dp[i][j][k] = -1;
long long res = 0;
for (int i = 1; i <= n - 1; i++) {
// debug << 0 << i << n - 1 << endl;
if (a[0][i] == '1')
res += dp_cal(1, i, n - 1);
}
cout << res << endl;
return 0;
}
| replace | 75 | 76 | 75 | 76 | 0 | |
p02896 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#define LL long long
#define LD long double
using namespace std;
const int NN = 117;
const int MM = 100 + 117;
int read() {
int fl = 1, x;
char c;
for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
;
if (c == '-') {
fl = -1;
c = getchar();
}
for (x = 0; c >= '0' && c <= '9'; c = getchar())
x = (x << 3) + (x << 1) + c - '0';
return x * fl;
}
void open() {
freopen("a.in", "r", stdin);
// freopen("a.out","w",stdout);
}
void close() {
fclose(stdin);
fclose(stdout);
}
int m, n, s;
LL dp[NN][NN][NN] = {};
LL tp[NN][NN] = {};
LL mod;
LL fact[NN] = {};
LL rev[NN] = {};
LL mi[NN][NN * NN] = {};
LL ksm(LL a, LL b) {
LL ret = 1;
for (; b; b >>= 1, a = a * a % mod)
if (b & 1)
ret = ret * a % mod;
return ret;
}
void prefact(int n) {
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i % mod;
}
rev[n] = ksm(fact[n], mod - 2);
for (int i = n; i >= 1; --i) {
rev[i - 1] = rev[i] * i % mod;
}
}
LL c[NN][NN] = {};
int main() {
open();
n = read();
m = read();
s = read();
mod = read();
prefact(max(n, m));
for (int i = 0; i <= s; ++i) {
mi[i][0] = 1;
for (int j = 1; j <= n * m; ++j) {
mi[i][j] = mi[i][j - 1] * i % mod;
}
}
dp[1][n][m] = 1;
for (int i = 1; i <= s; ++i) {
for (int j = 0; j <= n; ++j) {
for (int l = 0; l <= m; ++l) {
c[j][l] =
rev[l] * mi[i][j * l] % mod * mi[s - i + 1][(n - j) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
tp[j][k] = 0;
for (int l = 0; l + k <= m; ++l) {
tp[j][k] += dp[i][j][k + l] * c[j][l];
tp[j][k] %= mod;
}
}
}
for (int l = 0; l <= n; ++l) {
for (int k = 0; k <= m; ++k) {
c[l][k] =
rev[l] * mi[i][k * l] % mod * mi[s - i + 1][(m - k) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
dp[i][j][k] = 0;
for (int l = 0; l + j <= n; ++l) {
dp[i][j][k] += tp[j + l][k] * c[l][k];
dp[i][j][k] %= mod;
}
}
}
for (int j = 0; j <= n; ++j) {
for (int l = 0, sym = 1; l <= m; ++l, sym = -sym) {
c[j][l] =
rev[l] * mi[i][j * l] * sym % mod * mi[s - i][(n - j) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
tp[j][k] = 0;
for (int l = 0; l + k <= m; ++l) {
tp[j][k] += dp[i][j][k + l] * c[j][l];
tp[j][k] %= mod;
}
}
}
for (int l = 0, sym = 1; l <= n; ++l, sym = -sym) {
for (int k = 0; k <= m; ++k) {
c[l][k] =
rev[l] * mi[i][k * l] * sym % mod * mi[s - i][(m - k) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
dp[i + 1][j][k] = 0;
for (int l = 0; l + j <= n; ++l) {
dp[i + 1][j][k] += tp[j + l][k] * c[l][k];
dp[i + 1][j][k] %= mod;
}
}
}
}
LL ans = dp[s + 1][0][0] * fact[n] % mod * fact[m] % mod;
ans = (ans + mod) % mod;
printf("%lld\n", ans);
close();
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#define LL long long
#define LD long double
using namespace std;
const int NN = 117;
const int MM = 100 + 117;
int read() {
int fl = 1, x;
char c;
for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
;
if (c == '-') {
fl = -1;
c = getchar();
}
for (x = 0; c >= '0' && c <= '9'; c = getchar())
x = (x << 3) + (x << 1) + c - '0';
return x * fl;
}
void open() {
freopen("a.in", "r", stdin);
// freopen("a.out","w",stdout);
}
void close() {
fclose(stdin);
fclose(stdout);
}
int m, n, s;
LL dp[NN][NN][NN] = {};
LL tp[NN][NN] = {};
LL mod;
LL fact[NN] = {};
LL rev[NN] = {};
LL mi[NN][NN * NN] = {};
LL ksm(LL a, LL b) {
LL ret = 1;
for (; b; b >>= 1, a = a * a % mod)
if (b & 1)
ret = ret * a % mod;
return ret;
}
void prefact(int n) {
fact[0] = 1;
for (int i = 1; i <= n; ++i) {
fact[i] = fact[i - 1] * i % mod;
}
rev[n] = ksm(fact[n], mod - 2);
for (int i = n; i >= 1; --i) {
rev[i - 1] = rev[i] * i % mod;
}
}
LL c[NN][NN] = {};
int main() {
// open();
n = read();
m = read();
s = read();
mod = read();
prefact(max(n, m));
for (int i = 0; i <= s; ++i) {
mi[i][0] = 1;
for (int j = 1; j <= n * m; ++j) {
mi[i][j] = mi[i][j - 1] * i % mod;
}
}
dp[1][n][m] = 1;
for (int i = 1; i <= s; ++i) {
for (int j = 0; j <= n; ++j) {
for (int l = 0; l <= m; ++l) {
c[j][l] =
rev[l] * mi[i][j * l] % mod * mi[s - i + 1][(n - j) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
tp[j][k] = 0;
for (int l = 0; l + k <= m; ++l) {
tp[j][k] += dp[i][j][k + l] * c[j][l];
tp[j][k] %= mod;
}
}
}
for (int l = 0; l <= n; ++l) {
for (int k = 0; k <= m; ++k) {
c[l][k] =
rev[l] * mi[i][k * l] % mod * mi[s - i + 1][(m - k) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
dp[i][j][k] = 0;
for (int l = 0; l + j <= n; ++l) {
dp[i][j][k] += tp[j + l][k] * c[l][k];
dp[i][j][k] %= mod;
}
}
}
for (int j = 0; j <= n; ++j) {
for (int l = 0, sym = 1; l <= m; ++l, sym = -sym) {
c[j][l] =
rev[l] * mi[i][j * l] * sym % mod * mi[s - i][(n - j) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
tp[j][k] = 0;
for (int l = 0; l + k <= m; ++l) {
tp[j][k] += dp[i][j][k + l] * c[j][l];
tp[j][k] %= mod;
}
}
}
for (int l = 0, sym = 1; l <= n; ++l, sym = -sym) {
for (int k = 0; k <= m; ++k) {
c[l][k] =
rev[l] * mi[i][k * l] * sym % mod * mi[s - i][(m - k) * l] % mod;
}
}
for (int j = 0; j <= n; ++j) {
for (int k = 0; k <= m; ++k) {
dp[i + 1][j][k] = 0;
for (int l = 0; l + j <= n; ++l) {
dp[i + 1][j][k] += tp[j + l][k] * c[l][k];
dp[i + 1][j][k] %= mod;
}
}
}
}
LL ans = dp[s + 1][0][0] * fact[n] % mod * fact[m] % mod;
ans = (ans + mod) % mod;
printf("%lld\n", ans);
close();
return 0;
}
| replace | 61 | 62 | 61 | 62 | TLE | |
p02897 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define speed \
ios::sync_with_stdio(0); \
cin.tie(0);
void input() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
}
/*****************************************************************************/
int main() {
input();
speed
int q;
cin >> q;
double sum = 0;
for (int i = 1; i <= q; i++) {
if (i % 2 == 1)
sum++;
}
double ans = sum / q * 1.0;
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define speed \
ios::sync_with_stdio(0); \
cin.tie(0);
void input() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
}
/*****************************************************************************/
int main() {
// input();
speed
int q;
cin >> q;
double sum = 0;
for (int i = 1; i <= q; i++) {
if (i % 2 == 1)
sum++;
}
double ans = sum / q * 1.0;
cout << ans;
return 0;
} | replace | 14 | 15 | 14 | 15 | 0 | |
p02897 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9 + 7;
ll const maxn = 4e5 + 5;
ll const inf = 1e18;
ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
ll powm(ll x, ll n, ll M) {
ll result = 1;
while (n > 0) {
if (n % 2 == 1)
result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
ll ans = ceil((n * 1.0) / 2);
long double x = (ans * 1.0) / n;
cout << fixed << setprecision(10) << x << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9 + 7;
ll const maxn = 4e5 + 5;
ll const inf = 1e18;
ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
ll powm(ll x, ll n, ll M) {
ll result = 1;
while (n > 0) {
if (n % 2 == 1)
result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
ll ans = ceil((n * 1.0) / 2);
long double x = (ans * 1.0) / n;
cout << fixed << setprecision(10) << x << "\n";
return 0;
}
| replace | 19 | 23 | 19 | 23 | 0 | |
p02897 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST \
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); \
srand(time(NULL))
int main() {
ll odd = 0, even = 0;
ll n;
cin >> n;
for (ll i = 1; i <= n; i++) {
if (i % 2)
odd++;
else
even++;
}
ld ans = odd / even;
cout << fixed << setprecision(12) << ans;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST \
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); \
srand(time(NULL))
int main() {
ll odd = 0, even = 0;
ll n;
cin >> n;
for (ll i = 1; i <= n; i++) {
if (i % 2)
odd++;
else
even++;
}
ld ans = odd / (ld)n;
cout << fixed << setprecision(12) << ans;
} | replace | 22 | 23 | 22 | 23 | 0 | |
p02897 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define forr(i, t, n) for (int i = t; i < n; ++i)
#define rforr(i, t, n) (int i = n - 1; i >= t; --i)
#define rfor(i, n) for (int i = n - 1; i >= 0; --i)
#define rmod(x, y) (((x % y) + y) % y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;
// STRUCTS
// OPERATORS
// GLOBALS
// FUNCTIONS
// PROBLEM: odds of oddness
// LINK: https://atcoder.jp/contests/abc142/tasks/abc142_a
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("_input.txt", "r", stdin);
freopen("_output.txt", "w", stdout);
#endif
double n;
cin >> n;
double ans;
precision(7);
if (int(n) % 2) {
ans = ceil(n / 2);
ans /= n;
} else
ans = 1 / 2.00;
cout << ans;
return 0;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define forr(i, t, n) for (int i = t; i < n; ++i)
#define rforr(i, t, n) (int i = n - 1; i >= t; --i)
#define rfor(i, n) for (int i = n - 1; i >= 0; --i)
#define rmod(x, y) (((x % y) + y) % y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;
// STRUCTS
// OPERATORS
// GLOBALS
// FUNCTIONS
// PROBLEM: odds of oddness
// LINK: https://atcoder.jp/contests/abc142/tasks/abc142_a
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
double n;
cin >> n;
double ans;
precision(7);
if (int(n) % 2) {
ans = ceil(n / 2);
ans /= n;
} else
ans = 1 / 2.00;
cout << ans;
return 0;
} | delete | 49 | 53 | 49 | 49 | 0 | |
p02897 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
size_t n;
cin >> n;
double t = 0.0;
for (size_t i = 1; i <= n; ++i) {
if (i % 2 == 1)
t += 1.0;
}
auto c = t / double(n);
cout << c << endl;
return 1;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
size_t n;
cin >> n;
double t = 0.0;
for (size_t i = 1; i <= n; ++i) {
if (i % 2 == 1)
t += 1.0;
}
auto c = t / double(n);
cout << c << endl;
return 0;
} | replace | 22 | 23 | 22 | 23 | 1 | |
p02897 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define maxim (ll)1000000000000
#define PB push_back
#define MP make_pair
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// cin>>t;
while (t--) {
ll n;
cin >> n;
ld ans = (ld)((n / 2) + (n % 2)) / n;
cout << fixed << setprecision(10) << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define maxim (ll)1000000000000
#define PB push_back
#define MP make_pair
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// cin>>t;
while (t--) {
ll n;
cin >> n;
ld ans = (ld)((n / 2) + (n % 2)) / n;
cout << fixed << setprecision(10) << ans << endl;
}
return 0;
} | replace | 9 | 13 | 9 | 10 | 0 | |
p02897 | Python | Runtime Error | N = input()
if N % 2 == 0:
print((N / 2) / N)
else:
print(((N + 1) / 2) / N)
| N = int(input())
if N % 2 == 0:
print((N / 2) / N)
else:
print(((N + 1) / 2) / N)
| replace | 0 | 1 | 0 | 1 | TypeError: not all arguments converted during string formatting | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02897/Python/s639132796.py", line 3, in <module>
if N % 2 == 0:
TypeError: not all arguments converted during string formatting
|
p02897 | C++ | Runtime Error | #include <iostream>
int main() {
int n;
std::cin >> n;
return (n - n / 2) / (double)n;
} | #include <iostream>
int main() {
int n;
std::cin >> n;
std::cout << (n - n / 2) / (double)n;
} | replace | 5 | 7 | 5 | 6 | 0 | |
p02897 | C++ | Runtime Error | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
// #include"testlib.h"
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#else
// freopen("street.in", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
}
int main() {
file();
fast();
int n;
cin >> n;
cout << fixed << setprecision(6);
if (n & 1)
cout << (n / 2 + 1) / (double)n << endl;
else
cout << 0.5000000 << endl;
return 0;
} | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
// #include"testlib.h"
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#else
// freopen("street.in", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
}
int main() {
// file();
fast();
int n;
cin >> n;
cout << fixed << setprecision(6);
if (n & 1)
cout << (n / 2 + 1) / (double)n << endl;
else
cout << 0.5000000 << endl;
return 0;
} | replace | 38 | 39 | 38 | 39 | 0 | |
p02897 | C++ | Runtime Error | #include <iostream>
int main() {
int n;
std::cin >> n;
double ans;
if (n % 2 == 0)
ans = 0.5;
else
ans = (n / 2 + 1) / (n / 2);
std::cout << ans << std::endl;
return 0;
} | #include <iostream>
int main() {
int n;
std::cin >> n;
double ans;
if (n % 2 == 0)
ans = 0.5;
else
ans = (double)(n / 2 + 1) / (double)n;
std::cout << ans << std::endl;
return 0;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p02897 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define per(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define per1(i, n) for (int i = int(n); i > 0; i--)
#define foreach(i, n) for (auto &&i : n)
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) \
int x; \
cin >> x
#define cill(x) \
LL x; \
cin >> x
#define cis(x) \
string x; \
cin >> x
#define co(x) cout << x << endl
#define dump(x) cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() \
cin.tie(0); \
ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
int main() {
fastcin();
cout << fixed << setprecision(10);
cii(n);
double ans = (n % 2 == 0) ? 0.5 : (n / 2 + 1) / (n / 2);
co(ans);
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define per(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define per1(i, n) for (int i = int(n); i > 0; i--)
#define foreach(i, n) for (auto &&i : n)
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) \
int x; \
cin >> x
#define cill(x) \
LL x; \
cin >> x
#define cis(x) \
string x; \
cin >> x
#define co(x) cout << x << endl
#define dump(x) cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() \
cin.tie(0); \
ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
int main() {
fastcin();
cout << fixed << setprecision(10);
cii(n);
double ans = (n % 2 == 0) ? 0.5 : (n / 2 + 1) / (double)n;
co(ans);
return 0;
} | replace | 61 | 62 | 61 | 62 | 0 | |
p02897 | Python | Runtime Error | N = int(input())
nums = filter(lambda x: x % 2 != 0, range(1, N + 1))
print(len(nums) / float(N))
| N = int(input())
odds = list(filter(lambda x: x % 2 != 0, range(1, N + 1)))
print("{:.10f}".format(len(odds) / float(N)))
| replace | 1 | 3 | 1 | 3 | TypeError: object of type 'filter' has no len() | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02897/Python/s177857539.py", line 3, in <module>
print(len(nums) / float(N))
TypeError: object of type 'filter' has no len()
|
p02897 | Python | Runtime Error | n = int(input())
odd = (n + 1) // 2
ans = odd / n
print(f"{ans:.9f}")
| n = int(input())
odd = (n + 1) // 2
ans = odd / n
print("{:.9f}".format(ans))
| replace | 4 | 5 | 4 | 5 | 0 | |
p02897 | C++ | Runtime Error | #include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
#define int long long int
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define dbg(x) \
{ cerr << "> " << #x << ": " << x << endl; }
#define dbg2(x, y) \
{ cerr << "> " << #x << ": " << x << " , " << #y << ": " << y << endl; }
#define dbg3(x, y, z) \
{ \
cerr << "> " << #x << ": " << x << " , " << #y << ": " << y << " , " << #z \
<< ": " << z << endl; \
}
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
signed main() {
IOS;
int n;
cin >> n;
cout << fixed << setprecision(10) << (n + 1) / 2 / (n / 2);
return 0;
} | #include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
#define int long long int
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define dbg(x) \
{ cerr << "> " << #x << ": " << x << endl; }
#define dbg2(x, y) \
{ cerr << "> " << #x << ": " << x << " , " << #y << ": " << y << endl; }
#define dbg3(x, y, z) \
{ \
cerr << "> " << #x << ": " << x << " , " << #y << ": " << y << " , " << #z \
<< ": " << z << endl; \
}
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
signed main() {
IOS;
int n;
cin >> n;
int a = (n + 1) / 2;
int b = n / 2;
cout << fixed << setprecision(10) << (double)a / n;
return 0;
} | replace | 35 | 36 | 35 | 38 | 0 | |
p02898 | Python | Runtime Error | # -*- coding: utf-8 -*-
n, k = map(int, input().split())
cnt = 0
h = list(map(int, input().split()))
for high in h:
if h >= k:
cnt += 1
print(cnt)
| # -*- coding: utf-8 -*-
n, k = map(int, input().split())
cnt = 0
h = list(map(int, input().split()))
for high in h:
if high >= k:
cnt += 1
print(cnt)
| replace | 8 | 9 | 8 | 9 | TypeError: '>=' not supported between instances of 'list' and 'int' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s184020467.py", line 9, in <module>
if h >= k:
TypeError: '>=' not supported between instances of 'list' and 'int'
|
p02898 | Python | Runtime Error | n, k = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
for i in n:
if H[i] >= k:
cnt += 1
print(cnt)
| n, k = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
for i in range(n):
if H[i] >= k:
cnt += 1
print(cnt)
| replace | 3 | 4 | 3 | 4 | TypeError: 'int' object is not iterable | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s127858228.py", line 4, in <module>
for i in n:
TypeError: 'int' object is not iterable
|
p02898 | Python | Runtime Error | n, k = map(int, input().split())
h = list(map(int, input().split()))
print(len(filter(lambda x: x >= k, h)))
| n, k = map(int, input().split())
h = list(map(int, input().split()))
print(len(list(filter(lambda x: x >= k, h))))
| replace | 2 | 3 | 2 | 3 | TypeError: object of type 'filter' has no len() | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s747999474.py", line 3, in <module>
print(len(filter(lambda x: x >= k, h)))
TypeError: object of type 'filter' has no len()
|
p02898 | Python | Runtime Error | N = int(input())
K = int(input())
h = list(map(int, input().split()))
count = 0
for i in h:
if i >= K:
count += 1
print(count)
| N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
count = 0
for i in h:
if i >= K:
count += 1
print(count)
| replace | 0 | 2 | 0 | 1 | ValueError: invalid literal for int() with base 10: '4 150' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s129159641.py", line 1, in <module>
N = int(input())
ValueError: invalid literal for int() with base 10: '4 150'
|
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k, cnt = 0;
int v[501];
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> v[i];
if (v[i] >= k)
cnt++;
}
cout << cnt << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n, k, cnt = 0;
int v[1000000];
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> v[i];
if (v[i] >= k)
cnt++;
}
cout << cnt << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
#include <vector>
#define rep(i, n) \
for (int i = 0; i < n; i++) \
;
using namespace std;
int main() {
int N, K;
vector<int> A(500);
cin >> N >> K;
int count = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] > K - 1) {
count++;
}
}
cout << count << endl;
return 0;
}
| #include <iostream>
#include <vector>
#define rep(i, n) \
for (int i = 0; i < n; i++) \
;
using namespace std;
int main() {
int N, K;
vector<int> A(100000);
cin >> N >> K;
int count = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] > K - 1) {
count++;
}
}
cout << count << endl;
return 0;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p02898 | Python | Runtime Error | N, K = map(int, input().split())
ar = list(map, input().split())
count = 0
for i in range(N):
if ar[i] >= K:
count += 1
print(count)
| N, K = map(int, input().split())
ar = list(map(int, input().split()))
count = 0
for i in range(N):
if ar[i] >= K:
count += 1
print(count)
| replace | 1 | 2 | 1 | 2 | TypeError: list expected at most 1 argument, got 2 | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s440277663.py", line 2, in <module>
ar = list(map, input().split())
TypeError: list expected at most 1 argument, got 2
|
p02898 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int N, K, h[500], count = 0;
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> h[i];
if (h[i] >= K) {
count++;
}
}
printf("%d", count);
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int N, K, h[100000], count = 0;
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> h[i];
if (h[i] >= K) {
count++;
}
}
printf("%d", count);
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, K;
cin >> N >> K;
ll h[501];
REP(i, N) cin >> h[i];
ll ans = 0;
REP(i, N) {
if (h[i] >= K)
++ans;
}
cout << ans << '\n';
return 0;
}
| #include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, K;
cin >> N >> K;
ll h[100100];
REP(i, N) cin >> h[i];
ll ans = 0;
REP(i, N) {
if (h[i] >= K)
++ans;
}
cout << ans << '\n';
return 0;
}
| replace | 34 | 35 | 34 | 35 | 0 | |
p02898 | Python | Runtime Error | n = int(input())
min_height = int(input())
height = []
for _ in range(n):
height.append(int(input()))
height.sort(reverse=True)
cnt = 0
for h in height:
if h < min_height:
break
cnt += 1
print(cnt)
| n, min_height = map(int, input().split())
height = list(map(int, input().split()))
height.sort(reverse=True)
cnt = 0
for h in height:
if h < min_height:
break
cnt += 1
print(cnt)
| replace | 0 | 6 | 0 | 2 | ValueError: invalid literal for int() with base 10: '4 150' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02898/Python/s709157737.py", line 1, in <module>
n = int(input())
ValueError: invalid literal for int() with base 10: '4 150'
|
p02898 | C++ | Runtime Error | #include <stdio.h>
int main() {
int r = 0, i, n, k, h[10010];
scanf("%d%d", &n, &k);
for (i = 1; i <= n; i++) {
scanf("%d", &h[i]);
}
for (i = 1; i <= n; i++) {
if (h[i] >= k) {
r++;
}
}
printf("%d", r);
return 0;
}
| #include <stdio.h>
int main() {
int r = 0, i, n, k, h[100100];
scanf("%d%d", &n, &k);
for (i = 1; i <= n; i++) {
scanf("%d", &h[i]);
}
for (i = 1; i <= n; i++) {
if (h[i] >= k) {
r++;
}
}
printf("%d", r);
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int, int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define GOODBYE \
do { \
cout << "No" << endl; \
return 0; \
} while (false)
#define MM << " " <<
#define Endl endl
signed main(void) {
int N, K, Ans = 0;
int h[514];
cin >> N >> K;
REP(i, N) { cin >> h[i]; }
REP(i, N) {
if (h[i] >= K)
Ans++;
}
cout << Ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int, int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define GOODBYE \
do { \
cout << "No" << endl; \
return 0; \
} while (false)
#define MM << " " <<
#define Endl endl
signed main(void) {
int N, K, Ans = 0;
int h[114514];
cin >> N >> K;
REP(i, N) { cin >> h[i]; }
REP(i, N) {
if (h[i] >= K)
Ans++;
}
cout << Ans << endl;
return 0;
}
| replace | 23 | 24 | 23 | 24 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 100100100;
using namespace std;
int main() {
int N, K;
int h[510];
int res = 0;
cin >> N >> K;
rep(i, N) cin >> h[i];
rep(i, N) {
if (h[i] >= K)
res++;
}
cout << res << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 100100100;
using namespace std;
int main() {
int N, K;
int h[110000];
int res = 0;
cin >> N >> K;
rep(i, N) cin >> h[i];
rep(i, N) {
if (h[i] >= K)
res++;
}
cout << res << endl;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#define FOR(i, m, M) for (int i = m; i < M; i++)
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int h[500];
bool flag = 0;
FOR(i, 0, N) { cin >> h[i]; }
sort(h, h + N, greater<int>());
FOR(j, 0, N) {
if (h[j] < K) {
cout << j << endl;
flag = 1;
break;
}
}
if (!flag)
cout << N << endl;
}
| #include <algorithm>
#include <iostream>
#define FOR(i, m, M) for (int i = m; i < M; i++)
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int h[100000];
bool flag = 0;
FOR(i, 0, N) { cin >> h[i]; }
sort(h, h + N, greater<int>());
FOR(j, 0, N) {
if (h[j] < K) {
cout << j << endl;
flag = 1;
break;
}
}
if (!flag)
cout << N << endl;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a[1000], count = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] >= k)
count++;
}
cout << count << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a[100005], count = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] >= k)
count++;
}
cout << count << endl;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int ans = 0;
int h[1000];
for (int i = 0; i < n; i++) {
cin >> h[i];
if (h[i] >= k) {
ans++;
}
}
cout << ans << endl;
} | #include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int ans = 0;
int h[n];
for (int i = 0; i < n; i++) {
cin >> h[i];
if (h[i] >= k) {
ans++;
}
}
cout << ans << endl;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
int h[550];
rep(i, n) { cin >> h[i]; }
int noreru = 0;
rep(j, n) {
if (h[j] >= k) {
noreru++;
}
}
cout << noreru << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
int h[n];
rep(i, n) { cin >> h[i]; }
int noreru = 0;
rep(j, n) {
if (h[j] >= k) {
noreru++;
}
}
cout << noreru << endl;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02898 | C++ | Runtime Error | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int N, K;
int h[500];
int count = 0;
cin >> N >> K;
for (int i = 0; i < N; i++)
cin >> h[i];
for (int i = 0; i < N; i++) {
if (h[i] >= K)
count++;
}
cout << count;
} | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int N, K;
int h[100000];
int count = 0;
cin >> N >> K;
for (int i = 0; i < N; i++)
cin >> h[i];
for (int i = 0; i < N; i++) {
if (h[i] >= K)
count++;
}
cout << count;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a[k];
for (int i = 0; i < n; i++)
cin >> a[i];
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i] >= k)
cnt++;
}
cout << cnt << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i] >= k)
cnt++;
}
cout << cnt << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, c = 0, i;
int h[500];
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> h[i];
}
for (i = 0; i < n; i++) {
if (h[i] >= k) {
c++;
}
}
cout << c << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, c = 0, i;
int h[100000];
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> h[i];
}
for (i = 0; i < n; i++) {
if (h[i] >= k) {
c++;
}
}
cout << c << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main(void) {
int n;
cin >> n;
int k;
cin >> k;
int j = 0;
int h[500];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = 0; i < n; i++) {
if (k <= h[i]) {
j++;
}
}
cout << j;
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
int n;
cin >> n;
int k;
cin >> k;
int j = 0;
int h[n];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = 0; i < n; i++) {
if (k <= h[i]) {
j++;
}
}
cout << j;
return 0;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int N, K;
int array[10000] = {};
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> array[i];
}
int cnt = 0;
for (int i = 0; i < N; i++) {
if (array[i] >= K) {
// 乗れる
cnt++;
}
}
cout << cnt << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int N, K;
int array[100000] = {};
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> array[i];
}
int cnt = 0;
for (int i = 0; i < N; i++) {
if (array[i] >= K) {
// 乗れる
cnt++;
}
}
cout << cnt << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int h[510];
int main() {
int N, K;
cin >> N >> K;
for (int i = 0; i < N; ++i) {
cin >> h[i];
}
int cnt = 0;
for (int i = 0; i < N; ++i) {
if (h[i] >= K)
cnt++;
}
cout << cnt << endl;
}
| #include <iostream>
using namespace std;
int h[100100];
int main() {
int N, K;
cin >> N >> K;
for (int i = 0; i < N; ++i) {
cin >> h[i];
}
int cnt = 0;
for (int i = 0; i < N; ++i) {
if (h[i] >= K)
cnt++;
}
cout << cnt << endl;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
int n, k, i, count;
vector<int> h(500);
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> h.at(i);
}
count = 0;
for (i = 0; i < n; i++) {
if (h.at(i) >= k)
count++;
}
cout << count << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
int n, k, i, count;
vector<int> h(100000);
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> h.at(i);
}
count = 0;
for (i = 0; i < n; i++) {
if (h.at(i) >= k)
count++;
}
cout << count << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int count = 0;
vector<int> wtf(K);
for (int i = 0; i < N; i++) {
cin >> wtf.at(i);
if (wtf.at(i) >= K) {
count++;
}
}
cout << count << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int count = 0;
vector<int> wtf(N);
for (int i = 0; i < N; i++) {
cin >> wtf.at(i);
if (wtf.at(i) >= K) {
count++;
}
}
cout << count << endl;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main(void) {
int N, K, h[500], a;
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> h[i];
}
a = 0;
for (int i = 1; i <= N; i++) {
if (h[i] >= K) {
a = a + 1;
}
}
cout << a << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
int N, K, h[100000], a;
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> h[i];
}
a = 0;
for (int i = 1; i <= N; i++) {
if (h[i] >= K) {
a = a + 1;
}
}
cout << a << endl;
return 0;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
int main() {
int n, k;
cin >> n >> k;
int h[k];
rep(i, n) cin >> h[i];
int ans = 0;
rep(i, n) {
if (h[i] >= k)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
int main() {
int n, k;
cin >> n >> k;
int h[n];
rep(i, n) cin >> h[i];
int ans = 0;
rep(i, n) {
if (h[i] >= k)
ans++;
}
cout << ans << endl;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
int N, K;
int height[100];
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> height[i];
}
int count = 0;
for (int i = 0; i < N; i++) {
if (height[i] >= K) {
count++;
}
}
cout << count << endl;
return 0;
}
| #include <iostream>
#include <string>
using namespace std;
int main() {
int N, K;
int height[100000];
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> height[i];
}
int count = 0;
for (int i = 0; i < N; i++) {
if (height[i] >= K) {
count++;
}
}
cout << count << endl;
return 0;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int h[500];
int result = 0;
for (int i = 0; i < N; i++) {
cin >> h[i];
if (h[i] >= K) {
result++;
}
}
cout << result << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int h[100000];
int result = 0;
for (int i = 0; i < N; i++) {
cin >> h[i];
if (h[i] >= K) {
result++;
}
}
cout << result << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int h[510];
for (int i = 0; i < n; i++)
cin >> h[i];
int cnt = 0;
for (int i = 0; i < n; i++) {
if (h[i] >= k)
cnt++;
}
cout << cnt << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int h[100010];
for (int i = 0; i < n; i++)
cin >> h[i];
int cnt = 0;
for (int i = 0; i < n; i++) {
if (h[i] >= k)
cnt++;
}
cout << cnt << endl;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int k;
cin >> k;
int ans = 0;
for (int i = 0; i < n; i++) {
int h;
cin >> h;
if (h >= k)
ans++;
}
return ans;
}
| #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int k;
cin >> k;
int ans = 0;
for (int i = 0; i < n; i++) {
int h;
cin >> h;
if (h >= k)
ans++;
}
cout << ans << endl;
}
| replace | 16 | 17 | 16 | 17 | 2 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64, i64>
#define all(x) x.begin(), x.end()
#define LB(x, v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int h[110];
int solve(int n, int k) {
int ans = 0;
for (int i = 0; i < n; i++)
if (h[i] >= k)
ans++;
return ans;
}
int main() {
/*BEFORE SUBMIT, CHECK
sample i/o format
statements for debugging are removed/comment out
global values / stl containers are initialized/cleared for each test (if
needed) all array size are sufficient loop variable or output value doesn't
cross min/max limit of input
// */
int n, k;
while (scanf("%d %d", &n, &k) == 2) {
for (int i = 0; i < n; i++)
scanf("%d", &h[i]);
printf("%d\n", solve(n, k));
}
return 0;
} | #include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64, i64>
#define all(x) x.begin(), x.end()
#define LB(x, v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int h[maxn + 2];
int solve(int n, int k) {
int ans = 0;
for (int i = 0; i < n; i++)
if (h[i] >= k)
ans++;
return ans;
}
int main() {
/*BEFORE SUBMIT, CHECK
sample i/o format
statements for debugging are removed/comment out
global values / stl containers are initialized/cleared for each test (if
needed) all array size are sufficient loop variable or output value doesn't
cross min/max limit of input
// */
int n, k;
while (scanf("%d %d", &n, &k) == 2) {
for (int i = 0; i < n; i++)
scanf("%d", &h[i]);
printf("%d\n", solve(n, k));
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define max 500
using namespace std;
int main() {
int n, k, i, ara[max], cnt = 0;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &ara[i]);
}
for (i = 0; i < n; i++) {
if (ara[i] >= k)
cnt++;
}
printf("%d", cnt);
}
| #include <bits/stdc++.h>
#define max 500
using namespace std;
int main() {
int n, k, i, ara[100005], cnt = 0;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &ara[i]);
}
for (i = 0; i < n; i++) {
if (ara[i] >= k)
cnt++;
}
printf("%d", cnt);
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int h[1000];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (h[i] >= k)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int h[200000];
for (int i = 0; i < n; i++) {
cin >> h[i];
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (h[i] >= k)
ans++;
}
cout << ans << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <queue>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int i, j, k;
long n, m, tmp;
int a[10000];
int num = 0;
string s[200000];
cin >> n >> k;
rep(i, n) cin >> a[i];
rep(i, n) {
if (a[i] >= k) {
num++;
}
}
cout << num << endl;
return 0;
} | #include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <queue>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int i, j, k;
long n, m, tmp;
int a[100000];
int num = 0;
string s[200000];
cin >> n >> k;
rep(i, n) cin >> a[i];
rep(i, n) {
if (a[i] >= k) {
num++;
}
}
cout << num << endl;
return 0;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p02898 | C++ | Runtime Error | #include <iomanip>
#include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int ans = 0;
int h[1000];
for (int i = 0; i < n; i++) {
cin >> h[i];
if (h[i] >= k)
ans++;
}
cout << ans << endl;
} | #include <iomanip>
#include <iostream>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int ans = 0;
int h[100002];
for (int i = 0; i < n; i++) {
cin >> h[i];
if (h[i] >= k)
ans++;
}
cout << ans << endl;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main(void) {
int N, K;
scanf("%d %d", &N, &K);
vector<int> H(510);
for (int i = 0; i < N; i++) {
scanf("%d", &H[i]);
}
int ans = 0;
for (int i = 0; i < N; i++) {
if (K <= H[i]) {
ans++;
}
}
printf("%d\n", ans);
} | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main(void) {
int N, K;
scanf("%d %d", &N, &K);
vector<int> H(N + 10);
for (int i = 0; i < N; i++) {
scanf("%d", &H[i]);
}
int ans = 0;
for (int i = 0; i < N; i++) {
if (K <= H[i]) {
ans++;
}
}
printf("%d\n", ans);
} | replace | 21 | 22 | 21 | 22 | 0 | |
p02898 | C++ | Runtime Error | #include <stdio.h>
int main() {
int n, k, h[500], i, cnt;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &h[i]);
}
cnt = 0;
for (i = 0; i < n; i++) {
if (k <= h[i]) {
cnt++;
}
}
printf("%d\n", cnt);
return 0;
}
| #include <stdio.h>
int main() {
int n, k, h[100000], i, cnt;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &h[i]);
}
cnt = 0;
for (i = 0; i < n; i++) {
if (k <= h[i]) {
cnt++;
}
}
printf("%d\n", cnt);
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
int K = 0;
int A = 0;
cin >> N >> K;
vector<int> H(K);
for (int i = 0; i < N; i++) {
cin >> H.at(i);
}
for (int j = 0; j < N; j++) {
if (H.at(j) >= K) {
A += 1;
}
}
cout << A << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
int K = 0;
int A = 0;
cin >> N >> K;
vector<int> H(N);
for (int i = 0; i < N; i++) {
cin >> H.at(i);
}
for (int j = 0; j < N; j++) {
if (H.at(j) >= K) {
A += 1;
}
}
cout << A << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for (int i = a; i < b; i++)
#define for_m(i, a, b) for (int i = a - 1; i >= b; i--)
// a = s1.size();
// vector<string> s1;
// string s2 = accumulate( s1.begin(), s1.end(), string() );
using namespace std;
int main() {
int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
int i = 0, j = 0;
double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
int a1[256], a2[512], a3[1024];
char s1[200000], s2[200000], s3[200000];
cin >> a >> b;
for (i = 0; i < a; i++) {
cin >> a1[i];
if (b <= a1[i]) {
c++;
}
}
cout << c << endl;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for (int i = a; i < b; i++)
#define for_m(i, a, b) for (int i = a - 1; i >= b; i--)
// a = s1.size();
// vector<string> s1;
// string s2 = accumulate( s1.begin(), s1.end(), string() );
using namespace std;
int main() {
int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
int i = 0, j = 0;
double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
int a1[100000], a2[512], a3[1024];
char s1[200000], s2[200000], s3[200000];
cin >> a >> b;
for (i = 0; i < a; i++) {
cin >> a1[i];
if (b <= a1[i]) {
c++;
}
}
cout << c << endl;
}
| replace | 28 | 29 | 28 | 29 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int a[505];
int main() {
int n, m, cnt = 0;
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
if (a[i] >= m)
cnt++;
}
cout << cnt;
return 0;
} | #include <iostream>
using namespace std;
int a[100005];
int main() {
int n, m, cnt = 0;
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
if (a[i] >= m)
cnt++;
}
cout << cnt;
return 0;
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
int h[500];
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> h[i];
}
int ans = 0;
for (int i = 0; i < N; i++) {
if (h[i] >= K)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
int h[(int)1e+5];
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> h[i];
}
int ans = 0;
for (int i = 0; i < N; i++) {
if (h[i] >= K)
ans++;
}
cout << ans << endl;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define for0(i, N) for (int i = 0; i < (N); ++i)
#define for1n(i, N) for (int i = 1; i <= (N); ++i)
#define for1(i, N) for (int i = 1; i < (N); ++i)
#define forn(i, N) for (int i = 0; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i < (N); ++i)
#define forl(i, N, x, a) \
for (int i = (x), a = 0; a < (N); i = (i + 1) % (N), ++a)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, K, result = 0;
cin >> N >> K;
int h[500] = {};
for0(i, N) {
cin >> h[i];
if (h[i] >= K)
++result;
}
cout << result;
return 0;
}
| #include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define for0(i, N) for (int i = 0; i < (N); ++i)
#define for1n(i, N) for (int i = 1; i <= (N); ++i)
#define for1(i, N) for (int i = 1; i < (N); ++i)
#define forn(i, N) for (int i = 0; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i < (N); ++i)
#define forl(i, N, x, a) \
for (int i = (x), a = 0; a < (N); i = (i + 1) % (N), ++a)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, K, result = 0;
cin >> N >> K;
int h[100000] = {};
for0(i, N) {
cin >> h[i];
if (h[i] >= K)
++result;
}
cout << result;
return 0;
}
| replace | 43 | 44 | 43 | 44 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long n;
int k, a, cc;
cin >> n >> k;
vector<long> data(500);
for (long i = 0; i < n; i++) {
cin >> a;
data.at(i) = a;
}
cc = 0;
for (long i = 0; i < n; i++) {
if (data.at(i) >= k) {
cc++;
}
}
cout << cc << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long n;
int k, a, cc;
cin >> n >> k;
vector<long> data(1000000);
for (long i = 0; i < n; i++) {
cin >> a;
data.at(i) = a;
}
cc = 0;
for (long i = 0; i < n; i++) {
if (data.at(i) >= k) {
cc++;
}
}
cout << cc << endl;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
vector<int> h(N);
for (int i = 0; i < N; i++) {
cin >> h.at(i);
}
sort(h.begin(), h.end());
reverse(h.begin(), h.end());
int i = 0;
while (h.at(i) >= K) {
i++;
if (i == N) {
break;
}
}
cout << i << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h(N);
for (int i = 0; i < N; i++) {
cin >> h.at(i);
}
sort(h.begin(), h.end());
reverse(h.begin(), h.end());
int i = 0;
while (h.at(i) >= K) {
i++;
if (i == N) {
break;
}
}
cout << i << endl;
} | insert | 5 | 5 | 5 | 6 | -6 | terminate called after throwing an instance of 'std::length_error'
what(): cannot create std::vector larger than max_size()
|
p02898 | C++ | Runtime Error | // #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
int N, K;
int sum = 0;
cin >> N >> K;
vector<int> vi(K);
for (int i = 0; i < N; i++) {
cin >> vi[i];
}
for (int i = 0; i < N; i++) {
if (vi[i] >= K) {
sum++;
}
}
cout << sum << endl;
} | // #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
int N, K;
int sum = 0;
cin >> N >> K;
vector<int> vi(N);
for (int i = 0; i < N; i++) {
cin >> vi[i];
}
for (int i = 0; i < N; i++) {
if (vi[i] >= K) {
sum++;
}
}
cout << sum << endl;
} | replace | 44 | 45 | 44 | 45 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h;
int count = 0;
for (int i = 0; i < N; i++) {
cin >> h.at(i);
if (h.at(i) >= K)
count++;
}
cout << count << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h(N);
int count = 0;
for (int i = 0; i < N; i++) {
cin >> h.at(i);
if (h.at(i) >= K)
count++;
}
cout << count << endl;
}
| replace | 5 | 6 | 5 | 6 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
|
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int odd(int n, int A[], int k) {
int i, j = 0;
for (i = 0; i < n; i++) {
if (A[i] >= k) {
j++;
}
}
return j;
}
int main() {
int p, u;
int c, B[1000], b;
cin >> p >> c;
for (u = 0; u < p; u++) {
cin >> B[u];
}
b = odd(p, B, c);
cout << b << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int odd(int n, int A[], int k) {
int i, j = 0;
for (i = 0; i < n; i++) {
if (A[i] >= k) {
j++;
}
}
return j;
}
int main() {
int p, u;
int c, B[100005], b;
cin >> p >> c;
for (u = 0; u < p; u++) {
cin >> B[u];
}
b = odd(p, B, c);
cout << b << endl;
return 0;
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int h[1000] = {};
int main() {
int N, K;
cin >> N >> K;
int cnt = 0;
rep(i, N) {
cin >> h[i];
if (h[i] >= K) {
cnt++;
}
}
cout << cnt << endl;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int h[100010] = {};
int main() {
int N, K;
cin >> N >> K;
int cnt = 0;
rep(i, N) {
cin >> h[i];
if (h[i] >= K) {
cnt++;
}
}
cout << cnt << endl;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace ::std;
int N, K;
int main() {
int h[505] = {0};
int ans = 0;
cin >> N >> K;
for (int i = 1; i <= N; ++i) {
cin >> h[i];
if (h[i] >= K) {
++ans;
}
}
cout << ans;
return 0;
} | #include <iostream>
using namespace ::std;
int N, K;
int main() {
int h[100000] = {0};
int ans = 0;
cin >> N >> K;
for (int i = 1; i <= N; ++i) {
cin >> h[i];
if (h[i] >= K) {
++ans;
}
}
cout << ans;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k;
int arr[50];
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> arr[i];
int count = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= k)
count++;
}
cout << count;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n, k;
int arr[100000];
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> arr[i];
int count = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= k)
count++;
}
cout << count;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a[505], ilosc = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] >= k) {
ilosc++;
}
}
cout << ilosc;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a[100005], ilosc = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] >= k) {
ilosc++;
}
}
cout << ilosc;
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
std::string line;
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
int h[10010] = {0};
rep(i, n) cin >> h[i];
sort(h, h + n, greater<int>());
int cnt = 0;
rep(i, n) {
if (k <= h[i])
cnt++;
}
cout << cnt << endl;
return 0;
} | #include <bits/stdc++.h>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
std::string line;
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
int h[100010] = {0};
rep(i, n) cin >> h[i];
sort(h, h + n, greater<int>());
int cnt = 0;
rep(i, n) {
if (k <= h[i])
cnt++;
}
cout << cnt << endl;
return 0;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p02898 | C++ | Time Limit Exceeded | #include <iostream>
int main(void) {
int n = 0, k = 0, a = 0;
scanf("%d", &n);
scanf("%d", &k);
int h[n + 1];
for (int i = 1; i = n; i++) {
scanf("%d", &h[i]);
if (h[i] >= k) {
a++;
}
}
printf("%d\n", a);
} | #include <iostream>
int main(void) {
int n = 0, k = 0, a = 0;
scanf("%d", &n);
scanf("%d", &k);
int h[n + 1];
for (int i = 1; i <= n; i++) {
scanf("%d", &h[i]);
if (h[i] >= k) {
a++;
}
}
printf("%d\n", a);
} | replace | 8 | 9 | 8 | 9 | TLE | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include <tr1/unordered_map>
#include <iostream>
#define maxn 10005
#define M 1000000007
using namespace std;
// using namespace tr1;
int main() {
int n, k, num = 0;
scanf("%d%d", &n, &k);
int a[maxn];
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (a[i] >= k)
num++;
}
printf("%d", num);
return 0;
}
| #include <algorithm>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include <tr1/unordered_map>
#include <iostream>
#define maxn 100005
#define M 1000000007
using namespace std;
// using namespace tr1;
int main() {
int n, k, num = 0;
scanf("%d%d", &n, &k);
int a[maxn];
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (a[i] >= k)
num++;
}
printf("%d", num);
return 0;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int cnt = 0;
int a[505];
int main() {
int n, h;
cin >> n >> h;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (h <= a[i]) {
cnt++;
}
}
cout << cnt << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int cnt = 0;
int a[100005];
int main() {
int n, h;
cin >> n >> h;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (h <= a[i]) {
cnt++;
}
}
cout << cnt << endl;
return 0;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0, k = 0;
cin >> n >> k;
assert(n > 0 && 10000 >= n);
assert(k > 0 && 500 >= k);
int answer = 0;
for (int i = 0; i < n; i++) {
int h = 0;
cin >> h;
assert(h > 0 && h <= 500);
if (h >= k)
answer++;
}
cout << answer << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0, k = 0;
cin >> n >> k;
assert(n > 0 && 100000 >= n);
assert(k > 0 && 500 >= k);
int answer = 0;
for (int i = 0; i < n; i++) {
int h = 0;
cin >> h;
assert(h > 0 && h <= 500);
if (h >= k)
answer++;
}
cout << answer << endl;
return 0;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n, k;
int h[11000];
cin >> n >> k;
rep(i, n) cin >> h[i];
int count = 0;
rep(i, n) {
if (h[i] >= k) {
count++;
}
}
cout << count << endl;
} | #include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n, k;
int h[110000];
cin >> n >> k;
rep(i, n) cin >> h[i];
int count = 0;
rep(i, n) {
if (h[i] >= k) {
count++;
}
}
cout << count << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02898 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, o, p, k, i, x = 0, y;
cin >> n >> k;
o = n;
p = n;
int h[i];
for (i = 0; i < o; i++) {
cin >> h[i];
}
for (y = 0; y < p; y++) {
if (h[y] >= k) {
x++;
}
}
cout << x << endl;
} | #include <iostream>
using namespace std;
int main() {
int n, o, p, k, i, x = 0, y;
cin >> n >> k;
o = n;
p = n;
int h[100000];
for (i = 0; i < o; i++) {
cin >> h[i];
}
for (y = 0; y < p; y++) {
if (h[y] >= k) {
x++;
}
}
cout << x << endl;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
int h[550];
int cot = 0;
cin >> n >> k;
for (int i = 0; i < n; ++i)
cin >> h[i];
for (int i = 0; i < n; ++i) {
if (h[i] >= k)
++cot;
}
cout << cot;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
int h[1000000];
int cot = 0;
cin >> n >> k;
for (int i = 0; i < n; ++i)
cin >> h[i];
for (int i = 0; i < n; ++i) {
if (h[i] >= k)
++cot;
}
cout << cot;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define m0(x) memset(x, 0, sizeof(x))
int A[1000];
int main() {
int n, k;
scanf("%d %d", &n, &k);
rep(i, n) scanf("%d", &A[i]);
int sum = 0;
rep(i, n) if (A[i] >= k) sum++;
printf("%d", sum);
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define m0(x) memset(x, 0, sizeof(x))
int A[100000];
int main() {
int n, k;
scanf("%d %d", &n, &k);
rep(i, n) scanf("%d", &A[i]);
int sum = 0;
rep(i, n) if (A[i] >= k) sum++;
printf("%d", sum);
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02898 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h(501);
for (int i = 0; i < N; i++)
cin >> h[i];
int ans = 0;
for (int i = 0; i < N; i++) {
if (h[i] >= K)
ans += 1;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> h(200000);
for (int i = 0; i < N; i++)
cin >> h[i];
int ans = 0;
for (int i = 0; i < N; i++) {
if (h[i] >= K)
ans += 1;
}
cout << ans << endl;
} | replace | 5 | 6 | 5 | 6 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.