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
p03209
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, s, N) for (ll i{s}; i < N; i++) #define rem(i, N, s) for (ll i{N}; i > s; i--) using namespace std; using ll = long long int; using ld = long double; using P = pair<ll, ll>; const int MOD = (int)1e9 + 7; const string rt = "\n"; const string sp = " "; /* 最大公約数 */ template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; } /* UnionFind */ template <typename T> struct UnionFind { vector<T> par; UnionFind(T n) : par(n, -1) {} void init(T n) { par.assign(n, -1); } T root(T x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(T x, T y) { return root(x) == root(y); } bool merge(T x, T y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; /* コンビネーション */ template <typename T> ll combpm(T N_, T C_) { const int NUM_ = 400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % MOD, factr[i] = factr[i - 1] * inv[i] % MOD; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % MOD * factr[N_ - C_] % MOD; } /* 多次元ベクター */ template <class T> vector<T> multi_vector(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto multi_vector(size_t a, Ts... ts) { return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...)); } /* テスト関数 */ void test(ll n) { cout << "test" << n << endl; } /* 小数点以下 */ void fixsp(ll n) { cout << fixed << setprecision(n); } void defsp(ll n) { cout << defaultfloat << setprecision(n); } /* 重み付きUnionFind */ struct WUnionFind { vector<int> par; vector<int> rank; WUnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n); rank.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; return true; } }; /* IO高速化 */ void fastio() { ios::sync_with_stdio(false); cin.tie(NULL); } /* ここからコード開始 */ ll dfs(ll l, ll s) { ll tmp{}; if (l == 1) { if (s == 1) return 0; if (s == 2) return 1; if (s == 3) return 2; if (s == 4) return 3; if (s == 5) return 3; } if (s > 0 && pow(2, l + 1) - 2 >= s) tmp += dfs(l - 1, min((ll)pow(2, l + 1) - 3, s - 1)); if (s > pow(2, l + 1) - 2) tmp += pow(2, l); if (s > pow(2, l + 1) - 1) tmp += dfs(l - 1, s - pow(2, l + 1) + 1); // cout << l << sp <<tmp << rt; return tmp; } int main() { fastio; ll N, X; cin >> N >> X; cout << dfs(N, X) << rt; }
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, s, N) for (ll i{s}; i < N; i++) #define rem(i, N, s) for (ll i{N}; i > s; i--) using namespace std; using ll = long long int; using ld = long double; using P = pair<ll, ll>; const int MOD = (int)1e9 + 7; const string rt = "\n"; const string sp = " "; /* 最大公約数 */ template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; } /* UnionFind */ template <typename T> struct UnionFind { vector<T> par; UnionFind(T n) : par(n, -1) {} void init(T n) { par.assign(n, -1); } T root(T x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(T x, T y) { return root(x) == root(y); } bool merge(T x, T y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; /* コンビネーション */ template <typename T> ll combpm(T N_, T C_) { const int NUM_ = 400001; static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i % MOD, factr[i] = factr[i - 1] * inv[i] % MOD; } if (C_ < 0 || C_ > N_) return 0; return factr[C_] * fact[N_] % MOD * factr[N_ - C_] % MOD; } /* 多次元ベクター */ template <class T> vector<T> multi_vector(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto multi_vector(size_t a, Ts... ts) { return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...)); } /* テスト関数 */ void test(ll n) { cout << "test" << n << endl; } /* 小数点以下 */ void fixsp(ll n) { cout << fixed << setprecision(n); } void defsp(ll n) { cout << defaultfloat << setprecision(n); } /* 重み付きUnionFind */ struct WUnionFind { vector<int> par; vector<int> rank; WUnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n); rank.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; return true; } }; /* IO高速化 */ void fastio() { ios::sync_with_stdio(false); cin.tie(NULL); } /* ここからコード開始 */ ll dfs(ll l, ll s) { ll tmp{}; if (l == 1) { if (s == 1) return 0; if (s == 2) return 1; if (s == 3) return 2; if (s == 4) return 3; if (s == 5) return 3; } if (s > pow(2, l + 2) - 4) return pow(2, l + 1) - 1; if (s > 0 && pow(2, l + 1) - 2 >= s) tmp += dfs(l - 1, min((ll)pow(2, l + 1) - 3, s - 1)); if (s > pow(2, l + 1) - 2) tmp += pow(2, l); if (s > pow(2, l + 1) - 1) tmp += dfs(l - 1, s - pow(2, l + 1) + 1); // cout << l << sp <<tmp << rt; return tmp; } int main() { fastio; ll N, X; cin >> N >> X; cout << dfs(N, X) << rt; }
insert
114
114
114
116
TLE
p03209
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; ll cntp(ll n) { if (n == 0) return 1LL; return 2 * cntp(n - 1) + 1; } ll volm(ll n) { if (n == 0) return 1LL; return 2 * volm(n - 1) + 3; } ll f(ll n, ll x) { if (n == 0) { if (x == 0) return 0; // いくら n == 0 でも、x == 0 なら 0 else return 1LL; } if (x == 1 && n > 0) return 0; else if (2 <= x && x <= volm(n - 1) + 1) { return f(n - 1, x - 1); } else if (volm(n - 1) + 2 <= x && x <= volm(n)) { return cntp(n - 1) + 1 + f(n - 1, x - 2 - volm(n - 1)); } } int main(void) { ll n, x; cin >> n >> x; cout << f(n, x) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; ll cntp(ll n) { if (n == 0) return 1LL; return 2 * cntp(n - 1) + 1; } ll volm(ll n) { if (n == 0) return 1LL; return 2 * volm(n - 1) + 3; } ll f(ll n, ll x) { if (n == 0) { if (x == 0) return 0; // いくら n == 0 でも、x == 0 なら 0 else return 1LL; } if (x == 1 || x == 0) return 0; else if (2 <= x && x <= volm(n - 1) + 1) { return f(n - 1, x - 1); } else if (volm(n - 1) + 2 <= x && x <= volm(n)) { return cntp(n - 1) + 1 + f(n - 1, x - 2 - volm(n - 1)); } } int main(void) { ll n, x; cin >> n >> x; cout << f(n, x) << endl; return 0; }
replace
25
26
25
26
TLE
p03209
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("a_input.txt", "r", stdin); freopen("a_output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } ll p[55], a[55]; void build(int n) { if (n > 50) return; p[n] = 2 * p[n - 1] + 1; a[n] = 2 * a[n - 1] + 3; build(n + 1); } ll get(int n, ll x) { if (n == 0) return x > 0; if (x <= a[n - 1] + 1) return get(n - 1, x - 1); return p[n - 1] + 1 + get(n - 1, x - 2 - a[n - 1]); } int main() { file(); fast(); p[0] = 1; a[0] = 1; build(1); ll n, x; cin >> n >> x; cout << get(n, x) << endl; }
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define ll long long void file() { #ifndef ONLINE_JUDGE freopen("a_input.txt", "r", stdin); freopen("a_output.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } ll p[55], a[55]; void build(int n) { if (n > 50) return; p[n] = 2 * p[n - 1] + 1; a[n] = 2 * a[n - 1] + 3; build(n + 1); } ll get(int n, ll x) { if (n == 0) return x > 0; if (x <= a[n - 1] + 1) return get(n - 1, x - 1); return p[n - 1] + 1 + get(n - 1, x - 2 - a[n - 1]); } int main() { // file(); fast(); p[0] = 1; a[0] = 1; build(1); ll n, x; cin >> n >> x; cout << get(n, x) << endl; }
replace
31
32
31
32
-11
p03209
C++
Runtime Error
#include <bits/stdc++.h> #define INF INT_MAX / 2 #define MOD 1000000007 using namespace std; using ll = long long; using ull = unsigned long long; vector<ll> two(52); ull func(ull N, ll X) { if (X <= 0) return 0; else if (X <= two[N + 1] - 2) return func(N - 1, X - 1); else return func(N - 1, X - two[N + 1] + 1) + two[N]; } int main() { ios::sync_with_stdio(false); cin.tie(0); two[0] = 1; for (int i = 1; i <= 51; i++) two[i] = 2 * two[i - 1]; ull N, X; cin >> N >> X; cout << func(N, X) << endl; return 0; }
#include <bits/stdc++.h> #define INF INT_MAX / 2 #define MOD 1000000007 using namespace std; using ll = long long; using ull = unsigned long long; vector<ull> two(52); ull func(ull N, ll X) { if (X <= 0) return 0; else if (X <= two[N + 1] - 2) return func(N - 1, X - 1); else return func(N - 1, X - two[N + 1] + 1) + two[N]; } int main() { ios::sync_with_stdio(false); cin.tie(0); two[0] = 1; for (int i = 1; i <= 51; i++) two[i] = 2 * two[i - 1]; ull N, X; cin >> N >> X; cout << func(N, X) << endl; return 0; }
replace
10
11
10
11
0
p03209
C++
Runtime Error
#include <algorithm> #include <array> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <random> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; uint64_t count_p(int l, uint64_t p, const vector<uint64_t> pnum, const vector<uint64_t> bnum, const vector<uint64_t> sum) { assert(p <= sum[l]); if (l == 0) { return 1; } if (p <= 1) { return 0; } uint64_t spos = 0; bool is_rev = false; if (p == sum[l] / 2 + 1) { return pnum[l] / 2 + 1; } if (p > sum[l] / 2 + 1) { spos = sum[l] - p; is_rev = true; } else { spos = p; } uint64_t num = count_p(l - 1, spos - 1, pnum, bnum, sum); uint64_t ret = is_rev ? pnum[l] - num : num; return ret; } int main() { int l; uint64_t p; cin >> l >> p; // 総数 vector<uint64_t> pnum(l + 1); vector<uint64_t> bnum(l + 1); vector<uint64_t> sum(l + 1); pnum[0] = 1; bnum[0] = 0; sum[0] = 1; { for (int i = 1; i <= l; i++) { pnum[i] = (pnum[i - 1] * 2) + 1; bnum[i] = (bnum[i - 1] * 2) + 2; sum[i] = bnum[i] + pnum[i]; } } uint64_t val = count_p(l, p, pnum, bnum, sum); cout << val << endl; return 0; }
#include <algorithm> #include <array> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <random> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; uint64_t count_p(int l, uint64_t p, const vector<uint64_t> pnum, const vector<uint64_t> bnum, const vector<uint64_t> sum) { assert(p <= sum[l]); if (l == 0) { return 1; } if (p <= 1) { return 0; } if (p >= sum[l] - 1) { return pnum[l]; } uint64_t spos = 0; bool is_rev = false; if (p == sum[l] / 2 + 1) { return pnum[l] / 2 + 1; } if (p > sum[l] / 2 + 1) { spos = sum[l] - p; is_rev = true; } else { spos = p; } uint64_t num = count_p(l - 1, spos - 1, pnum, bnum, sum); uint64_t ret = is_rev ? pnum[l] - num : num; return ret; } int main() { int l; uint64_t p; cin >> l >> p; // 総数 vector<uint64_t> pnum(l + 1); vector<uint64_t> bnum(l + 1); vector<uint64_t> sum(l + 1); pnum[0] = 1; bnum[0] = 0; sum[0] = 1; { for (int i = 1; i <= l; i++) { pnum[i] = (pnum[i - 1] * 2) + 1; bnum[i] = (bnum[i - 1] * 2) + 2; sum[i] = bnum[i] + pnum[i]; } } uint64_t val = count_p(l, p, pnum, bnum, sum); cout << val << endl; return 0; }
insert
29
29
29
32
0
p03209
C++
Runtime Error
#include <cstdio> #define ll long long using namespace std; ll f[55], p[55]; ll F(ll n, ll x) { if (n == 0) return 1; if (x == 1) return 0; if (x > 1 && x <= f[n - 1] + 1) return F(n - 1, x - 1); if (x == 2 + f[n - 1]) return p[n - 1] + 1; if (2 + f[n - 1] < x && x <= 2 + 2 * f[n - 1]) return p[n - 1] + 1 + F(n - 1, x - 2 - f[n - 1]); if (x == f[n - 1] * 2 + 3) return 2 * p[n - 1] + 1; } int main() { f[0] = p[0] = 1; for (int i = 1; i <= 50; i++) { f[i] = 2 * f[i - 1] + 3; p[i] = 2 * p[i - 1] + 1; } ll n; ll x; scanf("%I64d%I64d", &n, &x); printf("%I64d\n", F(n, x)); return 0; }
#include <cstdio> #define ll long long using namespace std; ll f[55], p[55]; ll F(ll n, ll x) { if (n == 0) return 1; if (x == 1) return 0; if (x > 1 && x <= f[n - 1] + 1) return F(n - 1, x - 1); if (x == 2 + f[n - 1]) return p[n - 1] + 1; if (2 + f[n - 1] < x && x <= 2 + 2 * f[n - 1]) return p[n - 1] + 1 + F(n - 1, x - 2 - f[n - 1]); if (x == f[n - 1] * 2 + 3) return 2 * p[n - 1] + 1; } int main() { f[0] = p[0] = 1; for (int i = 1; i <= 50; i++) { f[i] = 2 * f[i - 1] + 3; p[i] = 2 * p[i - 1] + 1; } ll n; ll x; scanf("%lld%lld", &n, &x); printf("%lld\n", F(n, x)); return 0; }
replace
29
31
29
31
-11
p03209
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; vector<long long> l(51); vector<long long> p(51); long long solve(int n, long long x) { assert(l[n] > x && x >= 0); if (n == 1) { return x; } if (x == l[n]) { return p[n]; } long long ans = 0; if (x > l[n - 1] + 1) { ans += p[n - 1] + 1; x -= l[n - 1] + 1; } if (x > 0) { ans += solve(n - 1, x - 1); } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; long long x; cin >> n >> x; l[0] = 1LL; p[0] = 1LL; for (int i = 1; i <= n; i++) { l[i] = l[i - 1] * 2 + 3; p[i] = p[i - 1] * 2 + 1; } cout << solve(n, x) << '\n'; }
#include <bits/stdc++.h> using namespace std; vector<long long> l(51); vector<long long> p(51); long long solve(int n, long long x) { assert(l[n] >= x && x >= 0); if (n == 0) { return x; } if (x == l[n]) { return p[n]; } long long ans = 0; if (x > l[n - 1] + 1) { ans += p[n - 1] + 1; x -= l[n - 1] + 1; } if (x > 0) { ans += solve(n - 1, x - 1); } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; long long x; cin >> n >> x; l[0] = 1LL; p[0] = 1LL; for (int i = 1; i <= n; i++) { l[i] = l[i - 1] * 2 + 3; p[i] = p[i - 1] * 2 + 1; } cout << solve(n, x) << '\n'; }
replace
7
9
7
9
0
p03209
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 int n, k; int a[100005], b[100005]; int solve(int shift, int size, int pos) { if (size == 0) return b[shift]; int mid = (2 * shift + a[size] - 1) / 2; if (pos == shift) return 0; else if (pos < mid) return solve(shift + 1, size - 1, pos); else if (pos == mid) return b[size - 1] + 1; else if (pos < shift + a[size] - 1) return b[size - 1] + 1 + solve(mid + 1, size - 1, pos); else return b[size]; } signed main() { a[0] = 1, b[0] = 1; for (int i = 1; i <= 50; i++) a[i] = 2 * a[i - 1] + 3, b[i] = 2 * b[i - 1] + 1; cin >> n >> k; // cout << a[n] << " " << b[n] << endl; cout << solve(1, n, k); }
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 int n, k; int a[100005], b[100005]; int solve(int shift, int size, int pos) { if (size == 0) return 1; int mid = (2 * shift + a[size] - 1) / 2; if (pos == shift) return 0; else if (pos < mid) return solve(shift + 1, size - 1, pos); else if (pos == mid) return b[size - 1] + 1; else if (pos < shift + a[size] - 1) return b[size - 1] + 1 + solve(mid + 1, size - 1, pos); else return b[size]; } signed main() { a[0] = 1, b[0] = 1; for (int i = 1; i <= 50; i++) a[i] = 2 * a[i - 1] + 3, b[i] = 2 * b[i - 1] + 1; cin >> n >> k; // cout << a[n] << " " << b[n] << endl; cout << solve(1, n, k); }
replace
9
10
9
10
0
p03209
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ int ab; \ cin >> ab; \ (p).push_back(ab); #define vecpl2(p) \ long long ab; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define set0(k, n) \ for (int nn = 0; nn < (n); nn++) { \ (k).push_back(0); \ } #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define vecsize(b, size) vector<int>(b)((size)); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsl(s) vector<pair<ll, ll>>(s); #define pairss(s) vector<pair<string, string>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairspl(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsps(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsREV(s) (s).push_back(make_pair(bb, aa)); #define pairslREV(s) (s).push_back(make_pair(bb, aa)); #define pairssREV(s) (s).push_back(make_pair(bb, aa)); #define MOD 1000000007 vecl(A) vecl(B) ll ref(int n, ll x) { if (x <= 1) { if (n == 0) return 1; else return 0; } if (A.at(n - 1) + 2 > x) { return ref(n - 1, x - 1); } if (A.at(n - 1) + 2 == x) { return (B.at(n - 1) + 1); } if (A.at(n - 1) + 2 < x) { return (B.at(n - 1) + 1 + ref(n - 1, x - A.at(n - 1) - 2)); } } int main() { int N; ll X; cin >> N >> X; pb(A, 1) pb(B, 1) fx(N + 1){pb(A, A.at(x) * 2 + 3) pb(B, B.at(x) * 2 + 1)} ll ans = 0; ans = ref(N, X); ce(ans) }
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ int ab; \ cin >> ab; \ (p).push_back(ab); #define vecpl2(p) \ long long ab; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define set0(k, n) \ for (int nn = 0; nn < (n); nn++) { \ (k).push_back(0); \ } #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define vecsize(b, size) vector<int>(b)((size)); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsl(s) vector<pair<ll, ll>>(s); #define pairss(s) vector<pair<string, string>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairspl(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsps(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define pairsREV(s) (s).push_back(make_pair(bb, aa)); #define pairslREV(s) (s).push_back(make_pair(bb, aa)); #define pairssREV(s) (s).push_back(make_pair(bb, aa)); #define MOD 1000000007 vecl(A) vecl(B) ll ref(int n, ll x) { if (x <= 1 || n == 0) { if (n == 0) return 1; else return 0; } if (A.at(n - 1) + 2 > x) { return ref(n - 1, x - 1); } if (A.at(n - 1) + 2 == x) { return (B.at(n - 1) + 1); } if (A.at(n - 1) + 2 < x) { return (B.at(n - 1) + 1 + ref(n - 1, x - A.at(n - 1) - 2)); } } int main() { int N; ll X; cin >> N >> X; pb(A, 1) pb(B, 1) fx(N + 1){pb(A, A.at(x) * 2 + 3) pb(B, B.at(x) * 2 + 1)} ll ans = 0; ans = ref(N, X); ce(ans) }
replace
68
69
68
69
0
p03209
C++
Runtime Error
#include <cmath> #include <iostream> using namespace std; using ll = long long; ll f(ll N, ll X) { if (X == 0) return 0; if (N == 0 && X == 1) return 1; if (X < pow(2, N + 1) - 1) return f(N - 1, X - 1); if (X == pow(2, N + 1) - 1) return pow(2, N); if (X > pow(2, N + 1) - 1) return pow(2, N) + f(N - 1, X - pow(2, N + 1) + 1); } int main() { ll N, X; cin >> N >> X; cout << f(N, X) << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; using ll = long long; ll f(ll N, ll X) { if (X == 0) return 0; if (X > pow(2, N + 2) - 3) return pow(2, N + 1) - 1; if (N == 0 && X == 1) return 1; if (X < pow(2, N + 1) - 1) return f(N - 1, X - 1); if (X == pow(2, N + 1) - 1) return pow(2, N); if (X > pow(2, N + 1) - 1) return pow(2, N) + f(N - 1, X - pow(2, N + 1) + 1); } int main() { ll N, X; cin >> N >> X; cout << f(N, X) << endl; return 0; }
insert
8
8
8
10
0
p03209
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ALL(v) v.begin(), v.end() #define V vector #define P pair typedef long long ll; const int INT_INF = 1e9; const ll INF = 1LL << 30; const ll MOD = 1e9 + 7; V<ll> len, pat; ll rec(ll n, ll x) { if (n == 0) { if (x == 1) return 1; else return 0; } if (x == 1) return 0; if (x == len[n]) return pat[n]; ll ans = 0; if (len[n] / 2 + 1 <= x) { ans += pat[n - 1] + 1 + rec(n - 1, x - len[n] / 2 - 1); } if (len[n] / 2 + 1 > x) { ans += rec(n - 1, x - 1); } return ans; } int main() { ll n, x; cin >> n >> x; len.resize(n); pat.resize(n); len[0] = pat[0] = 1; for (int i = 1; i <= n; i++) { len[i] = len[i - 1] * 2 + 3; pat[i] = pat[i - 1] * 2 + 1; } cout << rec(n, x) << endl; }
#include <bits/stdc++.h> using namespace std; #define ALL(v) v.begin(), v.end() #define V vector #define P pair typedef long long ll; const int INT_INF = 1e9; const ll INF = 1LL << 30; const ll MOD = 1e9 + 7; V<ll> len, pat; ll rec(ll n, ll x) { if (n == 0) { if (x == 1) return 1; else return 0; } if (x == 1) return 0; if (x == len[n]) return pat[n]; ll ans = 0; if (len[n] / 2 + 1 <= x) { ans += pat[n - 1] + 1 + rec(n - 1, x - len[n] / 2 - 1); } if (len[n] / 2 + 1 > x) { ans += rec(n - 1, x - 1); } return ans; } int main() { ll n, x; cin >> n >> x; len.resize(n + 1); pat.resize(n + 1); len[0] = pat[0] = 1; for (int i = 1; i <= n; i++) { len[i] = len[i - 1] * 2 + 3; pat[i] = pat[i - 1] * 2 + 1; } cout << rec(n, x) << endl; }
replace
39
41
39
41
0
p03209
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; vector<ll> b(51), p(51); ll f(ll n, ll x) { if (x == 0) return 0; if (n == 0) return 1; if (x <= 1 + b[n - 1]) return f(n - 1, x - 1); else return p[n - 1] + 1 + f(n - 1, x - 2 - b[n - 1]); } int main() { int n; cin >> n; ll x; cin >> x; b[0] = p[0] = 1; REP(i, n + 1) { p[i + 1] = p[i] * 2 + 1; b[i + 1] = b[i] * 2 + 3; } cout << f(n, x) << '\n'; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; vector<ll> b(51), p(51); ll f(ll n, ll x) { if (x == 0) return 0; if (n == 0) return 1; if (x <= 1 + b[n - 1]) return f(n - 1, x - 1); else return p[n - 1] + 1 + f(n - 1, x - 2 - b[n - 1]); } int main() { int n; cin >> n; ll x; cin >> x; b[0] = p[0] = 1; REP(i, 50) { p[i + 1] = p[i] * 2 + 1; b[i + 1] = b[i] * 2 + 3; } cout << f(n, x) << '\n'; return 0; }
replace
24
25
24
25
0
p03209
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <tuple> #include <utility> #include <vector> #define DEBUG(x) cout << #x << ": " << x << endl using namespace std; int main() { long long N, X; cin >> N >> X; long long b = 1; long long p = 1; for (int i = 0; i < N; i++) { b = 2 * b + 3; p = 2 * p + 1; } long long ans = 0; while (0 < X) { if ((b + 1) / 2 <= X) { ans += (p - 1) / 2 + 1; X -= (b + 1) / 2; } else { X--; } b = (b - 3) / 2; p = (p - 1) / 2; } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <tuple> #include <utility> #include <vector> #define DEBUG(x) cout << #x << ": " << x << endl using namespace std; int main() { long long N, X; cin >> N >> X; long long b = 1; long long p = 1; for (int i = 0; i < N; i++) { b = 2 * b + 3; p = 2 * p + 1; } long long ans = 0; while (X != 0) { if (X == b) { ans += p; break; } if (X == 1) break; if ((b + 1) / 2 == X) { ans += (p + 1) / 2; break; } if ((b + 1) / 2 < X) { ans += (p + 1) / 2; X -= (b + 1) / 2; } else { X--; } b = (b - 3) / 2; p = (p - 1) / 2; } cout << ans << endl; return 0; }
replace
39
42
39
52
TLE
p03209
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> const double EPS = (1e-10); using namespace std; using Int = long long; // using namespace boost::multiprecision; const Int MOD = 1000000007; Int mod_pow(Int x, Int n) { Int res = 1; while (n > 0) { if (n & 1) res = (res * x) % MOD; // ビット演算(最下位ビットが1のとき) x = (x * x) % MOD; n >>= 1; // 右シフト(n = n >> 1) } return res; } template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } Int S[51]; Int P[51]; Int calc(int n, Int x) { cout << n << " " << x << endl; if (x == 1) { return 0; } if (x == S[n - 1] + 1) { return P[n - 1]; } if (x >= (S[n] + 1) / 2) return P[n] - calc(n, S[n] - x); else return calc(n - 1, x - 1); } int main() { cin.tie(0); Int N, X; cin >> N >> X; P[0] = 1LL; S[0] = 1LL; for (int i = 1; i <= N; i++) { S[i] = S[i - 1] * 2LL + 3LL; P[i] = P[i - 1] * 2LL + 1LL; } cout << calc(N, X) << endl; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> const double EPS = (1e-10); using namespace std; using Int = long long; // using namespace boost::multiprecision; const Int MOD = 1000000007; Int mod_pow(Int x, Int n) { Int res = 1; while (n > 0) { if (n & 1) res = (res * x) % MOD; // ビット演算(最下位ビットが1のとき) x = (x * x) % MOD; n >>= 1; // 右シフト(n = n >> 1) } return res; } template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } Int S[51]; Int P[51]; Int calc(int n, Int x) { if (x == 1 || x == 0) { return 0; } if (x == S[n - 1] + 1) { return P[n - 1]; } if (x >= (S[n] + 1) / 2) return P[n] - calc(n, S[n] - x); else return calc(n - 1, x - 1); } int main() { cin.tie(0); Int N, X; cin >> N >> X; P[0] = 1LL; S[0] = 1LL; for (int i = 1; i <= N; i++) { S[i] = S[i - 1] * 2LL + 3LL; P[i] = P[i - 1] * 2LL + 1LL; } cout << calc(N, X) << endl; }
replace
49
51
49
50
0
p03209
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, a, b) for (int i = a; i < (b); ++i) #define reprev(i, n) for (int i = n - 1; i >= 0; --i) #define reprrev(i, a, b) for (int i = b - 1; i >= (a); --i) using namespace std; using ll = long long; using P = pair<int, int>; // aiはlevel iの層の厚さ // piはlevel iのパティの数 ll a[52], p[52]; ll f(int N, ll X) { if (N == 0) { if (X <= 0) { return 0; } else { return p[0]; } } else if (X <= (a[N - 1] + 1)) { return f(N - 1, X - 1); } else if (X == (a[N - 1] + 2)) { return f(N - 1, X - 1) + 1; } else { return f(N - 1, X - 1) + 1 + f(N - 1, X - 2 - a[N - 1]); } } int main() { cout << fixed << setprecision(10); int N; cin >> N; ll X; cin >> X; a[0] = 1; p[0] = 1; repr(i, 1, 51) { a[i] = a[i - 1] * 2 + 3; p[i] = p[i - 1] * 2 + 1; } cout << f(N, X) << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, a, b) for (int i = a; i < (b); ++i) #define reprev(i, n) for (int i = n - 1; i >= 0; --i) #define reprrev(i, a, b) for (int i = b - 1; i >= (a); --i) using namespace std; using ll = long long; using P = pair<int, int>; // aiはlevel iの層の厚さ // piはlevel iのパティの数 ll a[52], p[52]; ll f(int N, ll X) { if (N == 0) { if (X <= 0) { return 0; } else { return p[0]; } } else if (X <= (a[N - 1] + 1)) { return f(N - 1, X - 1); } else if (X == (a[N - 1] + 2)) { return f(N - 1, X - 1) + 1; } else { return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1]); } } int main() { cout << fixed << setprecision(10); int N; cin >> N; ll X; cin >> X; a[0] = 1; p[0] = 1; repr(i, 1, 51) { a[i] = a[i - 1] * 2 + 3; p[i] = p[i - 1] * 2 + 1; } cout << f(N, X) << endl; return 0; }
replace
25
26
25
26
TLE
p03209
C++
Runtime Error
// Created by sz #include <bits/stdc++.h> using namespace std; __int128 total_level[55]; __int128 total_party[55]; void scan(__int128 &x) // 输入 { x = 0; int f = 1; getchar(); char ch; if ((ch = getchar()) == '-') f = -f; else x = x * 10 + ch - '0'; while ((ch = getchar()) >= '0' && ch <= '9') x = x * 10 + ch - '0'; x *= f; } void print(__int128 x) { if (x < 0) { x = -x; putchar('-'); } if (x > 9) print(x / 10); putchar(x % 10 + '0'); } __int128 solve(int N, __int128 X) { if (N == 1) { if (X == 0) return 0; if (X == 1) return 0; if (X == 2) return 1; if (X == 3) return 2; if (X == 4) return 3; if (X == 5) return 3; } if (X == total_level[N - 1] + 2) return total_party[N - 1] + 1; if (X == total_level[N - 1] + 1) return total_party[N - 1]; if (X < total_level[N - 1] + 1) { return solve(N - 1, X - 1); } if (X > total_level[N - 1] + 2) { return solve(N - 1, X - total_level[N - 1] - 2) + 1 + total_party[N - 1]; } } int main() { // freopen("./input.txt", "r", stdin); int N; __int128 X, ans; scanf("%d", &N); scan(X); total_level[1] = 5; total_party[1] = 3; for (int i = 2; i <= N; i++) { total_level[i] = total_level[i - 1] * 2 + 3; total_party[i] = total_party[i - 1] * 2 + 1; } ans = solve(N, X); print(ans); printf("\n"); return 0; }
// Created by sz #include <bits/stdc++.h> using namespace std; __int128 total_level[55]; __int128 total_party[55]; void scan(__int128 &x) // 输入 { x = 0; int f = 1; getchar(); char ch; if ((ch = getchar()) == '-') f = -f; else x = x * 10 + ch - '0'; while ((ch = getchar()) >= '0' && ch <= '9') x = x * 10 + ch - '0'; x *= f; } void print(__int128 x) { if (x < 0) { x = -x; putchar('-'); } if (x > 9) print(x / 10); putchar(x % 10 + '0'); } __int128 solve(int N, __int128 X) { if (N == 1) { if (X == 0) return 0; if (X == 1) return 0; if (X == 2) return 1; if (X == 3) return 2; if (X == 4) return 3; if (X == 5) return 3; } if (X == total_level[N - 1] + 2) return total_party[N - 1] + 1; if (X == total_level[N - 1] + 1) return total_party[N - 1]; if (X == total_level[N] || X == total_level[N] - 1) return total_party[N]; if (X < total_level[N - 1] + 1) { return solve(N - 1, X - 1); } if (X > total_level[N - 1] + 2) { return solve(N - 1, X - total_level[N - 1] - 2) + 1 + total_party[N - 1]; } } int main() { // freopen("./input.txt", "r", stdin); int N; __int128 X, ans; scanf("%d", &N); scan(X); total_level[1] = 5; total_party[1] = 3; for (int i = 2; i <= N; i++) { total_level[i] = total_level[i - 1] * 2 + 3; total_party[i] = total_party[i - 1] * 2 + 1; } ans = solve(N, X); print(ans); printf("\n"); return 0; }
insert
51
51
51
53
0
p03210
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int X; scanf("%d", X); if (X == 3) printf("%s", "YES"); else if (X == 5) printf("%s", "YES"); else if (X == 7) printf("%s", "YES"); else printf("%s", "NO"); }
#include <bits/stdc++.h> using namespace std; int main() { int X; scanf("%d", &X); if (X == 3) printf("%s", "YES"); else if (X == 5) printf("%s", "YES"); else if (X == 7) printf("%s", "YES"); else printf("%s", "NO"); }
replace
5
6
5
6
-11
p03210
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
replace
52
54
52
53
TLE
p03210
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
replace
52
54
52
53
TLE
p03210
C++
Runtime Error
#include <stdio.h> int main() { int x; scanf("%d", x); if (x != 1 && x != 9 && x % 2 == 1) { printf("YES"); return 0; } printf("NO"); return 0; }
#include <stdio.h> int main() { int x; scanf("%d", &x); if (x != 1 && x != 9 && x % 2 == 1) { printf("YES"); return 0; } printf("NO"); return 0; }
replace
4
5
4
5
-11
p03210
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; // for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
replace
52
54
52
54
TLE
p03210
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
replace
52
54
52
53
TLE
p03210
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; for (int i = 0; i < 1e9; ++i) cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> using namespace std; struct BoolName : numpunct<char> { string t, f; BoolName(string t = "Yes", string f = "No") : t(t), f(f) {} string do_truename() const { return t; } string do_falsename() const { return f; } }; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15) << boolalpha; cout.imbue(locale(cout.getloc(), new BoolName)); } } initializer; template <typename T> istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) s >> t; return s; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { for (const T &t : v) s << t << endl; return s; } void set_bool_name(string t, string f) { cout.imbue(locale(cout.getloc(), new BoolName(t, f))); } int main() { set_bool_name("YES", "NO"); int x; cin >> x; cout << (x == 3 || x == 5 || x == 7) << endl; }
replace
52
54
52
53
TLE
p03210
Python
Runtime Error
#!/usr/bin/env python3 a = int(input()) a, b = list(map(int, input().split())) a = list(str(input()))
#!/usr/bin/env python3 x = int(input()) if x == 3 or x == 5 or x == 7: print("YES") else: print("NO")
replace
2
5
2
8
EOFError: EOF when reading a line
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03210/Python/s739413400.py", line 4, in <module> a, b = list(map(int, input().split())) EOFError: EOF when reading a line
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int checker(int x) { if (x >= 753) { return x - 753; } else return 753 - x; } int main() { string S; cin >> S; int SIZE = S.size() - 2; int MY = stoi(S); vector<int> gard(SIZE); for (int i = 0; i < SIZE; i++) { gard.at(i) = checker(MY % 1000); MY /= 10; } sort(gard.begin(), gard.end()); cout << gard.at(0) << endl; }
#include <bits/stdc++.h> using namespace std; int checker(int x) { if (x >= 753) { return x - 753; } else return 753 - x; } int main() { string S; cin >> S; int SIZE = S.size() - 2; int64_t MY = stoll(S); vector<int> gard(SIZE); for (int i = 0; i < SIZE; i++) { gard.at(i) = checker(MY % 1000); MY /= 10; } sort(gard.begin(), gard.end()); cout << gard.at(0) << endl; }
replace
14
15
14
15
0
p03211
C++
Runtime Error
#include <fstream> #include <iostream> #include <string> using namespace std; int main() { string S; std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); cin >> S; int imin = 1000; int tmp; for (int i = 0; i <= S.size() - 3; i++) { tmp = stoi(S.substr(i, 3)); tmp = abs(753 - tmp); imin = min(imin, tmp); } cout << imin << endl; }
#include <fstream> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int imin = 1000; int tmp; for (int i = 0; i <= S.size() - 3; i++) { tmp = stoi(S.substr(i, 3)); tmp = abs(753 - tmp); imin = min(imin, tmp); } cout << imin << endl; }
delete
10
12
10
10
-6
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; int N = S.size(); vector<int> A(N - 2); for (int i = 0; i < N - 2; i++) { string s = ""; for (int j = 0; j < 3; j++) { s += S.at(i + j); } A.at(i) = stoi(s); } int Min = 1000; for (int i = 0; i < N - 2; i++) if (abs(A.at(i) - 753) <= Min) Min = abs(A.at(i) - 753); cout << Min << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(); vector<int> A(N - 2); for (int i = 0; i < N - 2; i++) { string s = ""; for (int j = 0; j < 3; j++) { s += S.at(i + j); } A.at(i) = stoi(s); } int Min = 1000; for (int i = 0; i < N - 2; i++) if (abs(A.at(i) - 753) <= Min) Min = abs(A.at(i) - 753); cout << Min << endl; return 0; }
insert
4
4
4
5
-6
terminate called after throwing an instance of 'std::length_error' what(): cannot create std::vector larger than max_size()
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a = s.size(); vector<int> ans(a - 2); for (int i = 0; i < a; i++) { string x = s.substr(i, 3); int y = stoi(x); ans[i] = abs(753 - y); } sort(ans.begin(), ans.end()); cout << ans[0] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a = s.size(); vector<int> ans(a - 2); for (int i = 0; i < a - 2; i++) { string x = s.substr(i, 3); int y = stoi(x); ans[i] = abs(753 - y); } sort(ans.begin(), ans.end()); cout << ans[0] << endl; }
replace
8
9
8
9
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int c = 1000; for (int i = 0; i < a.size() - 1; i++) { if (c > abs((a.at(i) - '0') * 100 + (a.at(i + 1) - '0') * 10 + (a.at(i + 2) - '0') - 753)) c = abs((a.at(i) - '0') * 100 + (a.at(i + 1) - '0') * 10 + (a.at(i + 2) - '0') - 753); } cout << c; }
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int c = 1000; for (int i = 0; i < a.size() - 2; i++) { if (c > abs((a.at(i) - '0') * 100 + (a.at(i + 1) - '0') * 10 + (a.at(i + 2) - '0') - 753)) c = abs((a.at(i) - '0') * 100 + (a.at(i + 1) - '0') * 10 + (a.at(i + 2) - '0') - 753); } cout << c; }
replace
7
8
7
8
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 10) >= this->size() (which is 10)
p03211
C++
Time Limit Exceeded
#include <algorithm> #include <cstring> #include <iostream> using namespace std; int main() { int i, len, ans = 100000; char s[12]; cin >> s; len = strlen(s); // cout <<s << endl << len<< endl; for (i = 0; i < len; i++) // cout << s[i] <<endl; for (i = 0; i < len - 2; i++) { ans = min(abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0' - 753), ans); // cout << s[i] << endl; } cout << ans; return 0; }
#include <algorithm> #include <cstring> #include <iostream> using namespace std; int main() { int i, len, ans = 100000; char s[12]; cin >> s; len = strlen(s); for (i = 0; i < len - 2; i++) { ans = min( abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0' - 753), ans); } cout << ans; return 0; }
replace
9
18
9
14
TLE
p03211
C++
Runtime Error
#include <iostream> #include <stdlib.h> #include <string> using namespace std; int main() { string S; cin >> S; int min = 1000; for (int i = 0; i < 7; i++) { if (abs(753 - stoi(S.substr(i, 3))) < min) { min = abs(753 - stoi(S.substr(i, 3))); } } cout << min; }
#include <iostream> #include <stdlib.h> #include <string> using namespace std; int main() { string S; cin >> S; int min = 1000; for (int i = 0; i < S.size() - 2; i++) { if (abs(753 - stoi(S.substr(i, 3))) < min) { min = abs(753 - stoi(S.substr(i, 3))); } } cout << min; }
replace
8
9
8
9
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; int main() { string S; cin >> S; int n = S.length(); int Snum = stoi(S); int ans = 999; for (int i = 0; i < n - 2; i++) { int M = abs(Snum % 1000 - 753); ans = min(M, ans); if (ans == 0) break; Snum = Snum / 10; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; int main() { string S; cin >> S; int n = S.length(); ll Snum = stoll(S); int ans = 999; for (int i = 0; i < n - 2; i++) { int M = abs(Snum % 1000 - 753); ans = min(M, ans); if (ans == 0) break; Snum = Snum / 10; } cout << ans << endl; return 0; }
replace
10
11
10
11
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1000; for (int i = 0; s.size() - 2; i++) { int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0'); ans = min(ans, abs(num - 753)); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1000; for (int i = 0; i < s.size() - 2; i++) { int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0'); ans = min(ans, abs(num - 753)); } cout << ans << endl; }
replace
7
8
7
8
-11
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main(void) { string S; cin >> S; int jud, min = 1000, a; for (int i = 0; i < S.length(); i++) { for (int t = S.length() - i; t > 0; t--) { a = stoi(S.substr(i, t)); if (753 - a >= 0) jud = 753 - a; else jud = a - 753; if (jud <= min) min = jud; } } cout << min; }
#include <bits/stdc++.h> using namespace std; int main(void) { string S; cin >> S; int jud, min = 1000, a; for (int i = 0; i <= S.length() - 2; i++) { a = stoi(S.substr(i, 3)); if (753 - a >= 0) jud = 753 - a; else jud = a - 753; if (jud <= min) min = jud; } cout << min; }
replace
7
17
7
15
0
p03211
C++
Runtime Error
#include <algorithm> #include <cstdio> using namespace std; int main() { char s[11]; scanf("%s", s); int tmp = 2, min = 1000; while (s[tmp] != '\n') { int n; n = 100 * (s[tmp - 2] - '0') + 10 * (s[tmp - 1] - '0') + (s[tmp] - '0'); if (abs(n - 753) < min) min = abs(n - 753); tmp++; } printf("%d\n", min); return 0; }
#include <algorithm> #include <cstdio> using namespace std; int main() { char s[11]; scanf("%s", s); int tmp = 2, min = 1000; while (s[tmp] != '\0') { int n; n = 100 * (s[tmp - 2] - '0') + 10 * (s[tmp - 1] - '0') + (s[tmp] - '0'); if (abs(n - 753) < min) min = abs(n - 753); tmp++; } printf("%d\n", min); return 0; }
replace
10
11
10
11
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001 #define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010 #define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100 #define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000 #define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000 #define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000 #define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000 #define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INF = 1 << 29; const int MAX = 510000; const int MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int ans = INF; rep(i, s.size() - 2) { string tmp = ""; tmp = s[i] + s[i + 1] + s[i + 2]; int num = stoi(tmp); chmin(ans, abs(753 - num)); } cout << ans << endl; }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001 #define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010 #define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100 #define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000 #define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000 #define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000 #define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000 #define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INF = 1 << 29; const int MAX = 510000; const int MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int ans = INF; rep(i, s.size() - 2) { chmin(ans, abs(753 - stoi(s.substr(i, 3)))); } cout << ans << endl; }
replace
62
68
62
63
-6
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s, spart; cin >> s; int min = 999; int tmp = 0; for (int i = 0; i < s.length() - 2; i++) { spart = s[i] + s[i + 1] + s[i + 2]; tmp = stoi(spart); if (min > abs(tmp - 753)) min = abs(tmp - 753); } cout << min << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, spart; cin >> s; int min = 999; int tmp = 0; for (int i = 0; i < s.length() - 2; i++) { spart = s.substr(i, 3); tmp = stoi(spart); if (min > abs(tmp - 753)) min = abs(tmp - 753); } cout << min << endl; return 0; }
replace
9
10
9
10
-6
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int a = 1000; for (int i = 0; i < S.size() - 2; i++) { a = min(abs(753 - ((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + S.at(i - 2) - '0')), a); } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int a = 1000; for (int i = 0; i < S.size() - 2; i++) { a = min(abs(753 - ((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + S.at(i + 2) - '0')), a); } cout << a << endl; }
replace
9
10
9
10
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 18446744073709551614) >= this->size() (which is 10)
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s; cin >> s; int u = stoi(s); vector<int> a(s.size()); for (int i = 0; i < s.size(); i++) { a[i] = u % 10; u = u / 10; } reverse(a.begin(), a.end()); int minV = 1000; for (int i = 0; i < s.size() - 2; i++) { minV = min(minV, abs(753 - (a[i] * 100 + a[i + 1] * 10 + a[i + 2]))); } cout << minV << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s; cin >> s; ll u = stol(s); vector<int> a(s.size()); for (int i = 0; i < s.size(); i++) { a[i] = u % 10; u = u / 10; } reverse(a.begin(), a.end()); int minV = 1000; for (int i = 0; i < s.size() - 2; i++) { minV = min(minV, abs(753 - (a[i] * 100 + a[i + 1] * 10 + a[i + 2]))); } cout << minV << endl; return 0; }
replace
8
9
8
9
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string x; int z, result = 1000; cin >> x; for (int i = 0; i < 9; i++) { string s = x.substr(i, 3); z = abs(stoi(s) - 753); result = min(result, z); } cout << result << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string x; int z, result = 1000; cin >> x; for (int i = 0; i < x.length() - 2; i++) { string s = x.substr(i, 3); z = abs(stoi(s) - 753); result = min(result, z); } cout << result << endl; }
replace
7
8
7
8
0
p03211
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; // cout << fixed << setprecision(20); signed main() { int S; cin >> S; int ans = 114514; for (; S >= 100; S / 10) { int a = abs(S % 1000 - 753); if (abs(S % 1000 - 753) < ans) ans = a; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; // cout << fixed << setprecision(20); signed main() { int S; cin >> S; int ans = 114514; for (; S >= 100; S /= 10) { int a = abs(S % 1000 - 753); if (abs(S % 1000 - 753) < ans) ans = a; } cout << ans << endl; }
replace
15
16
15
16
TLE
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; vector<int> a(S.length() - 2); for (int i = 0; i < S.length() - 2; i++) { a[i] = abs(753 - stoi(S.substr(i, 3))); } sort(a.begin(), a.end()); cout << a[0] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; vector<int> a(S.length() - 2); for (int i = 0; i < S.length() - 2; i++) { a[i] = abs(753 - stoi(S.substr(i, 3))); } sort(a.begin(), a.end()); cout << a[0] << 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()
p03211
C++
Runtime Error
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int ret = stoi(S); for (auto i = 0u; i < S.size() - 2; ++i) { auto s = S.substr(i, 3); ret = min(ret, abs(753 - stoi(s))); } cout << ret << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int ret = 1000; for (auto i = 0u; i < S.size() - 2; ++i) { auto s = S.substr(i, 3); ret = min(ret, abs(753 - stoi(s))); } cout << ret << endl; return 0; }
replace
12
13
12
13
0
p03211
C++
Runtime Error
#include <iostream> #include <string> #include <vector> using namespace std; int abs(int a, int b) { if (a >= b) { return a - b; } else { return b - a; } } int main() { string S; cin >> S; int s = (int)S.size(); vector<int> T; for (int i = 0; i < s; i++) { T[i] = S[i] - '0'; } int min_diff = 1e4; for (int i = 0; i <= s - 3; i++) { int x = 100 * T[i] + 10 * T[i + 1] + T[i + 2]; min_diff = min(min_diff, abs(753, x)); } cout << min_diff << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int abs(int a, int b) { if (a >= b) { return a - b; } else { return b - a; } } int main() { string S; cin >> S; int s = (int)S.size(); vector<int> T(s); for (int i = 0; i < s; i++) { T[i] = S[i] - '0'; } int min_diff = 1e4; for (int i = 0; i <= s - 3; i++) { int x = 100 * T[i] + 10 * T[i + 1] + T[i + 2]; min_diff = min(min_diff, abs(753, x)); } cout << min_diff << endl; return 0; }
replace
18
19
18
19
-11
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string vec; cin >> vec; ll b = 1000; for (ll i = 0; i < 7; i++) { ll c, d, e; c = vec.at(i) - '0'; d = vec.at(i + 1) - '0'; e = vec.at(i + 2) - '0'; b = min(b, abs(100 * c + 10 * d + e - 753)); } cout << b << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string vec; cin >> vec; ll b = 1000; ll x = vec.size(); for (ll i = 0; i < vec.size() - 2; i++) { ll c, d, e; c = vec.at(i) - '0'; d = vec.at(i + 1) - '0'; e = vec.at(i + 2) - '0'; b = min(b, abs(100 * c + 10 * d + e - 753)); } cout << b << endl; return 0; }
replace
7
8
7
9
0
p03211
C++
Runtime Error
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); i++) #define pf(n) printf("%d\n", n) typedef long long ll; typedef pair<ll, ll> p; const int INF = 1001001001; const double PI = acos(-1); int main() { string s; cin >> s; int org = stoi(s); vector<int> ket(s.size()); int t = s.size(); for (int i = 0; i < t; i++) { ket[i] = org % 10; org /= 10; } reverse(ket.begin(), ket.end()); int ans = 999; for (int i = 0; i < t - 2; i++) { int num = 100 * ket[i] + 10 * ket[i + 1] + ket[i + 2]; ans = min(ans, abs(753 - num)); } cout << ans << endl; return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); i++) #define pf(n) printf("%d\n", n) typedef long long ll; typedef pair<ll, ll> p; const int INF = 1001001001; const double PI = acos(-1); int main() { string s; cin >> s; int n = s.length(); int ans = INF; for (int i = 0; i <= n - 3; i++) { int x = (s[i] - '0'); int y = (s[i + 1] - '0'); int z = (s[i + 2] - '0'); int a = 100 * x + 10 * y + z; ans = min(ans, abs(753 - a)); } cout << ans << endl; return 0; }
replace
20
33
20
28
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int counter = 10000; int n = stoi(s); deque<int> a; while (n > 0) { a.push_front(n % 10); n = n / 10; } for (int i = 0; i < a.size() - 2; i++) { counter = min(counter, abs(a.at(i) * 100 + a.at(i + 1) * 10 + a.at(i + 2) - 753)); } cout << counter << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int counter = 10000; long long n = stoll(s); deque<int> a; while (n > 0) { a.push_front(n % 10); n = n / 10; } for (int i = 0; i < a.size() - 2; i++) { counter = min(counter, abs(a.at(i) * 100 + a.at(i + 1) * 10 + a.at(i + 2) - 753)); } cout << counter << endl; }
replace
7
8
7
8
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string S; cin >> S; int diff = 753, t = 753; int s = stoi(S); int length = S.size(); cout << s << endl; for (int i = 0; i < S.size() - 3; i++) { diff = 753 - s / (int)pow(10, length - 3); cout << s / (int)pow(10, length - 3) << endl; if (abs(diff) <= t) { t = abs(diff); } s = s % (int)pow(10, length - 1); length -= 1; cout << s << " " << length << endl; } cout << t; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string s; cin >> s; int diff, t = 753; for (int i = 0; i < s.size() - 2; i++) { diff = 753 - (s[i] - '0') * 100 - (s[i + 1] - '0') * 10 - (s[i + 2] - '0'); t = min(t, abs(diff)); } cout << t; return 0; }
replace
6
21
6
12
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long a, ans; cin >> a; ans = abs(a % 1000 - 753); for (int i = 10; i < 10000000000000; i = i * 10) { if (abs((a % (i * 1000) / i) - 753) < ans) { ans = abs((a % (i * 1000) / i) - 753); } if (a / (i * 1000) == 0) { break; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, ans; cin >> a; ans = abs(a % 1000 - 753); for (long long i = 10; i < 10000000000000; i = i * 10) { if (abs((a % (i * 1000) / i) - 753) < ans) { ans = abs((a % (i * 1000) / i) - 753); } if (a / (i * 1000) == 0) { break; } } cout << ans << endl; }
replace
7
8
7
8
0
p03211
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { string s, t = ""; cin >> s; int ans = 999; rep(i, s.size() - 2) { t += s[i] + s[i + 1] + s[i + 2]; ans = min(ans, abs(753 - stoi(t))); t = ""; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { string s, t = ""; cin >> s; int ans = 999; rep(i, s.size() - 2) { t += s[i]; t += s[i + 1]; t += s[i + 2]; ans = min(ans, abs(753 - stoi(t))); t = ""; } cout << ans << endl; return 0; }
replace
12
13
12
15
-6
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
p03211
C++
Runtime Error
#include <algorithm> #include <array> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <sstream> #include <string> #include <utility> #include <vector> typedef long long ll; using namespace std; int main(int argc, char const *argv[]) { string s; cin >> s; vector<int> a; ll n = stoi(s); for (int i = 0; i < s.length(); ++i) { a.push_back(n % 10); n /= 10; } reverse(a.begin(), a.end()); // for (auto g : a) cout << g << std::endl; vector<int> b; for (int i = 0; i < s.length() - 2; ++i) { b.push_back(a[i] * 100 + a[i + 1] * 10 + a[i + 2]); } int min = 1 << 29; for (int i = 0; i < s.length() - 2; ++i) { int x = abs(b[i] - 753); if (x < min) min = x; } cout << min << std::endl; return 0; }
#include <algorithm> #include <array> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <sstream> #include <string> #include <utility> #include <vector> typedef long long ll; using namespace std; int main(int argc, char const *argv[]) { string s; cin >> s; vector<int> a; ll n = stoll(s); for (int i = 0; i < s.length(); ++i) { a.push_back(n % 10); n /= 10; } reverse(a.begin(), a.end()); // for (auto g : a) cout << g << std::endl; vector<int> b; for (int i = 0; i < s.length() - 2; ++i) { b.push_back(a[i] * 100 + a[i + 1] * 10 + a[i + 2]); } int min = 1 << 29; for (int i = 0; i < s.length() - 2; ++i) { int x = abs(b[i] - 753); if (x < min) min = x; } cout << min << std::endl; return 0; }
replace
17
18
17
18
0
p03211
C++
Runtime Error
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using ld = long double; // #define int long long // #define _CRT_SECURE_NO_WARNINGS #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG #define ALL(x) (x).begin(), (x).end() const int MOD = 1e9 + 7; const int INF = 1e18 + 9; constexpr long double pi = 3.141592653589793238462643383279; int fact(int i) { if (i == 0) return 1; return (fact(i - 1)) * i; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } int keta(int n) { if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } int ketasum(int n) { int sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } 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; } char toSmall(char c) { // 大文字を小文字へ return (c + 0x20); } char toLarge(char c) { // 小文字を大文字へ return (c - 0x20); } float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } string s; int sum; int ans; int main(void) { ans = 999; for (int i = 0; i < s.size() - 2; ++i) { sum = 100 * (s.at(i) - '0') + 10 * (s.at(i + 1) - '0') + (s.at(i + 2) - '0'); ans = min(ans, abs(753 - sum)); } cout << ans << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using ld = long double; // #define int long long // #define _CRT_SECURE_NO_WARNINGS #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG #define ALL(x) (x).begin(), (x).end() const int MOD = 1e9 + 7; const int INF = 1e18 + 9; constexpr long double pi = 3.141592653589793238462643383279; int fact(int i) { if (i == 0) return 1; return (fact(i - 1)) * i; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } int keta(int n) { if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } int ketasum(int n) { int sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } 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; } char toSmall(char c) { // 大文字を小文字へ return (c + 0x20); } char toLarge(char c) { // 小文字を大文字へ return (c - 0x20); } float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } string s; int sum; int ans; int main(void) { cin >> s; ans = 999; for (int i = 0; i < s.size() - 2; ++i) { sum = 100 * (s.at(i) - '0') + 10 * (s.at(i + 1) - '0') + (s.at(i + 2) - '0'); ans = min(ans, abs(753 - sum)); } cout << ans << endl; return 0; }
insert
109
109
109
110
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 0) >= this->size() (which is 0)
p03211
C++
Runtime Error
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; int main() { string s; int MIN = INF; for (int i = 0; i < s.size() - 2; i++) { int num = abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753); MIN = min(MIN, num); } cout << MIN << endl; }
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; int main() { string s; cin >> s; int MIN = INF; for (int i = 0; i < s.size() - 2; i++) { int num = abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753); MIN = min(MIN, num); } cout << MIN << endl; }
insert
11
11
11
12
-11
p03211
C++
Runtime Error
#include <assert.h> #include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1e9; for (int i = 0; i < s.size(); i++) for (int j = 1; j < s.size() - i + 1; j++) ans = min(ans, abs(753 - stoi(s.substr(i, j)))); cout << ans << endl; return 0; }
#include <assert.h> #include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1e9; for (int i = 0; i < s.size() - 2; i++) ans = min(ans, abs(753 - stoi(s.substr(i, 3)))); cout << ans << endl; return 0; }
replace
9
12
9
11
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define per(i, a, b) for (ll i = a; i >= b; i--) using namespace std; typedef vector<ll> vi; typedef vector<vector<ll>> vvi; const string defaultval = "753"; ll dfs(string s, int n) { ll x = stoi(s); if (x > n) return 0; ll ret = 0; if (count(s.begin(), s.end(), '7') > 0 && count(s.begin(), s.end(), '5') > 0 && count(s.begin(), s.end(), '3') > 0) ret = 1; for (char c : defaultval) { s.push_back(c); ret += dfs(s, n); s.pop_back(); } return ret; } int main() { ll n; cin >> n; string start = "0"; cout << dfs(start, n); }
#include <bits/stdc++.h> #include <iostream> typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define per(i, a, b) for (ll i = a; i >= b; i--) using namespace std; typedef vector<ll> vi; typedef vector<vector<ll>> vvi; const string defaultval = "753"; ll dfs(string s, ll n) { ll x = stoll(s); if (x > n) return 0; ll ret = 0; if (count(s.begin(), s.end(), '7') > 0 && count(s.begin(), s.end(), '5') > 0 && count(s.begin(), s.end(), '3') > 0) ret = 1; for (char c : defaultval) { s.push_back(c); ret += dfs(s, n); s.pop_back(); } return ret; } int main() { ll n; cin >> n; string start = "0"; cout << dfs(start, n); }
replace
11
13
11
13
0
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; if (n < 357) { puts("0"); return 0; } int ans = 0; for (int i = 357; i <= n; i += 2) { int temp = i; bool while_flag = true; bool count3 = false; bool count5 = false; bool count7 = false; switch (temp % 100) { case 33: count3 = true; break; case 35: count3 = true; count5 = true; break; case 37: count3 = true; count7 = true; break; case 53: count5 = true; count3 = true; break; case 55: count5 = true; break; case 57: count5 = true; count7 = true; break; case 73: count7 = true; count3 = true; break; case 75: count7 = true; count5 = true; break; case 77: count7 = true; break; default: while_flag = false; break; } temp /= 100; while (temp && while_flag) { switch (temp % 10) { case 3: count3 = true; break; case 5: count5 = true; break; case 7: count7 = true; break; default: while_flag = false; break; } if (!while_flag) break; temp /= 10; } if (while_flag && count3 && count5 && count7) { // cout << i << endl; ans++; } if (i % 10 == 7) { i += 4; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; if (n < 357) { puts("0"); return 0; } int ans = 0; for (int i = 357; i <= n; i += 2) { int temp = i; bool while_flag = true; bool count3 = false; bool count5 = false; bool count7 = false; switch (temp % 100) { case 33: count3 = true; break; case 35: count3 = true; count5 = true; break; case 37: count3 = true; count7 = true; break; case 53: count5 = true; count3 = true; break; case 55: count5 = true; break; case 57: count5 = true; count7 = true; break; case 73: count7 = true; count3 = true; break; case 75: count7 = true; count5 = true; break; case 77: count7 = true; break; default: while_flag = false; break; } temp /= 100; while (temp && while_flag) { switch (temp % 10) { case 3: count3 = true; break; case 5: count5 = true; break; case 7: count7 = true; break; default: while_flag = false; break; } if (!while_flag) break; temp /= 10; } if (while_flag && count3 && count5 && count7) { // cout << i << endl; ans++; } if (i % 10 == 7) { i += 4; } if (i > 800000000) { ans = 26484; break; } } cout << ans << endl; return 0; }
insert
88
88
88
92
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() typedef int64_t ll; typedef vector<int> VI; typedef pair<ll, ll> pii; const int MD = 1e9 + 7; typedef vector<ll> VL; void dbg() { cerr << "\n"; } template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) { cerr << fst << ": "; dbg(rst...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); string s; cin >> s; int m = sz(s), n = stoi(s), ans = 0; int mt[] = {3, 5, 7}; VI cnd, ct(m, 0); auto rec = [&](auto f, int idx) -> void { if (idx >= 3) { int w = 0; VI usd(3); rep(i, idx) { w = w * 10 + mt[ct[i]]; usd[ct[i]] = 1; } if (w >= 1 && w <= n && count(all(usd), 1) == 3) { ans++; } if (idx == m) return; } rep(i, 3) { ct[idx] = i; f(f, idx + 1); } }; rec(rec, 0); cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() typedef int64_t ll; typedef vector<int> VI; typedef pair<ll, ll> pii; const int MD = 1e9 + 7; typedef vector<ll> VL; void dbg() { cerr << "\n"; } template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) { cerr << fst << ": "; dbg(rst...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); string s; cin >> s; int m = sz(s), n = stoi(s), ans = 0; if (n < 357) { puts("0"); return 0; } int mt[] = {3, 5, 7}; VI cnd, ct(m, 0); auto rec = [&](auto f, int idx) -> void { if (idx >= 3) { int w = 0; VI usd(3); rep(i, idx) { w = w * 10 + mt[ct[i]]; usd[ct[i]] = 1; } if (w >= 1 && w <= n && count(all(usd), 1) == 3) { ans++; } if (idx == m) return; } rep(i, 3) { ct[idx] = i; f(f, idx + 1); } }; rec(rec, 0); cout << ans << "\n"; return 0; }
insert
30
30
30
34
0
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int llui_t; typedef long long int lli_t; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) /* inputs */ llui_t N; vector<llui_t> X; int main() { cin >> N; llui_t ans = 0; uint is7, is5, is3, no753; for (llui_t i = 0; i < N; i++) { llui_t n = i + 1; is7 = 0; is5 = 0; is3 = 0; no753 = 0; while (n > 0) { uint j = n % 10; if (j != 7 && j != 5 && j != 3) { no753 = 1; break; } if (j == 7) { is7 += 1; } if (j == 5) { is5 += 1; } if (j == 3) { is3 += 1; } n = n / 10; } // cout << i << "/" << is7 << "," << is5 << "," << is3 << "," << no753 << // endl; if (is7 > 0 && is5 > 0 && is3 > 0 && no753 == 0) { ans += 1; } } cout << ans << endl; }
#include <algorithm> #include <array> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int llui_t; typedef long long int lli_t; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) /* inputs */ llui_t N; vector<llui_t> X; int main() { cin >> N; llui_t ans = 0; uint is7, is5, is3, no753; for (llui_t i = 1; i < N + 1; i += 2) { llui_t n = i; is7 = 0; is5 = 0; is3 = 0; no753 = 0; while (n > 0) { uint j = n % 10; if (j != 7 && j != 5 && j != 3) { no753 = 1; break; } if (j == 7) { is7 += 1; } if (j == 5) { is5 += 1; } if (j == 3) { is3 += 1; } n = n / 10; } // cout << i << "/" << is7 << "," << is5 << "," << is3 << "," << no753 << // endl; if (is7 > 0 && is5 > 0 && is3 > 0 && no753 == 0) { ans += 1; } } cout << ans << endl; }
replace
34
36
34
36
TLE
p03212
C++
Time Limit Exceeded
#include <iostream> #include <queue> using namespace std; int n, ans, now, cnt3, cnt5, cnt7; queue<string> q; int main() { cin >> n; q.push("3"); q.push("5"); q.push("7"); while (!q.empty()) { string s = q.front(); q.pop(); now = 0; cnt3 = 0; cnt5 = 0; cnt7 = 0; for (int i = 1; i <= s.length(); i++) { now *= 10; now += s[i - 1] - '0'; if (s[i - 1] == '3') cnt3++; if (s[i - 1] == '5') cnt5++; if (s[i - 1] == '7') cnt7++; } if (now <= n) { if (cnt3 && cnt5 && cnt7) ans++; q.push("3" + s); q.push("5" + s); q.push("7" + s); } } cout << ans << endl; return 0; }
#include <iostream> #include <queue> using namespace std; long long n, ans, now, cnt3, cnt5, cnt7; queue<string> q; int main() { cin >> n; q.push("3"); q.push("5"); q.push("7"); while (!q.empty()) { string s = q.front(); q.pop(); now = 0; cnt3 = 0; cnt5 = 0; cnt7 = 0; for (int i = 1; i <= s.length(); i++) { now *= 10; now += s[i - 1] - '0'; if (s[i - 1] == '3') cnt3++; if (s[i - 1] == '5') cnt5++; if (s[i - 1] == '7') cnt7++; } if (now <= n) { if (cnt3 && cnt5 && cnt7) ans++; q.push("3" + s); q.push("5" + s); q.push("7" + s); } } cout << ans << endl; return 0; }
replace
5
6
5
6
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, b) for (int i = 0; i < (b); i++) #define REPS(i, b) for (int i = 1; i <= (b); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using ll = long long; ll N, ans; bool is753(string s) { vector<int> c(3, 0); REP(i, s.length()) { if (s[i] == '7') c[0]++; else if (s[i] == '5') c[1]++; else if (s[i] == '3') c[2]++; } if (c[0] > 0 && c[1] > 0 && c[2] > 0) return true; return false; } int dfs(string s) { ll res = 0; if (stoi(s) > N) return 0; if (is753(s)) res++; res += dfs(s + "7"); res += dfs(s + "5"); res += dfs(s + "3"); return res; } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); cin >> N; ans += dfs("7"); ans += dfs("5"); ans += dfs("3"); cout << ans << endl; }
#include <bits/stdc++.h> #define REP(i, b) for (int i = 0; i < (b); i++) #define REPS(i, b) for (int i = 1; i <= (b); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using ll = long long; ll N, ans; bool is753(string s) { vector<int> c(3, 0); REP(i, s.length()) { if (s[i] == '7') c[0]++; else if (s[i] == '5') c[1]++; else if (s[i] == '3') c[2]++; } if (c[0] > 0 && c[1] > 0 && c[2] > 0) return true; return false; } int dfs(string s) { ll res = 0; if (stoll(s) > N) return 0; if (is753(s)) res++; res += dfs(s + "7"); res += dfs(s + "5"); res += dfs(s + "3"); return res; } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); cin >> N; ans += dfs("7"); ans += dfs("5"); ans += dfs("3"); cout << ans << endl; }
replace
27
28
27
28
0
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; bool check(int a) { bool b3 = false, b5 = false, b7 = false; while (a) { switch (a % 10) { case 3: b3 = true; break; case 5: b5 = true; break; case 7: b7 = true; break; default: return false; } a /= 10; } return (b3 && b5 && b7); } int main() { int n; int ans = 0; cin >> n; for (int i = 357; i <= n;) { if (check(i)) { ans++; } switch (i) { case 77777753: i = 333333357; break; case 337777775: i = 353333337; break; case 357777777: i = 373333335; break; case 377777775: i = 533333337; break; case 537777777: i = 553333337; break; case 557777773: i = 573333333; break; case 577777773: i = 733333335; break; case 737777775: i = 753333333; break; case 757777773: i = 773333335; break; case 777777753: i = n; break; default: i += 2; break; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool check(int a) { bool b3 = false, b5 = false, b7 = false; while (a) { switch (a % 10) { case 3: b3 = true; break; case 5: b5 = true; break; case 7: b7 = true; break; default: return false; } a /= 10; } return (b3 && b5 && b7); } int main() { int n; int ans = 0; cin >> n; if (n >= 777777753) { cout << 26484 << endl; return 0; } for (int i = 357; i <= n;) { if (check(i)) { ans++; } switch (i) { case 77777753: i = 333333357; break; case 337777775: i = 353333337; break; case 357777777: i = 373333335; break; case 377777775: i = 533333337; break; case 537777777: i = 553333337; break; case 557777773: i = 573333333; break; case 577777773: i = 733333335; break; case 737777775: i = 753333333; break; case 757777773: i = 773333335; break; case 777777753: i = n; break; default: i += 2; break; } } cout << ans << endl; return 0; }
insert
26
26
26
30
TLE
p03212
Python
Runtime Error
n = int(input()) def dfs(s): if int(s) > n: return 0 ret = 1 if all(s.count > 0 for c in "753") else 0 for c in "753": ret += dfs(s + c) return ret print(dfs("0"))
n = int(input()) def dfs(s): if int(s) > n: return 0 ret = 1 if all(s.count(c) > 0 for c in "753") else 0 for c in "753": ret += dfs(s + c) return ret print(dfs("0"))
replace
6
7
6
7
TypeError: '>' not supported between instances of 'builtin_function_or_method' and 'int'
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03212/Python/s633600507.py", line 13, in <module> print(dfs('0')) File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03212/Python/s633600507.py", line 7, in dfs ret = 1 if all(s.count > 0 for c in '753') else 0 File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03212/Python/s633600507.py", line 7, in <genexpr> ret = 1 if all(s.count > 0 for c in '753') else 0 TypeError: '>' not supported between instances of 'builtin_function_or_method' and 'int'
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++) #define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++) #define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--) #define ALL(NAME) (NAME).begin(), (NAME).end() const ll INF = 1000000000000000; ll f357(ll x) { string s = to_string(x); if (s[s.size() - 1] != '3') return x - 2; string t = ""; BREP(i, s.size()) { ll a = s[i] - '0'; if (a != 3) { REP(j, i) t += s[j]; t += ((s[i] - '0') - 2) + '0'; FOR(k, i + 1, s.size()) t += '7'; return stoll(t); } } REP(i, s.size() - 1) t += '7'; return stoll(t); } ll start357(ll x) { string s = to_string(x); string t = ""; REP(i, s.size()) t += '7'; int y = stoll(t); while (y > x) { y = f357(y); } return y; } bool cnt357(ll x) { string s = to_string(x); bool b3 = 0, b5 = 0, b7 = 0; REP(i, s.size()) { ll a = s[i] - '0'; if (a == 3) b3 = 1; if (a == 5) b5 = 1; if (a == 7) b7 = 1; } if (b3 * b5 * b7 == 1) return true; else return false; } int main() { ll n, strat; cin >> n; ll z = start357(n), cnt = 0; while (z >= 77) { if (cnt357(z) == true) cnt++; z = f357(z); } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++) #define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++) #define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--) #define ALL(NAME) (NAME).begin(), (NAME).end() const ll INF = 1000000000000000; ll f357(ll x) { string s = to_string(x); if (s[s.size() - 1] != '3') return x - 2; string t = ""; BREP(i, s.size()) { ll a = s[i] - '0'; if (a != 3) { REP(j, i) t += s[j]; t += ((s[i] - '0') - 2) + '0'; FOR(k, i + 1, s.size()) t += '7'; return stoll(t); } } REP(i, s.size() - 1) t += '7'; return stoll(t); } ll start357(ll x) { string s = to_string(x); string t = ""; REP(i, s.size()) t += '7'; int y = stoll(t); while (y > x) { y = f357(y); } return y; } bool cnt357(ll x) { string s = to_string(x); bool b3 = 0, b5 = 0, b7 = 0; REP(i, s.size()) { ll a = s[i] - '0'; if (a == 3) b3 = 1; if (a == 5) b5 = 1; if (a == 7) b7 = 1; } if (b3 * b5 * b7 == 1) return true; else return false; } int main() { ll n, strat; cin >> n; if (n < 3) { cout << 0 << endl; return 0; } ll z = start357(n), cnt = 0; while (z >= 77) { if (cnt357(z) == true) cnt++; z = f357(z); } cout << cnt << endl; }
insert
61
61
61
65
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define Rep(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define ll long long ll n; vector<char> c753 = {'3', '5', '7'}; ll dfs(string m) { if (stoi(m.c_str()) > n) return 0; ll res = 1; for (char c : c753) if (m.find(c) == string::npos) res = 0; for (char c : c753) res += dfs(m + c); return res; } int main() { cin >> n; cout << dfs("0") << endl; }
#include <bits/stdc++.h> using namespace std; #define Rep(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define ll long long ll n; vector<char> c753 = {'3', '5', '7'}; ll dfs(string m) { if (stol(m.c_str()) > n) return 0; ll res = 1; for (char c : c753) if (m.find(c) == string::npos) res = 0; for (char c : c753) res += dfs(m + c); return res; } int main() { cin >> n; cout << dfs("0") << endl; }
replace
13
14
13
14
0
p03212
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main(void) { long long N, i, sum = 0; cin >> N; for (i = 3; i < N + 1;) { long long a = 0, b = 0, c = 0, d = 1, n = i; for (; n > 0;) { if (n % 10 == 3) { a = 1; } else if (n % 10 == 5) { b = 1; } else if (n % 10 == 7) { c = 1; } else { d = 0; break; } n = n / 10; } if (a * b * c * d == 1) { sum++; } if (i % 10 == 7) { i += 6; } else { i += 2; } } cout << sum << endl; }
#include <iostream> using namespace std; int main(void) { long long N, i, sum = 0; cin >> N; if (N > 500000000) { sum = 14384; for (i = 500000003; i < N + 1;) { long long a = 0, b = 0, c = 0, d = 1, n = i; for (; n > 0;) { if (n % 10 == 3) { a = 1; } else if (n % 10 == 5) { b = 1; } else if (n % 10 == 7) { c = 1; } else { d = 0; break; } n = n / 10; } if (a * b * c * d == 1) { sum++; } if (i % 10 == 7) { i += 6; } else { i += 2; } } cout << sum << endl; return 0; } for (i = 3; i < N + 1;) { long long a = 0, b = 0, c = 0, d = 1, n = i; for (; n > 0;) { if (n % 10 == 3) { a = 1; } else if (n % 10 == 5) { b = 1; } else if (n % 10 == 7) { c = 1; } else { d = 0; break; } n = n / 10; } if (a * b * c * d == 1) { sum++; } if (i % 10 == 7) { i += 6; } else { i += 2; } } cout << sum << endl; }
insert
5
5
5
34
TLE
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) using namespace std; bool is_good(int x) { map<int, int> mp; while (x > 0) { int res = x % 10; x /= 10; mp[res]++; } if (mp[3] > 0 && mp[5] > 0 && mp[7] > 0 && mp.size() == 3) { return true; } else return false; return 0; } int ans; int n; void dfs(int x) { if (x > n) return; if (is_good(x)) ans++; if (x < 1e9) { dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } } int main() { cin >> n; dfs(0); cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) using namespace std; bool is_good(int x) { map<int, int> mp; while (x > 0) { int res = x % 10; x /= 10; mp[res]++; } if (mp[3] > 0 && mp[5] > 0 && mp[7] > 0 && mp.size() == 3) { return true; } else return false; return 0; } int ans; int n; void dfs(int x) { if (x > n) return; if (is_good(x)) ans++; if (x < 1e8) { dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } } int main() { cin >> n; dfs(0); cout << ans << endl; }
replace
26
27
26
27
TLE
p03212
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; long long int N; bool func(string s) { bool seven = false, five = false, three = false; for (int i = 0; i < s.size(); i++) { if (s[i] == '7') { seven = true; } else if (s[i] == '5') { five = true; } else if (s[i] == '3') { three = true; } else { return false; } } if (seven && five && three) { return true; } return false; } long long int dfs(string s) { long long int ret = 0; // cout<<s<<endl; if (s != "" && stoi(s) > N) { // cout<<s + "b"<<endl; return 0; } // cout<<s + "c"<<endl; if (func(s)) ret = 1; ret += dfs(s + "7"); ret += dfs(s + "5"); ret += dfs(s + "3"); // cout<<s + "a"<<endl; return ret; } int main() { cin >> N; cout << dfs("") << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; long long int N; bool func(string s) { bool seven = false, five = false, three = false; for (int i = 0; i < s.size(); i++) { if (s[i] == '7') { seven = true; } else if (s[i] == '5') { five = true; } else if (s[i] == '3') { three = true; } else { return false; } } if (seven && five && three) { return true; } return false; } long long int dfs(string s) { long long int ret = 0; // cout<<s<<endl; if (s != "" && stoll(s) > N) { // cout<<s + "b"<<endl; return 0; } // cout<<s + "c"<<endl; if (func(s)) ret = 1; ret += dfs(s + "7"); ret += dfs(s + "5"); ret += dfs(s + "3"); // cout<<s + "a"<<endl; return ret; } int main() { cin >> N; cout << dfs("") << endl; return 0; }
replace
40
41
40
41
0
p03212
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9; static const ll INF = 1LL << 50; using namespace std; bool flag_3, flag_5, flag_7; ll n, counts; void func(string s, ll &counts) { if (s == "") ; else if (stoi(s) > n) return; flag_3 = false, flag_5 = false, flag_7 = false; if (s.size()) repp(i, 0, s.size()) { if (s[i] == '3') flag_3 = true; else if (s[i] == '5') flag_5 = true; else if (s[i] == '7') flag_7 = true; } if (flag_3 == true && flag_5 == true && flag_7 == true) ++counts; func(s + "7", counts); func(s + "5", counts); func(s + "3", counts); } int main() { cin >> n; string s = ""; counts = 0; func(s, counts); cout << counts << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9; static const ll INF = 1LL << 50; using namespace std; bool flag_3, flag_5, flag_7; ll n, counts; void func(string s, ll &counts) { if (s == "") ; else if (stoll(s) > n) return; flag_3 = false, flag_5 = false, flag_7 = false; if (s.size()) repp(i, 0, s.size()) { if (s[i] == '3') flag_3 = true; else if (s[i] == '5') flag_5 = true; else if (s[i] == '7') flag_7 = true; } if (flag_3 == true && flag_5 == true && flag_7 == true) ++counts; func(s + "7", counts); func(s + "5", counts); func(s + "3", counts); } int main() { cin >> n; string s = ""; counts = 0; func(s, counts); cout << counts << endl; return 0; }
replace
21
22
21
22
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define ll long long const int N = 1e6 + 5, MOD = 1e9 + 7; using namespace std; ll n, ans = 0; map<ll, bool> vis; bool occ[10]; bool gg(ll a) { memset(occ, 0, sizeof(occ)); while (a) { occ[a % 10] = 1; a /= 10; } return (occ[3] && occ[5] && occ[7]); } std::vector<int> v = {3, 5, 7}; void go(ll a) { vis[a] = 1; if (gg(a)) ans++; for (auto x : v) { if (!vis.count(a * 10 + x) && a * 10 + x <= n) go(a * 10 + x); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); #ifndef ONLINE_JUDGE freopen("test.txt", "r", stdin); #endif cin >> n; go(0); cout << ans << "\n"; }
#include <bits/stdc++.h> #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define ll long long const int N = 1e6 + 5, MOD = 1e9 + 7; using namespace std; ll n, ans = 0; map<ll, bool> vis; bool occ[10]; bool gg(ll a) { memset(occ, 0, sizeof(occ)); while (a) { occ[a % 10] = 1; a /= 10; } return (occ[3] && occ[5] && occ[7]); } std::vector<int> v = {3, 5, 7}; void go(ll a) { vis[a] = 1; if (gg(a)) ans++; for (auto x : v) { if (!vis.count(a * 10 + x) && a * 10 + x <= n) go(a * 10 + x); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; go(0); cout << ans << "\n"; }
delete
38
41
38
38
0
p03212
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <vector> #define rep(i, N) for (int i = 0; i < (int)N; i++) using namespace std; typedef long long ll; const ll LLINF = 9223372036854775807; const int MOD = 1000000007; int N; int dfs(string s) { if (stoi(s) > N) return 0; int result = 0; if (find(s.begin(), s.end(), '3') != s.end() && find(s.begin(), s.end(), '5') != s.end() && find(s.begin(), s.end(), '7') != s.end()) result++; result += dfs(s + "3"); result += dfs(s + "5"); result += dfs(s + "7"); return result; } int main() { cin >> N; cout << dfs("0") << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <vector> #define rep(i, N) for (int i = 0; i < (int)N; i++) using namespace std; typedef long long ll; const ll LLINF = 9223372036854775807; const int MOD = 1000000007; int N; int dfs(string s) { if (stol(s) > N) return 0; int result = 0; if (find(s.begin(), s.end(), '3') != s.end() && find(s.begin(), s.end(), '5') != s.end() && find(s.begin(), s.end(), '7') != s.end()) result++; result += dfs(s + "3"); result += dfs(s + "5"); result += dfs(s + "7"); return result; } int main() { cin >> N; cout << dfs("0") << endl; return 0; }
replace
17
18
17
18
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int MOD = 1000000007; int INF = numeric_limits<int>::max() / 2; int ans = 0; int N; void dfs(string S) { if (stoi(S) > N) return; bool ans3{}, ans5{}, ans7{}; for (int i = 0; i < S.size(); i++) { if (S[i] == '3') ans3 = true; if (S[i] == '5') ans5 = true; if (S[i] == '7') ans7 = true; } if (ans3 && ans5 && ans7) ans++; string T = S + "3"; string U = S + "5"; string W = S + "7"; dfs(T); dfs(U); dfs(W); } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; dfs("3"); dfs("5"); dfs("7"); cout << ans << endl; }
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int MOD = 1000000007; int INF = numeric_limits<int>::max() / 2; int ans = 0; int N; void dfs(string S) { if (stol(S) > N) return; bool ans3{}, ans5{}, ans7{}; for (int i = 0; i < S.size(); i++) { if (S[i] == '3') ans3 = true; if (S[i] == '5') ans5 = true; if (S[i] == '7') ans7 = true; } if (ans3 && ans5 && ans7) ans++; string T = S + "3"; string U = S + "5"; string W = S + "7"; dfs(T); dfs(U); dfs(W); } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; dfs("3"); dfs("5"); dfs("7"); cout << ans << endl; }
replace
11
12
11
12
0
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) vector<int> ans; void c(int x) { string s = to_string(x); bool a = false, b = false, c = false; rep(i, s.size()) { if (s[i] == '3') a = true; if (s[i] == '5') b = true; if (s[i] == '7') c = true; } if (a && b && c) ans.push_back(x); } void d(int x) { if (x < 1000000000) { c(x); d(10 * x + 3); d(10 * x + 5); d(10 * x + 7); } } int main() { int n; cin >> n; d(3); d(5); d(7); sort(ans.begin(), ans.end()); cout << upper_bound(ans.begin(), ans.end(), n) - ans.begin() << endl; getchar(); getchar(); return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) vector<int> ans; void c(int x) { string s = to_string(x); bool a = false, b = false, c = false; rep(i, s.size()) { if (s[i] == '3') a = true; if (s[i] == '5') b = true; if (s[i] == '7') c = true; } if (a && b && c) ans.push_back(x); } void d(int x) { c(x); if (x < 100000000) { d(10 * x + 3); d(10 * x + 5); d(10 * x + 7); } } int main() { int n; cin >> n; d(3); d(5); d(7); sort(ans.begin(), ans.end()); cout << upper_bound(ans.begin(), ans.end(), n) - ans.begin() << endl; getchar(); getchar(); return 0; }
replace
28
30
28
31
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define mod 1000000007 typedef long long ll; int cnt = 0; int n; void dfs(string num) { if (stoi(num) <= n) { bool three = false, five = false, seven = false; rep(i, num.length()) { if (num[i] == '3') three = true; if (num[i] == '5') five = true; if (num[i] == '7') seven = true; } if (three && five && seven) { cnt++; } dfs(num + "3"); dfs(num + "5"); dfs(num + "7"); } } int main() { cin >> n; dfs("3"); dfs("5"); dfs("7"); cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define mod 1000000007 typedef long long ll; int cnt = 0; int n; void dfs(string num) { if (stoll(num) <= n) { bool three = false, five = false, seven = false; rep(i, num.length()) { if (num[i] == '3') three = true; if (num[i] == '5') five = true; if (num[i] == '7') seven = true; } if (three && five && seven) { cnt++; } dfs(num + "3"); dfs(num + "5"); dfs(num + "7"); } } int main() { cin >> n; dfs("3"); dfs("5"); dfs("7"); cout << cnt << endl; return 0; }
replace
11
12
11
12
0
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } ll sft[3] = {3, 5, 7}; ll N; bool check(ll x) { set<ll> s; while (x > 0) { ll k = x % 10; s.insert(k); x /= 10; } if (s.size() == 3) return true; return false; } int dfs(ll x) { ll res = 0; if (check(x)) res++; rep(i, 3) { int y = x * 10 + sft[i]; if (y <= N) { res += dfs(y); } } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; ll ans = dfs(0); cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second void Yes() { cout << "Yes" << endl; exit(0); } void No() { cout << "No" << endl; exit(0); } ll sft[3] = {3, 5, 7}; ll N; bool check(ll x) { set<ll> s; while (x > 0) { ll k = x % 10; s.insert(k); x /= 10; } if (s.size() == 3) return true; return false; } int dfs(ll x) { ll res = 0; if (check(x)) res++; rep(i, 3) { ll y = x * 10 + sft[i]; if (y <= N) { res += dfs(y); } } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; ll ans = dfs(0); cout << ans << endl; return 0; }
replace
72
73
72
73
TLE
p03212
C++
Time Limit Exceeded
/************************************************ *Author : lrj124 *Created Time : 2018.12.02.20:14 *Mail : [email protected] *Problem : c ************************************************/ #include <bits/stdc++.h> using namespace std; int n, ans; inline void dfs(int now) { if (now <= n) { int tmp = now, f1 = 0, f2 = 0, f3 = 0; while (tmp) { int x = tmp % 10; tmp /= 10; if (x == 3) f1 = 1; if (x == 5) f2 = 1; if (x == 7) f3 = 1; } if (f1 && f2 && f3) ans++; } else return; dfs(now * 10 + 3), dfs(now * 10 + 7), dfs(now * 10 + 5); } int main() { scanf("%d", &n); dfs(0); printf("%d", ans); return 0; }
/************************************************ *Author : lrj124 *Created Time : 2018.12.02.20:14 *Mail : [email protected] *Problem : c ************************************************/ #include <bits/stdc++.h> using namespace std; int n, ans; inline void dfs(long long now) { if (now <= n) { int tmp = now, f1 = 0, f2 = 0, f3 = 0; while (tmp) { int x = tmp % 10; tmp /= 10; if (x == 3) f1 = 1; if (x == 5) f2 = 1; if (x == 7) f3 = 1; } if (f1 && f2 && f3) ans++; } else return; dfs(now * 10 + 3), dfs(now * 10 + 7), dfs(now * 10 + 5); } int main() { scanf("%d", &n); dfs(0); printf("%d", ans); return 0; }
replace
9
10
9
10
TLE
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; using P = pair<ll, ll>; const int mod = 1000000007; const int inf = (1 << 30) - 1; const ll linf = (1LL << 62LL) - 1; const double EPS = (1e-10); #define anyfill(n, s) setw(n) << setfill(s) #define loop(s) for (int i = 0; s > i; i++) #define rep(i, q) for (int i = 0; (q) > i; i++) #define repp(i, n, q) for (int i = n; (q) > i; i++) #define dep(i, q) for (int i = (q); 0 < i; i--) #define pb push_back #define fir first #define scn second #define ednl endl #define YesNo(a) (a ? "Yes" : "No") #define YESNO(a) (a ? "YES" : "NO") #define yesno(a) (a ? "yes" : "no") P ar4[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; P ar8[8] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; int dp[10][2]; __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } int main() { string s; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; s.size() > i; i++) { if (s[i] >= '7') { s[i] = '3'; } else if (s[i] >= '5') { s[i] = '2'; } else if (s[i] >= '3') { s[i] = '1'; } else { if (i + 1 != s.size()) { s[i + 1]--; s[i] = '3'; } else { s.pop_back(); } } } reverse(s.begin(), s.end()); string z = "123"; int a = 1; while (z != s) { int nw = z.size() - 1; while (nw >= 0 && z[nw] == '3') nw--; if (nw < 0) { z = "1" + z; for (int i = 0; z.size() > i; i++) { z[i] = '1'; } } else { z[nw++]++; while (nw != z.size()) { z[nw++] = '1'; } } bool g[3] = {0, 0, 0}; for (int i = 0; z.size() > i; i++) { g[z[i] - '1'] = true; } if (g[0] && g[1] && g[2]) a++; } cout << a << endl; }
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; using P = pair<ll, ll>; const int mod = 1000000007; const int inf = (1 << 30) - 1; const ll linf = (1LL << 62LL) - 1; const double EPS = (1e-10); #define anyfill(n, s) setw(n) << setfill(s) #define loop(s) for (int i = 0; s > i; i++) #define rep(i, q) for (int i = 0; (q) > i; i++) #define repp(i, n, q) for (int i = n; (q) > i; i++) #define dep(i, q) for (int i = (q); 0 < i; i--) #define pb push_back #define fir first #define scn second #define ednl endl #define YesNo(a) (a ? "Yes" : "No") #define YESNO(a) (a ? "YES" : "NO") #define yesno(a) (a ? "yes" : "no") P ar4[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; P ar8[8] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; int dp[10][2]; __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } int main() { string s; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; s.size() > i; i++) { if (s[i] >= '7') { s[i] = '3'; } else if (s[i] >= '5') { s[i] = '2'; } else if (s[i] >= '3') { s[i] = '1'; } else { if (i + 1 != s.size()) { s[i + 1]--; s[i] = '3'; } else { s.pop_back(); } } } reverse(s.begin(), s.end()); string z = "122"; int a = 0; while (z.size() <= s.size() && z != s) { int nw = z.size() - 1; while (nw >= 0 && z[nw] == '3') nw--; if (nw < 0) { z = "1" + z; for (int i = 0; z.size() > i; i++) { z[i] = '1'; } } else { z[nw++]++; while (nw != z.size()) { z[nw++] = '1'; } } bool g[3] = {0, 0, 0}; for (int i = 0; z.size() > i; i++) { g[z[i] - '1'] = true; } if (g[0] && g[1] && g[2]) a++; } cout << a << endl; }
replace
68
71
68
71
TLE
p03212
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; using ll = int64_t; string N; ll f(ll d, bool u3, bool u5, bool u7, bool uN) { if (d == N.size()) { return u3 && u5 && u7; } if (uN) { return f(d + 1, true, u5, u7, uN) + f(d + 1, u3, true, u7, uN) + f(d + 1, u3, u5, true, uN); } else { if (N[d] >= '7') { return f(d + 1, true, u5, u7, N[d] > '3') + f(d + 1, u3, true, u7, N[d] > '5') + f(d + 1, u3, u5, true, N[d] > '7'); } else if (N[d] >= '5') { return f(d + 1, true, u5, u7, N[d] > '3') + f(d + 1, u3, true, u7, N[d] > '5'); } else if (N[d] >= '3') { return f(d + 1, true, u5, u7, N[d] > '3'); } else { return 0; } } } int main() { cin >> N; ll ans = 0; for (ll i = 0; i < N.size() - 2; i++) { ans += f(i, false, false, false, i != 0); } cout << ans << endl; }
#include "bits/stdc++.h" using namespace std; using ll = int64_t; string N; ll f(ll d, bool u3, bool u5, bool u7, bool uN) { if (d == N.size()) { return u3 && u5 && u7; } if (uN) { return f(d + 1, true, u5, u7, uN) + f(d + 1, u3, true, u7, uN) + f(d + 1, u3, u5, true, uN); } else { if (N[d] >= '7') { return f(d + 1, true, u5, u7, N[d] > '3') + f(d + 1, u3, true, u7, N[d] > '5') + f(d + 1, u3, u5, true, N[d] > '7'); } else if (N[d] >= '5') { return f(d + 1, true, u5, u7, N[d] > '3') + f(d + 1, u3, true, u7, N[d] > '5'); } else if (N[d] >= '3') { return f(d + 1, true, u5, u7, N[d] > '3'); } else { return 0; } } } int main() { cin >> N; ll ans = 0; for (ll i = 0; i < (ll)N.size() - 2; i++) { ans += f(i, false, false, false, i != 0); } cout << ans << endl; }
replace
33
34
33
34
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int dfs(string s, int n) { if (stoi(s) > n) return 0; int cnt3 = 0, cnt5 = 0, cnt7 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '3') cnt3++; if (s[i] == '5') cnt5++; if (s[i] == '7') cnt7++; } int res = 0; if (cnt3 > 0 && cnt5 > 0 && cnt7 > 0) res++; res += dfs(s + '3', n); res += dfs(s + '5', n); res += dfs(s + '7', n); return res; } int main() { int n; cin >> n; cout << dfs("0", n) << endl; }
#include <bits/stdc++.h> using namespace std; int dfs(string s, int n) { if (stol(s) > n) return 0; int cnt3 = 0, cnt5 = 0, cnt7 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '3') cnt3++; if (s[i] == '5') cnt5++; if (s[i] == '7') cnt7++; } int res = 0; if (cnt3 > 0 && cnt5 > 0 && cnt7 > 0) res++; res += dfs(s + '3', n); res += dfs(s + '5', n); res += dfs(s + '7', n); return res; } int main() { int n; cin >> n; cout << dfs("0", n) << endl; }
replace
4
5
4
5
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define size_of_array(array) (sizeof(array) / sizeof(array[0])) #define MAX 100005 #define NIL -1 using ll = long long; using namespace std; using Graph = vector<vector<int>>; using Field = vector<vector<char>>; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } const ll mod = 1000000007; ll n; ll ans = 0; void check(ll x) { if (x > n) return; int cnt[3] = {}; while (x) { if (x % 10 == 3) cnt[0]++; if (x % 10 == 5) cnt[1]++; if (x % 10 == 7) cnt[2]++; x /= 10; } if (cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) ++ans; } void dfs(ll x) { check(x); dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } int main() { cin >> n; dfs(0); cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define size_of_array(array) (sizeof(array) / sizeof(array[0])) #define MAX 100005 #define NIL -1 using ll = long long; using namespace std; using Graph = vector<vector<int>>; using Field = vector<vector<char>>; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } const ll mod = 1000000007; ll n; ll ans = 0; void check(ll x) { if (x > n) return; int cnt[3] = {}; while (x) { if (x % 10 == 3) cnt[0]++; if (x % 10 == 5) cnt[1]++; if (x % 10 == 7) cnt[2]++; x /= 10; } if (cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) ++ans; } void dfs(ll x) { check(x); if (x <= 1000000000) { dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } } int main() { cin >> n; dfs(0); cout << ans << endl; return 0; }
replace
48
51
48
53
-11
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { unsigned long long n; cin >> n; int count = 0; bool seven, five, three; for (unsigned long long i = 357; i <= n; i += 2) { seven = 0; five = 0; three = 0; unsigned long long num = i; while (num > 0) { if (num % 10 == 7) seven = 1; else if (num % 10 == 5) five = 1; else if (num % 10 == 3) three = 1; else { goto label; } num /= 10; } if (seven == 1 && five == 1 && three == 1) { count++; } label:; } cout << count << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { unsigned long long n; cin >> n; int count = 0; bool seven, five, three; for (unsigned long long i = 357; i <= n; i += 2) { if (i == 77777753 + 2) i = 333333357 - 2; if (i == 377777775 + 2) i = 533333337 - 2; if (i == 577777773 + 2) i = 733333335 - 2; if (i == 777777753 + 2) break; seven = 0; five = 0; three = 0; unsigned long long num = i; while (num > 0) { if (num % 10 == 7) seven = 1; else if (num % 10 == 5) five = 1; else if (num % 10 == 3) three = 1; else { goto label; } num /= 10; } if (seven == 1 && five == 1 && three == 1) { count++; } label:; } cout << count << endl; }
insert
11
11
11
19
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // #define ONLINE_JUDGE #define pb(a) push_back(a) #define all(a) (a.begin(), a.end()) using ll = long long; const int E5 = 1e5; //////////// Solution ///////////////////////////////// int ans = 0; int n; void dfs(ll cur, int mask) { if (cur > n) return; if (mask == 7) ++ans; dfs(cur * 10 + 3, mask | 1); dfs(cur * 10 + 5, mask | 2); dfs(cur * 10 + 7, mask | 4); } void solve() { cin >> n; dfs(0, 0); cout << ans << '\n'; } /////////// End Solution /////////////////////////////////////// //////// Initialization //////////////////////////////////// int main() { #ifndef ONLINE_JUDGE FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin); clock_t time_start = clock(); #endif ios::sync_with_stdio(false); cin.tie(NULL); solve(); #ifndef ONLINE_JUDGE fclose(FIN); cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock() - time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m"; #endif return 0; } //////// End Initialization ///////////////////////////////////////
#include <bits/stdc++.h> using namespace std; #define ONLINE_JUDGE #define pb(a) push_back(a) #define all(a) (a.begin(), a.end()) using ll = long long; const int E5 = 1e5; //////////// Solution ///////////////////////////////// int ans = 0; int n; void dfs(ll cur, int mask) { if (cur > n) return; if (mask == 7) ++ans; dfs(cur * 10 + 3, mask | 1); dfs(cur * 10 + 5, mask | 2); dfs(cur * 10 + 7, mask | 4); } void solve() { cin >> n; dfs(0, 0); cout << ans << '\n'; } /////////// End Solution /////////////////////////////////////// //////// Initialization //////////////////////////////////// int main() { #ifndef ONLINE_JUDGE FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin); clock_t time_start = clock(); #endif ios::sync_with_stdio(false); cin.tie(NULL); solve(); #ifndef ONLINE_JUDGE fclose(FIN); cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock() - time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m"; #endif return 0; } //////// End Initialization ///////////////////////////////////////
replace
3
4
3
4
-11
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; cin >> n; for (int i = 357; i <= n; i += 2) { int a = i, a3 = 0, a5 = 0, a7 = 0; while (a > 0) { if (a % 10 == 3) { a3 = 1; } else if (a % 10 == 5) { a5 = 1; } else if (a % 10 == 7) { a7 = 1; } else { a3 = 0; break; } a /= 10; } if (a3 * a5 * a7 == 1) { k++; } } cout << k << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; cin >> n; if (n > 777777777) { n = 777777777; } for (int i = 357; i <= n; i += 2) { int a = i, a3 = 0, a5 = 0, a7 = 0; while (a > 0) { if (a % 10 == 3) { a3 = 1; } else if (a % 10 == 5) { a5 = 1; } else if (a % 10 == 7) { a7 = 1; } else { a3 = 0; break; } a /= 10; } if (a3 * a5 * a7 == 1) { k++; } } cout << k << endl; return 0; }
insert
6
6
6
9
TLE
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second bool sgs(int x) { bool f3 = false, f5 = false, f7 = false; while (x != 0) { if (x % 10 == 3) { f3 = true; } else if (x % 10 == 5) { f5 = true; } else if (x % 10 == 7) { f7 = true; } else { return false; } x /= 10; } if (f3 == true && f5 == true && f7 == true) { return true; } else { return false; } } int main() { int n, ans = 0; cin >> n; for (int i = 357; i < n + 1; i += 2) { if (sgs(i) == true) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second bool sgs(int x) { bool f3 = false, f5 = false, f7 = false; while (x != 0) { if (x % 10 == 3) { f3 = true; } else if (x % 10 == 5) { f5 = true; } else if (x % 10 == 7) { f7 = true; } else { return false; } x /= 10; } if (f3 == true && f5 == true && f7 == true) { return true; } else { return false; } } int main() { int n, ans = 0; cin >> n; n = min(n, 780000000); for (int i = 357; i < n + 1; i += 10) { if (sgs(i) == true) { ans++; } } for (int i = 375; i < n + 1; i += 10) { if (sgs(i) == true) { ans++; } } for (int i = 573; i < n + 1; i += 10) { if (sgs(i) == true) { ans++; } } cout << ans << endl; }
replace
32
33
32
44
TLE
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { int n, cnt = 0; cin >> n; if (n < 357) { cout << "0\n"; return 0; } int start = 357; if (n > 100000000) { start = 99999999; cnt += 8334; } for (int i = start; i <= n; i = i + 2) { int j = i, flg = 1, c3 = 0, c5 = 0, c7 = 0; while (j > 0) { int k = j % 10; if (k != 3 && k != 5 && k != 7) { flg = 0; break; } if (k == 3) ++c3; if (k == 5) ++c5; if (k == 7) ++c7; j /= 10; if (j > 0 && j % 2 == 0) { flg = 0; break; } } if (flg) { if (c3 > 0 && c5 > 0 && c7 > 0) ++cnt; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n, cnt = 0; cin >> n; if (n < 357) { cout << "0\n"; return 0; } int start = 357; if (n > 500000000) { start = 499999999; cnt += 14384; } for (int i = start; i <= n; i = i + 2) { int j = i, flg = 1, c3 = 0, c5 = 0, c7 = 0; while (j > 0) { int k = j % 10; if (k != 3 && k != 5 && k != 7) { flg = 0; break; } if (k == 3) ++c3; if (k == 5) ++c5; if (k == 7) ++c7; j /= 10; if (j > 0 && j % 2 == 0) { flg = 0; break; } } if (flg) { if (c3 > 0 && c5 > 0 && c7 > 0) ++cnt; } } cout << cnt << endl; }
replace
11
14
11
14
TLE
p03212
C++
Time Limit Exceeded
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll N; void func(ll cur, int use, ll &counter) { if (cur > N) return; if (use == 0b111) counter++; func(cur * 10 + 7, use | 0b001, counter); func(cur * 10 + 5, use | 0b010, counter); func(cur, use | 0b100, counter); } int main() { cin >> N; ll ans = 0; func(0, 0, ans); cout << ans << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll N; void func(ll cur, int use, ll &counter) { if (cur > N) return; if (use == 0b111) counter++; func(cur * 10 + 7, use | 0b001, counter); func(cur * 10 + 5, use | 0b010, counter); func(cur * 10 + 3, use | 0b100, counter); } int main() { cin >> N; ll ans = 0; func(0, 0, ans); cout << ans << endl; }
replace
29
30
29
30
TLE
p03212
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; #define ll long long #define pb push_back string nextStr(string str) { bool flag = str[0] == '7'; if (str[0] == '3') str[0] = '5'; else if (str[0] == '5') str[0] = '7'; else str[0] = '3'; for (int i = 1; flag; i++) { if (i == str.size()) { str.pb('3'); break; } if (str[i] == '3') { flag = false; str[i] = '5'; } else if (str[i] == '5') { flag = false; str[i] = '7'; } else str[i] = '3'; } return str; } bool check(string str) { bool f3 = false, f5 = false, f7 = false; for (int i = 0; i < str.size(); i++) { if (str[i] == '3') f3 = true; if (str[i] == '5') f5 = true; if (str[i] == '7') f7 = true; } return f3 && f5 && f7; } int main() { int N; cin >> N; string S = "753"; int ans = 0; reverse(S.begin(), S.end()); while (stoi(S) <= N) { // cout << stoi(S) << endl; if (check(S)) { ans++; // cout << "!!!!!!!!" << endl; } reverse(S.begin(), S.end()); S = nextStr(S); reverse(S.begin(), S.end()); } cout << ans << endl; /*string S = "357"; if(check(S))cout << "Y" << endl; else cout << "N" << endl;*/ return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; #define ll long long #define pb push_back string nextStr(string str) { bool flag = str[0] == '7'; if (str[0] == '3') str[0] = '5'; else if (str[0] == '5') str[0] = '7'; else str[0] = '3'; for (int i = 1; flag; i++) { if (i == str.size()) { str.pb('3'); break; } if (str[i] == '3') { flag = false; str[i] = '5'; } else if (str[i] == '5') { flag = false; str[i] = '7'; } else str[i] = '3'; } return str; } bool check(string str) { bool f3 = false, f5 = false, f7 = false; for (int i = 0; i < str.size(); i++) { if (str[i] == '3') f3 = true; if (str[i] == '5') f5 = true; if (str[i] == '7') f7 = true; } return f3 && f5 && f7; } int main() { int N; cin >> N; string S = "753"; int ans = 0; reverse(S.begin(), S.end()); while (stoll(S) <= N) { // cout << stoi(S) << endl; if (check(S)) { ans++; // cout << "!!!!!!!!" << endl; } reverse(S.begin(), S.end()); S = nextStr(S); reverse(S.begin(), S.end()); } cout << ans << endl; /*string S = "357"; if(check(S))cout << "Y" << endl; else cout << "N" << endl;*/ return 0; }
replace
54
55
54
55
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> #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 ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; string tem = "753"; int dfs(string s, int n) { if (stoi(s) > n) return 0; int res = (count(ALL(s), '7') > 0 && count(ALL(s), '5') > 0 && count(ALL(s), '3') > 0) ? 1 : 0; REP(i, 3) res += dfs(s + tem[i], n); return res; } int main() { int n; cin >> n; cout << dfs("0", n) << endl; }
#include <bits/stdc++.h> #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 ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; string tem = "753"; int dfs(string s, int n) { if (stol(s) > n) return 0; int res = (count(ALL(s), '7') > 0 && count(ALL(s), '5') > 0 && count(ALL(s), '3') > 0) ? 1 : 0; REP(i, 3) res += dfs(s + tem[i], n); return res; } int main() { int n; cin >> n; cout << dfs("0", n) << endl; }
replace
11
12
11
12
0
p03212
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int n; int ans = 0; void check(int x) { bool f3 = false, f5 = false, f7 = false; while (x != 0) { if (x > n) break; int a = x % 10; if (a == 3) f3 = true; else if (a == 5) f5 = true; else if (a == 7) f7 = true; x /= 10; } if (f3 && f5 && f7) ans++; } void dfs(int x) { check(x); if (x <= n) { dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } } int main() { cin >> n; dfs(0); cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int n; int ans = 0; void check(int x) { bool f3 = false, f5 = false, f7 = false; while (x != 0) { if (x > n) break; int a = x % 10; if (a == 3) f3 = true; else if (a == 5) f5 = true; else if (a == 7) f7 = true; x /= 10; } if (f3 && f5 && f7) ans++; } void dfs(int x) { check(x); if (x <= 100000000) { dfs(10 * x + 3); dfs(10 * x + 5); dfs(10 * x + 7); } } int main() { cin >> n; dfs(0); cout << ans << endl; return 0; }
replace
31
32
31
32
TLE
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int dfs(int s, int N) { int ret; if (s > N) { return 0; } bool flg3 = false; bool flg5 = false; bool flg7 = false; // s は 753 数か? int tmp = s; while (tmp > 0) { int digit = tmp % 10; tmp /= 10; if (digit == 3) flg3 = true; else if (digit == 5) flg5 = true; else if (digit == 7) flg7 = true; } // end while // s が 753 数なら +1 if (flg3 && flg5 && flg7) ret = 1; else ret = 0; if (s <= N) { ret += dfs(10 * s + 3, N); ret += dfs(10 * s + 5, N); ret += dfs(10 * s + 7, N); } return ret; } int main() { int N, ans; cin >> N; ans = dfs(0, N); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int dfs(long s, int N) { int ret; if (s > N) { return 0; } bool flg3 = false; bool flg5 = false; bool flg7 = false; // s は 753 数か? int tmp = s; while (tmp > 0) { int digit = tmp % 10; tmp /= 10; if (digit == 3) flg3 = true; else if (digit == 5) flg5 = true; else if (digit == 7) flg7 = true; } // end while // s が 753 数なら +1 if (flg3 && flg5 && flg7) ret = 1; else ret = 0; if (s <= N) { ret += dfs(10 * s + 3, N); ret += dfs(10 * s + 5, N); ret += dfs(10 * s + 7, N); } return ret; } int main() { int N, ans; cin >> N; ans = dfs(0, N); cout << ans << endl; return 0; }
replace
3
4
3
4
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define CHMIN(a, b) (a) = min((a), (b)) #define CHMAX(a, b) (a) = max((a), (b)) #define DEBUG(x) cout << #x << ": " << (x) << endl int N; char tfs[3] = {'3', '5', '7'}; int dfs(string s) { int ans; if (stoi(s) > N) return 0; else { int three, five, seven; three = 0; five = 0; seven = 0; FOR(i, 0, s.length()) { if (s[i] == '3') three++; if (s[i] == '5') five++; if (s[i] == '7') seven++; } ans = (three > 0 && five > 0 && seven > 0) ? 1 : 0; } for (auto c : tfs) { ans += dfs(s + c); } return ans; } int main() { cin >> N; int rep = dfs("0"); cout << rep << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define CHMIN(a, b) (a) = min((a), (b)) #define CHMAX(a, b) (a) = max((a), (b)) #define DEBUG(x) cout << #x << ": " << (x) << endl int N; char tfs[3] = {'3', '5', '7'}; int dfs(string s) { int ans; if (stol(s) > N) return 0; else { int three, five, seven; three = 0; five = 0; seven = 0; FOR(i, 0, s.length()) { if (s[i] == '3') three++; if (s[i] == '5') five++; if (s[i] == '7') seven++; } ans = (three > 0 && five > 0 && seven > 0) ? 1 : 0; } for (auto c : tfs) { ans += dfs(s + c); } return ans; } int main() { cin >> N; int rep = dfs("0"); cout << rep << endl; }
replace
23
24
23
24
0
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define PI (acos(-1)) #define swap(a, b) ((a != b) && (a += b, b = a - b, a -= b)) #define rep(i, N) for (int i = 0; i < (N); i++) #define all(a) (a).begin(), (a).end() #define pb push_back using ll = long long; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } vector<double> simequ(vector<vector<double>> a) { int N = a.size(); // 前進消去 for (int k = 0; k < N - 1; k++) { for (int i = k + 1; i < N; i++) { double d = a[i][k] / a[k][k]; for (int j = k + 1; j <= N; j++) a[i][j] -= a[k][j] * d; } } // 後退代入 for (int i = N - 1; i >= 0; i--) { double d = a[i][N]; for (int j = i + 1; j < N; j++) d -= a[i][j] * a[j][N]; a[i][N] = d / a[i][i]; } // 結果出力 vector<double> result; for (int k = 0; k < N; k++) result.push_back(a[k][N]); return result; } int main() { ll n; cin >> n; if (n == 999999999) { cout << 26484 << endl; return 0; } ll c = 0; for (ll i = 357; i <= n; i += 2) { ll a = i; bool is3 = false, is5 = false, is7 = false; while (a) { int b = a % 10; if (b == 3) is3 = true; else if (b == 5) is5 = true; else if (b == 7) is7 = true; else { is3 = false; break; } a /= 10; } if (is3 && is5 && is7) c++; } cout << c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define PI (acos(-1)) #define swap(a, b) ((a != b) && (a += b, b = a - b, a -= b)) #define rep(i, N) for (int i = 0; i < (N); i++) #define all(a) (a).begin(), (a).end() #define pb push_back using ll = long long; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } vector<double> simequ(vector<vector<double>> a) { int N = a.size(); // 前進消去 for (int k = 0; k < N - 1; k++) { for (int i = k + 1; i < N; i++) { double d = a[i][k] / a[k][k]; for (int j = k + 1; j <= N; j++) a[i][j] -= a[k][j] * d; } } // 後退代入 for (int i = N - 1; i >= 0; i--) { double d = a[i][N]; for (int j = i + 1; j < N; j++) d -= a[i][j] * a[j][N]; a[i][N] = d / a[i][i]; } // 結果出力 vector<double> result; for (int k = 0; k < N; k++) result.push_back(a[k][N]); return result; } int main() { ll n; cin >> n; if (n == 999999999) { cout << 26484 << endl; return 0; } if (n > 777777753) n = 777777753; ll c = 0; for (ll i = 357; i <= n; i += 2) { ll a = i; bool is3 = false, is5 = false, is7 = false; while (a) { int b = a % 10; if (b == 3) is3 = true; else if (b == 5) is5 = true; else if (b == 7) is7 = true; else { is3 = false; break; } a /= 10; } if (is3 && is5 && is7) c++; } cout << c << endl; return 0; }
insert
46
46
46
48
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define repi(i, a, b) \ for (long long i = (long long)(a); i < (long long)(b); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; ll ugauss(ll a, ll b) { if (!a) return 0; if (a > 0 ^ b > 0) return a / b; else return (a + (a > 0 ? -1 : 1)) / b + 1; } ll lgauss(ll a, ll b) { if (!a) return 0; if (a > 0 ^ b > 0) return (a + (a > 0 ? -1 : 1)) / b - 1; else return a / b; } template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system(((string) "dot -T png out.dot >" + filename).c_str()); } struct timeval start; double sec() { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec - start.tv_sec) + (tv.tv_usec - start.tv_usec) * 1e-6; } size_t random_seed; struct init_ { init_() { ios::sync_with_stdio(false); cin.tie(0); gettimeofday(&start, NULL); struct timeval myTime; struct tm *time_st; gettimeofday(&myTime, NULL); time_st = localtime(&myTime.tv_sec); srand(myTime.tv_usec); random_seed = RAND_MAX / 2 + rand() / 2; } } init__; #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) int main(void) { ll n; cin >> n; vll a(n); cin >> a; cout << (accumulate(all(a), 0ll) - n) << endl; return 0; }
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define repi(i, a, b) \ for (long long i = (long long)(a); i < (long long)(b); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; ll ugauss(ll a, ll b) { if (!a) return 0; if (a > 0 ^ b > 0) return a / b; else return (a + (a > 0 ? -1 : 1)) / b + 1; } ll lgauss(ll a, ll b) { if (!a) return 0; if (a > 0 ^ b > 0) return (a + (a > 0 ? -1 : 1)) / b - 1; else return a / b; } template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system(((string) "dot -T png out.dot >" + filename).c_str()); } struct timeval start; double sec() { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec - start.tv_sec) + (tv.tv_usec - start.tv_usec) * 1e-6; } size_t random_seed; struct init_ { init_() { ios::sync_with_stdio(false); cin.tie(0); gettimeofday(&start, NULL); struct timeval myTime; struct tm *time_st; gettimeofday(&myTime, NULL); time_st = localtime(&myTime.tv_sec); srand(myTime.tv_usec); random_seed = RAND_MAX / 2 + rand() / 2; } } init__; #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) int main(void) { ll n; cin >> n; ll ret = 0; repi(d, 1, 11) { rep(i, round(pow(3, d))) { ll tmp = i; ll x = 0; set<ll> memo; rep(_, d) { x *= 10; x += 3 + 2 * (tmp % 3); memo.insert(tmp % 3); tmp /= 3; } // cout << x << endl; if (memo.size() == 3 && 1 <= x && x <= n) { // cout << x << endl; ret++; } } } cout << ret << endl; return 0; }
replace
198
201
198
218
0
p03212
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; // #define int long long bool is753(int n) { int three = 0; int five = 0; int seven = 0; while (true) { switch (n % 10) { case 3: ++three; break; case 5: ++five; break; case 7: ++seven; break; default: return false; } n /= 10; if (n == 0) break; } if (three * five * seven == 0) return false; return true; } // bool is753(int n) { // string s = to_string(n); // if(s.find("0") != string::npos) // return false; // if(s.find("1") != string::npos) // return false; // if(s.find("2") != string::npos) // return false; // if(s.find("4") != string::npos) // return false; // if(s.find("6") != string::npos) // return false; // if(s.find("8") != string::npos) // return false; // if(s.find("9") != string::npos) // return false; // if(s.find("3") == string::npos) // return false; // if(s.find("5") == string::npos) // return false; // if(s.find("7") == string::npos) // return false; // return true; // } signed main(void) { int num; // num num = 0; // count, result // num = numeric_limits<int>::min(); // max // num = numeric_limits<int>::max(); // min int n; cin >> n; int i = 357; while (true) { if (i > n) break; if (is753(i)) // **7 ++num; i += 6; if (i > n) break; if (is753(i)) // **3 ++num; i += 2; if (i > n) break; if (is753(i)) // **5 ++num; i += 2; } cout << num << endl; return 0; }
#include "bits/stdc++.h" using namespace std; // #define int long long inline bool is753(int n) { int three = 0; int five = 0; int seven = 0; while (true) { switch (n % 10) { case 3: ++three; break; case 5: ++five; break; case 7: ++seven; break; default: return false; } n /= 10; if (n == 0) break; } if (three * five * seven == 0) return false; return true; } // bool is753(int n) { // string s = to_string(n); // if(s.find("0") != string::npos) // return false; // if(s.find("1") != string::npos) // return false; // if(s.find("2") != string::npos) // return false; // if(s.find("4") != string::npos) // return false; // if(s.find("6") != string::npos) // return false; // if(s.find("8") != string::npos) // return false; // if(s.find("9") != string::npos) // return false; // if(s.find("3") == string::npos) // return false; // if(s.find("5") == string::npos) // return false; // if(s.find("7") == string::npos) // return false; // return true; // } signed main(void) { int num; // num num = 0; // count, result // num = numeric_limits<int>::min(); // max // num = numeric_limits<int>::max(); // min int n; cin >> n; int i = 357; while (true) { if (i > n) break; if (is753(i)) // **7 ++num; i += 6; if (i > n) break; if (is753(i)) // **3 ++num; i += 2; if (i > n) break; if (is753(i)) // **5 ++num; i += 2; } cout << num << endl; return 0; }
replace
5
6
5
6
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() typedef unsigned int uint; typedef unsigned long long int ull; typedef long long int ll; typedef pair<int, int> P; typedef vector<int> V; typedef vector<V> VV; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define LINF ((ll)1 << 63 - 1) #define INF (1 << 29) #define MINF -2000000007 #define MAX 100050 const int MOD = 1e9 + 7; // テンプレ終了 //====================================================================// int N; int func(string a) { if (stoi(a) > N) return 0; // cout << a << endl; int cnt = 0, flag[3] = {0, 0, 0}; REP(i, a.size()) if (a[i] == '3') flag[0] = 1; REP(i, a.size()) if (a[i] == '5') flag[1] = 1; REP(i, a.size()) if (a[i] == '7') flag[2] = 1; if (flag[0] & flag[1] & flag[2]) cnt = 1; for (char i : {'3', '5', '7'}) { a.push_back(i); cnt += func(a); a.pop_back(); } return cnt; } // int main() { // int N; cin >> N; cout << func("0") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() typedef unsigned int uint; typedef unsigned long long int ull; typedef long long int ll; typedef pair<int, int> P; typedef vector<int> V; typedef vector<V> VV; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define LINF ((ll)1 << 63 - 1) #define INF (1 << 29) #define MINF -2000000007 #define MAX 100050 const int MOD = 1e9 + 7; // テンプレ終了 //====================================================================// int N; int func(string a) { if ((ll)stoll(a) > N) return 0; // cout << a << endl; int cnt = 0, flag[3] = {0, 0, 0}; REP(i, a.size()) if (a[i] == '3') flag[0] = 1; REP(i, a.size()) if (a[i] == '5') flag[1] = 1; REP(i, a.size()) if (a[i] == '7') flag[2] = 1; if (flag[0] & flag[1] & flag[2]) cnt = 1; for (char i : {'3', '5', '7'}) { a.push_back(i); cnt += func(a); a.pop_back(); } return cnt; } // int main() { // int N; cin >> N; cout << func("0") << endl; return 0; }
replace
30
31
30
31
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; const long long LINF = 1e18; #define dump(x) cout << 'x' << ' = ' << (x) << ` `; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, a) for (auto &(x) : (a)) typedef long long ll; using namespace std; ll n; vector<ll> ans; void solve(int x) { if (x > n) return; ans.push_back(x); for (int i = 3; i <= 7; i += 2) solve(10 * x + i); return; } ll judge() { ll cnt = 0; REP(i, ans.size()) { vector<bool> bu(10, false); string tmp = to_string(ans[i]); REP(j, tmp.size()) bu[tmp[j] - '0'] = true; if (bu[3] && bu[5] && bu[7]) cnt++; } return cnt; } int main(int argc, char const *argv[]) { cin >> n; solve(0); cout << judge() << endl; return 0; }
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; const long long LINF = 1e18; #define dump(x) cout << 'x' << ' = ' << (x) << ` `; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, a) for (auto &(x) : (a)) typedef long long ll; using namespace std; ll n; vector<ll> ans; void solve(ll x) { if (x > n) return; ans.push_back(x); for (int i = 3; i <= 7; i += 2) solve(10 * x + i); return; } ll judge() { ll cnt = 0; REP(i, ans.size()) { vector<bool> bu(10, false); string tmp = to_string(ans[i]); REP(j, tmp.size()) bu[tmp[j] - '0'] = true; if (bu[3] && bu[5] && bu[7]) cnt++; } return cnt; } int main(int argc, char const *argv[]) { cin >> n; solve(0); cout << judge() << endl; return 0; }
replace
15
16
15
16
0
p03212
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; bool is753(int n) { bool c3, c5, c7; c3 = c5 = c7 = false; do { int num = n % 10; switch (num) { case 3: c3 = true; break; case 5: c5 = true; break; case 7: c7 = true; break; default: return false; } } while (n /= 10); return (c3 && c5 && c7); } int main() { int n; cin >> n; n = min(n, 777777777); int ans = 0; for (int i = 357; i <= n; i++) { if (is753(i)) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool is753(int n) { bool c3, c5, c7; c3 = c5 = c7 = false; do { int num = n % 10; switch (num) { case 3: c3 = true; break; case 5: c5 = true; break; case 7: c7 = true; break; default: return false; } } while (n /= 10); return (c3 && c5 && c7); } int main() { int n; cin >> n; n = min(n, 777777777); int ans = 0; for (int i = 357; i <= n; i += 2) { if (is753(i)) ans++; } cout << ans << endl; return 0; }
replace
36
37
36
37
TLE
p03212
C++
Runtime Error
#include <bits/stdc++.h> #define INF 1000000000 #define ll long long #define pll pair<ll, ll> using namespace std; int main() { ll ans = 0; ll N; cin >> N; vector<char> num = {'3', '5', '7'}; queue<string> q; q.push("3"); q.push("5"); q.push("7"); while (!q.empty()) { string check = q.front(); q.pop(); for (ll i = 0; i < 3; ++i) { string temp = check; temp += num.at(i); ll next_num = stoi(temp); if (next_num > N) { continue; // cout << temp << endl; } q.push(temp); bool t = false, f = false, s = false; for (ll j = 0; j < temp.size(); ++j) { if (temp[j] == '3') { t = true; } else if (temp[j] == '5') { f = true; } else { s = true; } } if (t && f && s) { // cout << temp << endl; ans += 1; } // ans += 1; } } cout << ans << endl; }
#include <bits/stdc++.h> #define INF 1000000000 #define ll long long #define pll pair<ll, ll> using namespace std; int main() { ll ans = 0; ll N; cin >> N; vector<char> num = {'3', '5', '7'}; queue<string> q; q.push("3"); q.push("5"); q.push("7"); while (!q.empty()) { string check = q.front(); q.pop(); for (ll i = 0; i < 3; ++i) { string temp = check; temp += num.at(i); if (temp.size() > 9) { continue; } ll next_num = stoi(temp); if (next_num > N) { continue; // cout << temp << endl; } q.push(temp); bool t = false, f = false, s = false; for (ll j = 0; j < temp.size(); ++j) { if (temp[j] == '3') { t = true; } else if (temp[j] == '5') { f = true; } else { s = true; } } if (t && f && s) { // cout << temp << endl; ans += 1; } // ans += 1; } } cout << ans << endl; }
insert
21
21
21
24
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const int mod = 1e9 + 7; vector<ll> z; void zzz(int i, ll j) { z.push_back(j); if (i < 9) { zzz(i + 1, j * 10 + 3); zzz(i + 1, j * 10 + 5); zzz(i + 1, j * 10 + 7); } } int main() { ll s; cin >> s; zzz(0, 0); sort(z.begin(), z.end()); int ans = 0; for (int i = 0; z[i] <= s; i++) { int flag[10] = {}; while (z[i]) { flag[z[i] % 10]++; z[i] /= 10; if (flag[3] && flag[5] && flag[7]) { ans++; break; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const int mod = 1e9 + 7; vector<ll> z; void zzz(int i, ll j) { z.push_back(j); if (i < 10) { zzz(i + 1, j * 10 + 3); zzz(i + 1, j * 10 + 5); zzz(i + 1, j * 10 + 7); } } int main() { ll s; cin >> s; zzz(0, 0); sort(z.begin(), z.end()); int ans = 0; for (int i = 0; z[i] <= s; i++) { int flag[10] = {}; while (z[i]) { flag[z[i] % 10]++; z[i] /= 10; if (flag[3] && flag[5] && flag[7]) { ans++; break; } } } cout << ans << endl; return 0; }
replace
13
14
13
14
0
p03212
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #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 ALL(obj) (obj).begin(), (obj).end() #define INF 1e9 typedef long long ll; int main() { string N; cin >> N; int dp[12][2][2][2][2]; REP(i, 12) { REP(k, 2) { REP(l, 2) { REP(m, 2) { REP(n, 2) { dp[i][k][l][m][n] = 0; } } } } } dp[0][0][0][0][0] = 1; FOR(i, 1, N.size() - 2) { dp[i][1][0][0][0] = 1; } REP(i, N.size()) { // 何桁目 REP(smaller, 2) { // Smaller? REP(three, 2) { REP(five, 2) { REP(seven, 2) { REP(x, (smaller ? 10 : (N[i] - '0') + 1)) { if (x != 3 && x != 5 && x != 7) continue; // x=3,5,7のみ考慮 // N[i]の値で変わっていく dp[i + 1][smaller || x < (N[i] - '0')][three || x == 3] [five || x == 5][seven || x == 7] += dp[i][smaller][three][five][seven]; } } } } } } cout << dp[N.size()][0][1][1][1] + dp[N.size()][1][1][1][1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #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 ALL(obj) (obj).begin(), (obj).end() #define INF 1e9 typedef long long ll; int main() { string N; cin >> N; if (N.size() <= 2) { cout << 0 << endl; return 0; } int dp[12][2][2][2][2]; REP(i, 12) { REP(k, 2) { REP(l, 2) { REP(m, 2) { REP(n, 2) { dp[i][k][l][m][n] = 0; } } } } } dp[0][0][0][0][0] = 1; FOR(i, 1, N.size() - 2) { dp[i][1][0][0][0] = 1; } REP(i, N.size()) { // 何桁目 REP(smaller, 2) { // Smaller? REP(three, 2) { REP(five, 2) { REP(seven, 2) { REP(x, (smaller ? 10 : (N[i] - '0') + 1)) { if (x != 3 && x != 5 && x != 7) continue; // x=3,5,7のみ考慮 // N[i]の値で変わっていく dp[i + 1][smaller || x < (N[i] - '0')][three || x == 3] [five || x == 5][seven || x == 7] += dp[i][smaller][three][five][seven]; } } } } } } cout << dp[N.size()][0][1][1][1] + dp[N.size()][1][1][1][1] << endl; return 0; }
insert
13
13
13
19
0
p03212
C++
Runtime Error
#include <iostream> #include <string> using namespace std; const string decimals = "753"; bool check(string &s, long n) { if (stoi(s) > n) { return false; } for (char c : decimals) { if (s.find(c) == string::npos) { return false; } } return true; } int dfs(string s, long n) { int res = 0; if (!s.empty()) { if (check(s, n)) { ++res; } else if (stoll(s) > n) { return 0; } } for (char next : decimals) { res += dfs(s + next, n); } return res; } int solve(long n) { return dfs("", n); } int main() { long n; cin >> n; cout << solve(n) << endl; return 0; }
#include <iostream> #include <string> using namespace std; const string decimals = "753"; bool check(string &s, long n) { if (stoll(s) > n) { return false; } for (char c : decimals) { if (s.find(c) == string::npos) { return false; } } return true; } int dfs(string s, long n) { int res = 0; if (!s.empty()) { if (check(s, n)) { ++res; } else if (stoll(s) > n) { return 0; } } for (char next : decimals) { res += dfs(s + next, n); } return res; } int solve(long n) { return dfs("", n); } int main() { long n; cin >> n; cout << solve(n) << endl; return 0; }
replace
7
8
7
8
0