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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const long long t = 1e18;
int main() {
int n;
bool flg = false;
cin >> n;
long long s = 1;
for (int i = 0; i < n; i++) {
long long tmp;
cin >> tmp;
if (tmp == 0) {
cout << 0 << "\n";
return 0;
}
if ((t + 1) / s < tmp || s * tmp > t) {
flg = true;
}
s *= tmp;
}
if (flg) {
cout << -1 << "\n";
return 0;
}
cout << s << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const long long t = 1e18;
int main() {
int n;
bool flg = false;
cin >> n;
long long s = 1;
for (int i = 0; i < n; i++) {
long long tmp;
cin >> tmp;
if (tmp == 0) {
cout << 0 << "\n";
return 0;
}
if (flg || (t + 1) / s < tmp || s * tmp > t) {
flg = true;
}
s *= tmp;
}
if (flg) {
cout << -1 << "\n";
return 0;
}
cout << s << "\n";
return 0;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
int main() {
uint32_t N = 0;
std::cin >> N;
int64_t prod = 1;
for (uint32_t i = 0; i < N; i++) {
int64_t A = 0;
std::cin >> A;
if (prod == -1) {
if (A == 0)
prod = 0;
} else {
if ((1'000'000'000'000'000'000 + prod - 1) / prod < A) {
prod = -1;
} else {
prod *= A;
if (prod > 1'000'000'000'000'000'000)
prod = -1;
}
}
}
std::cout << prod << std::endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
int main() {
uint32_t N = 0;
std::cin >> N;
int64_t prod = 1;
for (uint32_t i = 0; i < N; i++) {
int64_t A = 0;
std::cin >> A;
if (prod == -1) {
if (A == 0)
prod = 0;
} else if (prod != 0) {
if ((1'000'000'000'000'000'000 + prod - 1) / prod < A) {
prod = -1;
} else {
prod *= A;
if (prod > 1'000'000'000'000'000'000)
prod = -1;
}
}
}
std::cout << prod << std::endl;
return 0;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
long long ans = 1, f = 0;
cin >> n;
for (int i = 0; n > i; i++) {
long long a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
cout << ans << endl;
if (a > 1000000000000000000LL / ans) {
f = 1;
}
ans = ans * a;
}
if (f)
ans = -1;
cout << ans << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int n;
long long ans = 1, f = 0;
cin >> n;
for (int i = 0; n > i; i++) {
long long a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
// cout << ans << endl;
if (ans > 1000000000000000000LL / a) {
f = 1;
}
ans = ans * a;
}
if (f)
ans = -1;
cout << ans << endl;
return 0;
}
| replace | 14 | 16 | 14 | 16 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
const long long k = 1000000000000000000;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
long long ans = 1;
for (long long i = 0; i < n; i++) {
if (k / ans < a.at(i)) {
ans = -1;
break;
}
ans *= a.at(i);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
const long long k = 1000000000000000000;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
long long ans = 1;
for (long long i = 0; i < n; i++) {
if (ans == 0)
break;
else if (k / ans < a.at(i)) {
ans = -1;
break;
}
ans *= a.at(i);
}
cout << ans << endl;
return 0;
}
| replace | 14 | 15 | 14 | 17 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int64_t Z = 1, A = 0;
int64_t K = 1000000000000000000;
for (int i = 0; i < N; i++) {
int64_t a;
cin >> a;
if (1 + (K - 1) / Z < a && a != 0) {
A++;
} else {
Z *= a;
}
}
if ((A == 0 && Z <= K) || Z == 0) {
cout << Z << endl;
} else {
cout << "-1" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int64_t Z = 1, A = 0;
int64_t K = 1000000000000000000;
for (int i = 0; i < N; i++) {
int64_t a;
cin >> a;
if (1 + (K - 1) / Z < a && a != 0) {
A++;
} else {
Z *= a;
}
if (Z == 0) {
break;
}
}
if ((A == 0 && Z <= K) || Z == 0) {
cout << Z << endl;
} else {
cout << "-1" << endl;
}
}
| insert | 16 | 16 | 16 | 19 | 0 | |
p02658 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) {
res = res * a % mod;
}
a = a * a % mod;
n >>= 1;
}
return res;
}
int main() {
int n;
cin >> n;
ll ans = 1;
rep(i, n) {
ll tmp;
cin >> tmp;
if (inf / ans < tmp && tmp != 0) {
ans = -1;
} else {
ans *= tmp;
}
}
if (ans < 0) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
}
| #define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) {
res = res * a % mod;
}
a = a * a % mod;
n >>= 1;
}
return res;
}
int main() {
int n;
cin >> n;
ll ans = 1;
rep(i, n) {
ll tmp;
cin >> tmp;
if (inf / ans < tmp && tmp != 0) {
ans = -1;
} else {
ans *= tmp;
}
if (ans == 0) {
break;
}
}
if (ans < 0) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
}
| insert | 85 | 85 | 85 | 88 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// 問題文および制約はちゃんと確認しよう!
// サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
// とりあえずサンプルを読んでから解法を考えよう?
lint inf = 1E18L + 1;
int main() {
int n;
lint out = 1, a;
cin >> n;
rep(i, n) {
cin >> a;
if (inf / out + 1 < a)
out = inf;
else
out *= a;
}
if (out >= inf)
cout << -1 << endl;
else
cout << out << endl;
}
| #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// 問題文および制約はちゃんと確認しよう!
// サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
// とりあえずサンプルを読んでから解法を考えよう?
lint inf = 1E18L + 1;
int main() {
int n;
lint out = 1, a;
cin >> n;
rep(i, n) {
cin >> a;
if (out < 1L)
continue;
if (inf / out + 1 < a)
out = inf;
else
out *= a;
}
if (out >= inf)
cout << -1 << endl;
else
cout << out << endl;
}
| insert | 43 | 43 | 43 | 45 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int, int> pr;
#define N 1000002
signed main() {
SPEED;
int n;
cin >> n;
int a[n], ans = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; ++i) {
if (ans > (1000000000000000000 / a[i])) {
cout << -1;
return 0;
}
ans *= a[i];
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int, int> pr;
#define N 1000002
signed main() {
SPEED;
int n;
cin >> n;
int a[n], ans = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
if (a[0] == 0) {
cout << 0;
return 0;
}
for (int i = 0; i < n; ++i) {
if (ans > (1000000000000000000 / a[i])) {
cout << -1;
return 0;
}
ans *= a[i];
}
cout << ans;
} | insert | 25 | 25 | 25 | 29 | 0 | |
p02658 | C++ | Runtime Error | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const ll MX = 1e18;
int main() {
int n;
cin >> n;
ll ans = 1;
bool flag = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (MX / ans < a)
flag = true;
ans *= a;
}
if (flag)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const ll MX = 1e18;
int main() {
int n;
cin >> n;
ll ans = 1;
bool flag = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (flag || MX / ans < a)
flag = true;
ans *= a;
}
if (flag)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | replace | 22 | 23 | 22 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long ans = 1;
for (int i = 0; i < n; i++) {
long long a;
cin >> a;
if (a == 0) {
ans = 0;
} else if (a <= 1000000000000000000 / ans) {
ans = ans * a;
} else {
ans = -1;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long ans = 1;
for (int i = 0; i < n; i++) {
long long a;
cin >> a;
if (a == 0) {
ans = 0;
cout << ans << endl;
return 0;
} else if (a <= 1000000000000000000 / ans) {
ans = ans * a;
} else {
ans = -1;
}
}
cout << ans << endl;
return 0;
} | insert | 12 | 12 | 12 | 14 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
#pragma GCC target("avx2")
#define int long long
const int INF = 1e18;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int m = INF;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
m /= a[i];
}
if (m == 0) {
cout << -1 << endl;
} else {
int ans = 1;
for (auto el : a) {
ans *= el;
}
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
#pragma GCC target("avx2")
#define int long long
const int INF = 1e18;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int m = INF;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
m /= a[i];
}
if (m == 0) {
cout << -1 << endl;
} else {
int ans = 1;
for (auto el : a) {
ans *= el;
}
cout << ans << endl;
}
return 0;
}
| insert | 20 | 20 | 20 | 24 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
int n;
scanf("%d", &n);
LL ans = 1, x, inf = 1e18, fl = 1, fl1 = 1;
for (int i = 0; i < n; i++) {
scanf("%lld", &x);
if (!x)
fl1 = 0;
if (x > inf / ans || (ans * x > inf))
fl = 0;
ans *= x;
}
if (!fl1 || fl)
printf("%lld", ans);
else
puts("-1");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
int n;
scanf("%d", &n);
LL ans = 1, x, inf = 1e18, fl = 1, fl1 = 1;
for (int i = 0; i < n; i++) {
scanf("%lld", &x);
if (!x)
fl1 = 0;
if (fl && (x > inf / ans || ans * x > inf))
fl = 0;
ans *= x;
}
if (!fl1 || fl)
printf("%lld", ans);
else
puts("-1");
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
ll a[N], inf = 1e18;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
ll sum = 1;
for (int i = 0; i < n; i++) {
ll x = a[i];
if (sum > inf / x) {
sum = -1;
break;
} else {
sum *= x;
}
}
cout << sum << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
ll a[N], inf = 1e18;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
ll sum = 1;
for (int i = 0; i < n; i++) {
ll x = a[i];
if (x == 0) {
sum = 0;
break;
}
if (sum > inf / x) {
sum = -1;
break;
} else {
sum *= x;
}
}
cout << sum << endl;
}
| insert | 14 | 14 | 14 | 18 | 0 | |
p02658 | C++ | Runtime Error | #include <cstdio>
typedef unsigned long long ull;
const ull LIMIT = 1000000000000000000llu;
int main() {
int N;
scanf("%d", &N);
ull ans = 1ull;
bool overflowed = false;
for (int i = 0; i < N; i++) {
ull temp;
scanf("%llu", &temp);
if (temp == 0) {
puts("0");
return 0;
}
if ((LIMIT / ans) < temp)
overflowed = true;
ans = ans * temp;
}
if (overflowed) {
puts("-1");
return 0;
} else
printf("%llu\n", ans);
return 0;
} | #include <cstdio>
typedef unsigned long long ull;
const ull LIMIT = 1000000000000000000llu;
int main() {
int N;
scanf("%d", &N);
ull ans = 1ull;
bool overflowed = false;
for (int i = 0; i < N; i++) {
ull temp;
scanf("%llu", &temp);
if (temp == 0) {
puts("0");
return 0;
}
if (ans != 0 && (LIMIT / ans) < temp)
overflowed = true;
ans = ans * temp;
}
if (overflowed) {
puts("-1");
return 0;
} else
printf("%llu\n", ans);
return 0;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define int long long
template <typename T> using vv = vector<vector<T>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using ll = long long;
constexpr ll INF = 1LL << 60;
signed main() {
int n;
cin >> n;
int ans = 1;
bool flag = false;
bool zero = false;
rep(i, n) {
int a;
cin >> a;
if (a > (ll)(1e18) / ans) {
flag = true;
}
if (a == 0) {
zero = true;
}
ans *= a;
}
if (flag && !zero) {
cout << -1 << endl;
} else if (zero) {
cout << 0 << endl;
} else {
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define int long long
template <typename T> using vv = vector<vector<T>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using ll = long long;
constexpr ll INF = 1LL << 60;
signed main() {
int n;
cin >> n;
int ans = 1;
bool flag = false;
bool zero = false;
rep(i, n) {
int a;
cin >> a;
if (ans != 0 && a > (ll)(1e18) / ans) {
flag = true;
}
if (a == 0) {
zero = true;
}
ans *= a;
}
if (flag && !zero) {
cout << -1 << endl;
} else if (zero) {
cout << 0 << endl;
} else {
cout << ans << endl;
}
return 0;
}
| replace | 26 | 27 | 26 | 27 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x) \
int x; \
cin >> x; \
while (x--)
#define pw(b, p) pow(b, p) + 0.1
#ifndef ONLINE_JUDGE
#define watch(x) cerr << #x << " = " << x << "\n"
#else
#define watch(x) 42
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
void c_p_c() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("debug.txt", "w", stderr);
#endif
}
int dig(int n) {
int d = 0;
while (n != 0) {
d++;
n /= 10;
}
return d;
}
int32_t main() {
c_p_c();
int n;
cin >> n;
int a[n];
int mx = 1e18;
int ans = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; ++i) {
// cout << ans << '\n';
if (ans == -1)
continue;
if (a[i] > ceil(mx / ans)) {
ans = -1;
} else
ans *= a[i];
}
if (ans > mx)
ans = -1;
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x) \
int x; \
cin >> x; \
while (x--)
#define pw(b, p) pow(b, p) + 0.1
#ifndef ONLINE_JUDGE
#define watch(x) cerr << #x << " = " << x << "\n"
#else
#define watch(x) 42
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
void c_p_c() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("debug.txt", "w", stderr);
#endif
}
int dig(int n) {
int d = 0;
while (n != 0) {
d++;
n /= 10;
}
return d;
}
int32_t main() {
c_p_c();
int n;
cin >> n;
int a[n];
int mx = 1e18;
int ans = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; ++i) {
// cout << ans << '\n';
if (ans == -1)
continue;
if (ans != 0 && a[i] > ceil(mx / ans)) {
ans = -1;
} else
ans *= a[i];
}
if (ans > mx)
ans = -1;
cout << ans;
return 0;
} | replace | 85 | 86 | 85 | 86 | -11 | |
p02658 | C++ | Runtime Error | // written by: rishav2416
#include <bits/stdc++.h>
#define ll long long
#define lli long long int
#define ld long double
#define mod 1000000000000000000
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(), x.end()
#define input(arr, n) \
for (ll c1 = 0; c1 < n; c1++) \
cin >> arr[c1];
#define arrinit(arr, n, k) \
for (ll c1 = 0; c1 < n; c1++) \
arr[i] = k;
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define revrep(i, a, n) for (ll i = a; i >= n; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
#define INF 1e18a
ll power(ll base, ll pow, ll mo) {
ll res = 1;
while (pow) {
if (pow % 2 != 0)
res = (res * base) % mo;
base = (base * base) % mo;
pow /= 2;
}
return res;
}
ll inv(ll i) { // mod must be prime and i must be coprime with mo
return power(i, mod - 2, mod);
}
std::string str = "All Good Till Here";
/////////////////////////////////////////////////////////////////////////////////
void solve() {
ll i, j, x, n;
cin >> n;
lli a[n];
input(a, n);
sort(a, a + n);
lli p = 1;
rep(i, 0, n) {
if (a[i] >= (mod / p)) {
cout << -1 << "\n";
return;
} else
p *= a[i];
}
cout << p << "\n";
return;
}
int32_t main() {
fastio ll tt;
// cin>>tt;
tt = 1;
while (tt--) {
solve();
}
return 0;
}
| // written by: rishav2416
#include <bits/stdc++.h>
#define ll long long
#define lli long long int
#define ld long double
#define mod 1000000000000000000
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(), x.end()
#define input(arr, n) \
for (ll c1 = 0; c1 < n; c1++) \
cin >> arr[c1];
#define arrinit(arr, n, k) \
for (ll c1 = 0; c1 < n; c1++) \
arr[i] = k;
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define revrep(i, a, n) for (ll i = a; i >= n; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
#define INF 1e18a
ll power(ll base, ll pow, ll mo) {
ll res = 1;
while (pow) {
if (pow % 2 != 0)
res = (res * base) % mo;
base = (base * base) % mo;
pow /= 2;
}
return res;
}
ll inv(ll i) { // mod must be prime and i must be coprime with mo
return power(i, mod - 2, mod);
}
std::string str = "All Good Till Here";
/////////////////////////////////////////////////////////////////////////////////
void solve() {
ll i, j, x, n;
cin >> n;
lli a[n];
input(a, n);
sort(a, a + n);
lli p = 1;
rep(i, 0, n) {
if (a[i] == 0) {
cout << 0 << '\n';
return;
}
}
rep(i, 0, n) {
if (a[i] > (mod / p)) {
cout << -1 << "\n";
return;
} else
p *= a[i];
}
cout << p << "\n";
return;
}
int32_t main() {
fastio ll tt;
// cin>>tt;
tt = 1;
while (tt--) {
solve();
}
return 0;
}
| replace | 59 | 60 | 59 | 66 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll n = 0;
cin >> n;
vector<ll> a(n);
ll res = 0;
res = 1;
bool ok = true;
bool zero = false;
for (int i = 0; i < n; i++) {
cin >> a[i];
string copy, now;
copy = to_string(res);
now = to_string(a[i]);
// cout << (ll)pow(10,18) / a[i] << " " << res << endl;
if (res > ((ll)pow(10, 18) / a[i]) + (ll)1) {
// cout << "!" << endl;
ok = false;
}
if (ok)
res *= a[i];
if (res > (ll)pow(10, 18))
ok = false;
// cout << res << endl;
// cout << pow(10,18) << endl;
if (a[i] == 0)
zero = true;
}
if (ok)
cout << res << endl;
else {
if (zero)
cout << 0 << endl;
else
cout << -1 << endl;
}
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll n = 0;
cin >> n;
vector<ll> a(n);
ll res = 0;
res = 1;
bool ok = true;
bool zero = false;
for (int i = 0; i < n; i++) {
cin >> a[i];
string copy, now;
copy = to_string(res);
now = to_string(a[i]);
// cout << (ll)pow(10,18) / a[i] << " " << res << endl;
if (a[i] == 0) {
res = 0;
zero = true;
break;
}
if (res > ((ll)pow(10, 18) / a[i]) + (ll)1) {
// cout << "!" << endl;
ok = false;
}
if (ok)
res *= a[i];
if (res > (ll)pow(10, 18))
ok = false;
// cout << res << endl;
// cout << pow(10,18) << endl;
if (a[i] == 0)
zero = true;
}
if (ok)
cout << res << endl;
else {
if (zero)
cout << 0 << endl;
else
cout << -1 << endl;
}
}
| insert | 26 | 26 | 26 | 31 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, l, r) for (int i = (l); i < (r); i++)
int main() {
int N;
cin >> N;
ll ans = 1;
vector<ll> a(N);
rep(i, N) {
cin >> a[i];
ans *= a[i];
}
ll an = ans;
rep(i, N) { an /= a[i]; }
if (ans > 1000000000000000000) {
cout << -1 << endl;
return 0;
}
if (an == 1) {
cout << ans << endl;
} else {
cout << -1 << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, l, r) for (int i = (l); i < (r); i++)
int main() {
int N;
cin >> N;
ll ans = 1;
vector<ll> a(N);
rep(i, N) {
cin >> a[i];
ans *= a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
ll an = ans;
rep(i, N) { an /= a[i]; }
if (ans > 1000000000000000000) {
cout << -1 << endl;
return 0;
}
if (an == 1) {
cout << ans << endl;
} else {
cout << -1 << endl;
}
} | insert | 14 | 14 | 14 | 18 | 0 | |
p02658 | 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;
const ll MX = 1e18;
int main() {
int n;
cin >> n;
ll ans = 1;
bool flg = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (MX / ans < a) {
flg = true;
}
ans *= a;
}
if (flg)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll MX = 1e18;
int main() {
int n;
cin >> n;
ll ans = 1;
bool flg = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (flg || MX / ans < a) {
flg = true;
}
ans *= a;
}
if (flg)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| replace | 20 | 21 | 20 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
int n;
cin >> n;
ll ans = 1, x = 1e18;
bool ng = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (x / ans < a)
ng = true;
ans *= a;
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
int n;
cin >> n;
ll ans = 1, x = 1e18;
bool ng = false;
rep(i, n) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (ng || x / ans < a)
ng = true;
ans *= a;
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
long long a[10010];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
int zero = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 0) {
zero++;
break;
}
}
if (zero > 0) {
printf("0\n");
return 0;
}
long long p = 1;
for (int i = 0; i < n; i++) {
if (a[i] <= 1000000000000000000 / p) {
p = p * a[i];
} else {
printf("-1\n");
return 0;
}
}
printf("%lld\n", p);
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
long long a[100010];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
int zero = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 0) {
zero++;
break;
}
}
if (zero > 0) {
printf("0\n");
return 0;
}
long long p = 1;
for (int i = 0; i < n; i++) {
if (a[i] <= 1000000000000000000 / p) {
p = p * a[i];
} else {
printf("-1\n");
return 0;
}
}
printf("%lld\n", p);
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
const ll MAX = 1e18;
int main() {
int n;
cin >> n;
vll a(10010);
ll ans = 1;
rep(i, n) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
rep(i, n) {
if (ans <= MAX / a[i]) {
ans *= a[i];
} else {
ans = -1;
break;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
const ll MAX = 1e18;
int main() {
int n;
cin >> n;
vll a(100010);
ll ans = 1;
rep(i, n) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
rep(i, n) {
if (ans <= MAX / a[i]) {
ans *= a[i];
} else {
ans = -1;
break;
}
}
cout << ans << endl;
}
| replace | 16 | 17 | 16 | 17 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <math.h>
#include <set>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
int main() {
long long int MX = 1e18;
int n;
cin >> n;
long long int a;
long long int ans = 1;
bool ng = false;
rep(i, n) {
cin >> a;
if (a == 0) {
cout << '0';
return 0;
}
if ((MX + 1) / ans < a || ans * a > MX) {
ng = true;
}
ans *= a;
}
if (ng)
cout << "-1";
else
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <math.h>
#include <set>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
int main() {
long long int MX = 1e18;
int n;
cin >> n;
long long int a;
long long int ans = 1;
bool ng = false;
rep(i, n) {
cin >> a;
if (a == 0) {
cout << '0';
return 0;
}
if (ng || (MX + 1) / ans < a || ans * a > MX) {
ng = true;
}
ans *= a;
}
if (ng)
cout << "-1";
else
cout << ans;
}
| replace | 22 | 23 | 22 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; i < (n); ++(i))
using ll = long long int;
const ll MOD = 1e9 + 7;
int main() {
int N;
std::cin >> N;
ll ans = 1;
ll T = 1000000000000000000LL;
bool over = false;
rep(i, N) {
ll A;
std::cin >> A;
if (A == 0) {
std::cout << 0 << '\n';
return 0;
}
if (A > T / ans) {
over = true;
}
ans *= A;
}
std::cout << (over ? -1LL : ans) << '\n';
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; i < (n); ++(i))
using ll = long long int;
const ll MOD = 1e9 + 7;
int main() {
int N;
std::cin >> N;
ll ans = 1;
ll T = 1000000000000000000LL;
bool over = false;
rep(i, N) {
ll A;
std::cin >> A;
if (A == 0) {
std::cout << 0 << '\n';
return 0;
}
if (ans <= 0 || A > T / ans) {
over = true;
}
ans *= A;
}
std::cout << (over ? -1LL : ans) << '\n';
}
| replace | 22 | 23 | 22 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int64_t INF = 1e18;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
ll res = 1;
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
for (ll i = 0; i < n; i++) {
if (a[i] == 0) {
res = 0;
} else if (a[i] != 0) {
if (a[i] <= 1000000000000000000 / res)
res *= a[i];
else
res = -1;
}
}
cout << res << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int64_t INF = 1e18;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
ll res = 1;
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
for (ll i = 0; i < n; i++) {
if (a[i] == 0) {
cout << 0 << endl;
return 0;
} else if (a[i] != 0) {
if (a[i] <= 1000000000000000000 / res)
res *= a[i];
else
res = -1;
}
}
cout << res << endl;
}
| replace | 17 | 18 | 17 | 19 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
ll ans, mx, mn, flag, sum = 1, cnt;
ll c = 1e18;
ll a[1000000];
int main() {
ll n;
cin >> n;
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (ll i = 0; i < n; i++) {
sum *= a[i];
if (i < n - 1 && a[i + 1] > c / sum && sum != 0) {
cout << -1;
return 0;
}
}
cout << sum << endl;
}
| #include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
ll ans, mx, mn, flag, sum = 1, cnt;
ll c = 1e18;
ll a[1000000];
int main() {
ll n;
cin >> n;
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (ll i = 0; i < n; i++) {
sum *= a[i];
if (sum == 0) {
cout << 0 << endl;
return 0;
}
if (i < n - 1 && a[i + 1] > c / sum) {
cout << -1;
return 0;
}
}
cout << sum << endl;
}
| replace | 28 | 29 | 28 | 34 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
ll N, flag = 0, ans = 1;
cin >> N;
vector<ll> a(N);
rep(i, N) cin >> a[i];
rep(i, N) {
ans *= a[i];
if ((ans > 1000000000000000000) || (a[i] > (ll)1000000000000000000 / ans)) {
flag = 1;
}
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
if (flag == 1)
cout << -1 << endl;
if (flag == 0)
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
ll N, flag = 0, ans = 1;
cin >> N;
vector<ll> a(N);
rep(i, N) cin >> a[i];
rep(i, N) {
if (a[i] <= (ll)1000000000000000000 / ans) {
ans *= a[i];
} else {
flag = 1;
}
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
if (flag == 1)
cout << -1 << endl;
if (flag == 0)
cout << ans << endl;
return 0;
} | replace | 21 | 23 | 21 | 25 | 0 | |
p02658 | C++ | Runtime Error | #include <cmath>
#include <iostream>
long long MAX = std::pow(10, 18);
int main(int argc, const char *argv[]) {
long long N = 0;
scanf("%lld", &N);
long long ans = 0;
scanf("%lld", &ans);
for (int i = 1; i < N; i++) {
long long num = 0;
scanf("%lld", &num);
if (ans == -1 && num == 0) {
ans = 0;
} else if (ans == -1 && num > 0) {
ans = -1;
} else if (MAX / ans < num) {
ans = -1;
} else {
ans *= num;
}
}
std::cout << ans;
return 0;
}
| #include <cmath>
#include <iostream>
long long MAX = std::pow(10, 18);
int main(int argc, const char *argv[]) {
long long N = 0;
scanf("%lld", &N);
long long ans = 0;
scanf("%lld", &ans);
for (int i = 1; i < N; i++) {
long long num = 0;
scanf("%lld", &num);
if (ans == -1 && num == 0) {
ans = 0;
} else if (ans == -1 && num > 0) {
ans = -1;
} else if (MAX / ans < num) {
ans = -1;
} else {
ans *= num;
}
if (ans == 0) {
break;
}
}
std::cout << ans;
return 0;
}
| insert | 25 | 25 | 25 | 29 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
unsigned int n;
unsigned long int a[100001];
unsigned long long int s = 1;
int t = 0;
cin >> n;
for (unsigned int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] > 1000000000000000000 / s)
t = 1;
else
s *= a[i];
}
if (t == 1)
cout << -1;
else
cout << s;
return 0;
} | #include <iostream>
using namespace std;
int main() {
unsigned int n;
unsigned long int a[100001];
unsigned long long int s = 1;
int t = 0;
cin >> n;
for (unsigned int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] > 1000000000000000000 / s)
t = 1;
else
s *= a[i];
if (a[i] == 0) {
cout << 0;
return 0;
}
}
if (t == 1)
cout << -1;
else
cout << s;
return 0;
} | insert | 17 | 17 | 17 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for (int(i) = (n); (i) < (m); (i)++)
#define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) \
int x; \
cin >> (x)
#define ii2(x, y) \
int x, y; \
cin >> (x) >> (y)
#define ii3(x, y, z) \
int x, y, z; \
cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x) ? ("Yes") : ("No")) << endl
#define YN(x) cout << ((x) ? ("YES") : ("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)
inline void logger() { std::cout << " [LOGGER] " << endl; }
template <typename A, typename... B> void logger(const A &a, const B &...b) {
cout << a << " , ";
logger(b...);
}
typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 5005;
/* ...o(^-^)o... */
int main() {
int n;
cin >> n;
ulint prod = 1;
bool of = false;
const ulint M = 1e18;
rep(i, n) {
ulint a;
cin >> a;
if (a == 0) {
prod = 0;
of = false;
continue;
}
if (M < prod * a || M / prod < a || M / a < prod) {
of = true;
continue;
}
prod *= a;
}
if (of)
out(-1);
else
out(prod);
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for (int(i) = (n); (i) < (m); (i)++)
#define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) \
int x; \
cin >> (x)
#define ii2(x, y) \
int x, y; \
cin >> (x) >> (y)
#define ii3(x, y, z) \
int x, y, z; \
cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x) ? ("Yes") : ("No")) << endl
#define YN(x) cout << ((x) ? ("YES") : ("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)
inline void logger() { std::cout << " [LOGGER] " << endl; }
template <typename A, typename... B> void logger(const A &a, const B &...b) {
cout << a << " , ";
logger(b...);
}
typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 5005;
/* ...o(^-^)o... */
int main() {
int n;
cin >> n;
ulint prod = 1;
bool of = false;
const ulint M = 1e18;
rep(i, n) {
ulint a;
cin >> a;
if (a == 0) {
prod = 0;
of = false;
continue;
}
if (M < prod * a || M / a < prod) {
of = true;
continue;
}
prod *= a;
}
if (of)
out(-1);
else
out(prod);
} | replace | 57 | 58 | 57 | 58 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n, a;
cin >> n;
a = 1;
bool flg = false;
int64_t upper = 1000000000000000000;
for (int i = 0; i < n; i++) {
int64_t tmp;
cin >> tmp;
if (tmp == 0) {
a = 0;
break;
}
if (tmp > (upper / a)) {
flg = true;
}
a *= tmp;
if (a > upper) {
flg = true;
}
}
if (a == 0) {
cout << a << endl;
} else if (flg) {
cout << -1 << endl;
} else if (a < 0) {
cout << -1 << endl;
} else {
cout << a << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n, a;
cin >> n;
a = 1;
bool flg = false;
int64_t upper = 1000000000000000000;
for (int i = 0; i < n; i++) {
int64_t tmp;
cin >> tmp;
if (tmp == 0) {
a = 0;
break;
} else if (a > (upper / tmp)) {
flg = true;
}
a *= tmp;
if (a > upper) {
flg = true;
}
}
if (a == 0) {
cout << a << endl;
} else if (flg) {
cout << -1 << endl;
} else if (a < 0) {
cout << -1 << endl;
} else {
cout << a << endl;
}
} | replace | 15 | 17 | 15 | 16 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a, ll n, ll m);
ll power(ll a, ll n, ll m) {
if (n == 0)
return 1;
ll x = power(a, n / 2, m);
if (n % 2 != 0)
return (((a * x) % m) * (x) % m) % m;
else
return (x * x) % m;
}
map<ll, ll>::iterator itr;
ll ans;
double PI = 3.14159265357;
int32_t main() {
ll n, i, j, x, y, m, k, t, sum, count, cnt, b, c, d, j1, z, a, o, temp;
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
ll arr[n];
for (i = 0; i < n; i++)
cin >> arr[i];
sort(arr, arr + n);
cnt = 1;
for (i = 0; i < n; i++) {
if (arr[i] > (inf / cnt)) {
cout << "-1\n";
return 0;
}
cnt = (cnt * arr[i]);
}
cout << cnt;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a, ll n, ll m);
ll power(ll a, ll n, ll m) {
if (n == 0)
return 1;
ll x = power(a, n / 2, m);
if (n % 2 != 0)
return (((a * x) % m) * (x) % m) % m;
else
return (x * x) % m;
}
map<ll, ll>::iterator itr;
ll ans;
double PI = 3.14159265357;
int32_t main() {
ll n, i, j, x, y, m, k, t, sum, count, cnt, b, c, d, j1, z, a, o, temp;
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
ll arr[n];
for (i = 0; i < n; i++)
cin >> arr[i];
sort(arr, arr + n);
cnt = 1;
for (i = 0; i < n; i++) {
if (arr[i] == 0) {
cout << "0\n";
return 0;
}
if (arr[i] > (inf / cnt)) {
cout << "-1\n";
return 0;
}
cnt = (cnt * arr[i]);
}
cout << cnt;
return 0;
}
| insert | 32 | 32 | 32 | 37 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
int main() {
ios::sync_with_stdio(false);
int n, t = 0;
ll w = 1, k, a = 1000000000000000000;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> k;
if (k == 0) {
cout << "0";
return 0;
}
if (a / w < k)
t = 1;
w = w * k;
}
if (t)
cout << "-1";
else
cout << w;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
int main() {
ios::sync_with_stdio(false);
int n, t = 0;
ll w = 1, k, a = 1000000000000000000;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> k;
if (k == 0) {
cout << "0";
return 0;
}
if (a / w < k)
t = 1;
if (!t)
w = w * k;
}
if (t)
cout << "-1";
else
cout << w;
return 0;
}
| replace | 27 | 28 | 27 | 29 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
unsigned long long x;
unsigned long long z = 1;
bool flag = false;
bool zeroflag = false;
for (int i = 0; i < n; i++) {
cin >> x;
if (x == 0) {
zeroflag = true;
}
if (x <= 1000000000000000000 / z) {
z = z * x;
} else {
flag = true;
}
}
if (!zeroflag) {
if (!flag) {
cout << z << endl;
} else {
cout << -1 << endl;
}
} else {
cout << 0 << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
unsigned long long x;
unsigned long long z = 1;
bool flag = false;
bool zeroflag = false;
for (int i = 0; i < n; i++) {
cin >> x;
if (x == 0) {
zeroflag = true;
break;
}
if (x <= 1000000000000000000 / z) {
z = z * x;
} else {
flag = true;
}
}
if (!zeroflag) {
if (!flag) {
cout << z << endl;
} else {
cout << -1 << endl;
}
} else {
cout << 0 << endl;
}
return 0;
} | insert | 15 | 15 | 15 | 16 | 0 | |
p02658 | C++ | Runtime Error | // RAKSHIT KADAM
// ALWAYS USE &IT FOR ITERATING USING AUTO ...
// USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN
// THE RESPECTIVE DATA STRUCTURE NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18
// IT WILL ASSIGN A LOWER VALUE THAN THAT!!! NOTE THAT MEMSET CANT FILL THE
// DOUBLE VALUES; ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING
// BEYOND 1E9...
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int , null_type , less<int> , rb_tree_tag ,
// tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
// NUMERIC DEFINITIONS :
#define INF 2000000000000000005
#define MOD 1000000007
#define newMOD 998244353
#define MAX 300006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long
#define P(gg) \
for (auto rax : gg) { \
cout << rax << " "; \
} \
cout << endl;
#define Need_for_speed(activated) \
ios_base ::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL)
#define satisfy \
ll t; \
cin >> t; \
while (t--)
#define inp(n) \
int n; \
cin >> n
#define mp make_pair
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define fore(i, a, b) for (ll i = a; i < b; i++)
#define forci(i, n) for (ll i = 0; i < n; i++)
#define vi vector<ll>
#define Endl endl
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll, ll>
#define input \
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define time \
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int power(int x, unsigned int y, unsigned int m) {
if (y == 0)
return 1;
int p = power(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
ll modInverse(int a, int m) {
int g = gcd(a, m);
{ return power(a, m - 2, m); }
}
const int maxn = 500004;
ll bad;
void solve() {
ll n;
cin >> n;
ll ans = 1;
ll c = 1;
for (ll j = 1; j <= 18; j++)
c *= 10;
ll x;
for (ll i = 0; i < n; i++) {
cin >> x;
if (ans != 0)
if (c / ans < x) {
bad = 1;
}
if (c / ans >= x) {
ans *= x;
}
if (x == 0)
bad = 0, ans = 0;
}
if (bad)
cout << "-1" << endl;
else
cout << ans << endl;
}
signed main() {
Need_for_speed(activated);
// satisfy
// {
// solve();
// }
solve();
return 0;
}
| // RAKSHIT KADAM
// ALWAYS USE &IT FOR ITERATING USING AUTO ...
// USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN
// THE RESPECTIVE DATA STRUCTURE NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18
// IT WILL ASSIGN A LOWER VALUE THAN THAT!!! NOTE THAT MEMSET CANT FILL THE
// DOUBLE VALUES; ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING
// BEYOND 1E9...
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int , null_type , less<int> , rb_tree_tag ,
// tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
// NUMERIC DEFINITIONS :
#define INF 2000000000000000005
#define MOD 1000000007
#define newMOD 998244353
#define MAX 300006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long
#define P(gg) \
for (auto rax : gg) { \
cout << rax << " "; \
} \
cout << endl;
#define Need_for_speed(activated) \
ios_base ::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL)
#define satisfy \
ll t; \
cin >> t; \
while (t--)
#define inp(n) \
int n; \
cin >> n
#define mp make_pair
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define fore(i, a, b) for (ll i = a; i < b; i++)
#define forci(i, n) for (ll i = 0; i < n; i++)
#define vi vector<ll>
#define Endl endl
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll, ll>
#define input \
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define time \
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int power(int x, unsigned int y, unsigned int m) {
if (y == 0)
return 1;
int p = power(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * p) % m;
}
ll modInverse(int a, int m) {
int g = gcd(a, m);
{ return power(a, m - 2, m); }
}
const int maxn = 500004;
ll bad;
void solve() {
ll n;
cin >> n;
ll ans = 1;
ll c = 1;
for (ll j = 1; j <= 18; j++)
c *= 10;
ll x;
for (ll i = 0; i < n; i++) {
cin >> x;
if (ans != 0)
if (c / ans < x) {
bad = 1;
}
if (ans != 0)
if (c / ans >= x) {
ans *= x;
}
if (x == 0)
bad = 0, ans = 0;
}
if (bad)
cout << "-1" << endl;
else
cout << ans << endl;
}
signed main() {
Need_for_speed(activated);
// satisfy
// {
// solve();
// }
solve();
return 0;
}
| replace | 93 | 96 | 93 | 97 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long int> a(n);
int zer = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0)
zer = 1;
}
long long int ans = 1;
for (int i = 0; i < n; i++) {
long long int op = 1000000000000000000LL / ans;
long long int p = (1000000000000000001LL) / ans;
if (p != op)
p = op;
if (a[i] > p) {
if (zer == 0) {
cout << "-1" << endl;
return 0;
}
}
ans = ans * a[i];
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long int> a(n);
int zer = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0)
zer = 1;
}
long long int ans = 1;
for (int i = 0; i < n; i++) {
if (ans == 0) {
cout << "0" << endl;
return 0;
}
long long int op = 1000000000000000000LL / ans;
long long int p = (1000000000000000001LL) / ans;
if (p != op)
p = op;
if (a[i] > p) {
if (zer == 0) {
cout << "-1" << endl;
return 0;
}
}
ans = ans * a[i];
}
cout << ans << endl;
} | insert | 15 | 15 | 15 | 19 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long mx = 1e18;
int main() {
int n;
long long ans = 1;
bool ng = false;
cin >> n;
rep(i, n) {
long long a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (a > (mx / ans)) {
ng = true;
}
ans *= a;
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long mx = 1e18;
int main() {
int n;
long long ans = 1;
bool ng = false;
cin >> n;
rep(i, n) {
long long a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (ans > (mx / a)) {
ng = true;
}
ans *= a;
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| replace | 20 | 21 | 20 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(void) {
int N;
scanf("%d", &N);
long long A[10010];
long long ans = 1;
for (int i = 0; i < N; i++) {
scanf("%lld", &A[i]);
if (A[i] == 0) {
printf("0");
return 0;
}
}
for (int i = 0; i < N; i++) {
// cout << ans << " " << 1000000000000000000 / ans << endl;
if (1000000000000000000 / ans < A[i]) {
printf("-1");
return 0;
} else {
ans *= A[i];
}
}
printf("%lld", ans);
return 0;
}
| #include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(void) {
int N;
scanf("%d", &N);
long long A[100010];
long long ans = 1;
for (int i = 0; i < N; i++) {
scanf("%lld", &A[i]);
if (A[i] == 0) {
printf("0");
return 0;
}
}
for (int i = 0; i < N; i++) {
// cout << ans << " " << 1000000000000000000 / ans << endl;
if (1000000000000000000 / ans < A[i]) {
printf("-1");
return 0;
} else {
ans *= A[i];
}
}
printf("%lld", ans);
return 0;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define max_sum 1000000000000000000
int main() {
ll n;
cin >> n;
ll a;
long long sum = 1;
bool flag = 0;
for (int i = 0; i < n; i++) {
cin >> a;
if (a == 0) {
flag = 0;
sum = 0;
}
if (flag || max_sum / sum < a) {
flag = 1;
sum = 0;
} else {
sum *= a;
}
}
if (flag == 1) {
cout << -1 << endl;
} else {
cout << sum << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define max_sum 1000000000000000000
int main() {
ll n;
cin >> n;
ll a;
long long sum = 1;
bool flag = 0;
for (int i = 0; i < n; i++) {
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (flag || max_sum / sum < a) {
flag = 1;
sum = 0;
} else {
sum *= a;
}
}
if (flag == 1) {
cout << -1 << endl;
} else {
cout << sum << endl;
}
} | replace | 17 | 19 | 17 | 19 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, k, x, l(1);
cin >> n;
k = pow(10, 18);
for (int i = 0; i < n; i++) {
cin >> x;
k = k / x;
l *= x;
}
if (k == 0) {
cout << "-1";
} else
cout << l;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, k, x, l(1);
cin >> n;
k = pow(10, 18);
for (int i = 0; i < n; i++) {
cin >> x;
if (x == 0) {
l = 0;
k = 1;
break;
}
k = k / x;
l *= x;
}
if (k == 0) {
cout << "-1";
} else
cout << l;
} | insert | 11 | 11 | 11 | 16 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
int n;
ll A[MAXN];
void solve() {
ll ans = 1;
sort(A, A + n);
for (int i = 0; i < n; i++) {
if (1000000000000000000 / ans < A[i]) {
cout << -1 << endl;
return;
}
ans *= A[i];
if (ans > 1000000000000000000) {
cout << -1 << endl;
return;
}
}
cout << ans << endl;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> A[i];
}
solve();
}
| #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
int n;
ll A[MAXN];
void solve() {
ll ans = 1;
sort(A, A + n);
for (int i = 0; i < n; i++) {
if (ans == 0) {
cout << 0 << endl;
return;
}
if (1000000000000000000 / ans < A[i]) {
cout << -1 << endl;
return;
}
ans *= A[i];
if (ans > 1000000000000000000) {
cout << -1 << endl;
return;
}
}
cout << ans << endl;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> A[i];
}
solve();
}
| insert | 15 | 15 | 15 | 19 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ostream &operator<<(ostream &dest, __int128_t value) {
ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(ios_base::badbit);
}
}
return dest;
}
__int128 parse(string &s) {
__int128 ret = 0;
for (int i = 0; i < (int)s.length(); i++)
if ('0' <= s[i] && s[i] <= '9')
ret = 10 * ret + s[i] - '0';
return ret;
}
istream &operator>>(istream &is, __int128_t &a) {
string s;
is >> s;
a = parse(s);
return (is);
}
using Int = __int128_t;
int main() {
int n;
cin >> n;
vector<Int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
if (count(a.begin(), a.end(), Int(0))) {
cout << 0 << endl;
return 0;
}
Int t = 1;
for (int i = 0; i < n; i++) {
if (t * a[i] > Int(1000000000000000000)) {
cout << -1 << endl;
return -1;
}
t *= a[i];
}
cout << t << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ostream &operator<<(ostream &dest, __int128_t value) {
ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(ios_base::badbit);
}
}
return dest;
}
__int128 parse(string &s) {
__int128 ret = 0;
for (int i = 0; i < (int)s.length(); i++)
if ('0' <= s[i] && s[i] <= '9')
ret = 10 * ret + s[i] - '0';
return ret;
}
istream &operator>>(istream &is, __int128_t &a) {
string s;
is >> s;
a = parse(s);
return (is);
}
using Int = __int128_t;
int main() {
int n;
cin >> n;
vector<Int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
if (count(a.begin(), a.end(), Int(0))) {
cout << 0 << endl;
return 0;
}
Int t = 1;
for (int i = 0; i < n; i++) {
if (t * a[i] > Int(1000000000000000000)) {
cout << -1 << endl;
return 0;
}
t *= a[i];
}
cout << t << endl;
}
| replace | 58 | 59 | 58 | 59 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FORR(i, a, n) for (int i = a; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
// int in() { int x; scanf("%d", &x); return x; }
// ll lin() { ll x; scanf("%lld", &x); return x; }
// void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }
const ll MAX = 1e18;
int main(void) {
std::ios_base::sync_with_stdio(false);
int n;
cin >> n;
ll ans = 1;
bool ng = false;
FOR(i, n) {
ll tmp;
cin >> tmp;
if (tmp == 0) {
cout << 0 << endl;
return 0;
}
if (MAX / ans < tmp || ans * tmp > MAX) {
ng = true;
}
ans *= tmp;
}
if (ng)
cout << -1 << endl;
else
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FORR(i, a, n) for (int i = a; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
// int in() { int x; scanf("%d", &x); return x; }
// ll lin() { ll x; scanf("%lld", &x); return x; }
// void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }
const ll MAX = 1e18;
int main(void) {
std::ios_base::sync_with_stdio(false);
int n;
cin >> n;
ll ans = 1;
bool ng = false;
FOR(i, n) {
ll tmp;
cin >> tmp;
if (tmp == 0) {
cout << 0 << endl;
return 0;
}
if (ng || MAX / ans < tmp) {
ng = true;
}
ans *= tmp;
}
if (ng)
cout << -1 << endl;
else
cout << ans;
return 0;
} | replace | 44 | 45 | 44 | 45 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) { cin >> a[i]; }
ll ans = 1;
int ansm = 0;
sort(ALL(a));
for (int i = 0; i < n; i++) {
if (ans > 1000000000000000000 / a[i]) {
ansm = -1;
break;
} else {
ans *= a[i];
}
}
if (ansm == -1) {
cout << ansm << "\n";
} else {
cout << ans << "\n";
}
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) { cin >> a[i]; }
ll ans = 1;
int ansm = 0;
sort(ALL(a));
for (int i = 0; i < n; i++) {
if (a[i] == 0) {
ans = 0;
break;
}
if (ans > 1000000000000000000 / a[i]) {
ansm = -1;
break;
} else {
ans *= a[i];
}
}
if (ansm == -1) {
cout << ansm << "\n";
} else {
cout << ans << "\n";
}
} | insert | 23 | 23 | 23 | 28 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
long long lim = 1e18;
int n;
cin >> n;
long long a[n], ans = 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0)
ans = 0;
else if (a[i] > lim / ans)
ans = -1;
else if (ans != -1)
ans *= a[i];
}
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
long long lim = 1e18;
int n;
cin >> n;
long long a[n], ans = 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0)
ans = 0;
else if (ans > lim / a[i])
ans = -1;
else if (ans != -1)
ans *= a[i];
}
cout << ans << "\n";
return 0;
} | replace | 13 | 14 | 13 | 14 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
ll a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = 1;
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (ans > INF / a[i]) {
ans = -1;
break;
} else {
ans *= a[i];
}
}
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
ll a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = 1;
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (a[i] && ans > INF / a[i]) {
ans = -1;
break;
} else {
ans *= a[i];
}
}
cout << ans << '\n';
return 0;
} | replace | 32 | 33 | 32 | 33 | 0 | |
p02658 | 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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MX = 1e18;
int main() {
int N;
cin >> N;
ll sum = 1;
bool ng = false;
REP(i, N) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if ((MX / sum) < a || sum * a > MX) {
ng = true;
}
sum *= a;
}
if (ng) {
cout << -1 << endl;
} else {
cout << sum << endl;
}
return 0;
} | #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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MX = 1e18;
int main() {
int N;
cin >> N;
ll sum = 1;
bool ng = false;
REP(i, N) {
ll a;
cin >> a;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (ng || (MX / sum) < a || sum * a > MX) {
ng = true;
}
sum *= a;
}
if (ng) {
cout << -1 << endl;
} else {
cout << sum << endl;
}
return 0;
} | replace | 22 | 23 | 22 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath> //sqrt
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll unsigned long long
int main() {
auto mul = [](ll x, ll y) {
ll inf = pow(10, 18);
if (inf / x < y)
return inf + 1;
else
return x * y;
};
int N;
ll MA = 1;
rep(i, 18) MA *= 10;
cin >> N;
ll tot = 1;
rep(i, N) {
ll a;
cin >> a;
tot = mul(tot, a);
}
if (MA < tot)
cout << "-1" << endl;
else
cout << tot << endl;
return 0;
}
| #include <algorithm>
#include <cmath> //sqrt
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll unsigned long long
int main() {
auto mul = [](ll x, ll y) {
ll inf = pow(10, 18);
if (x != 0 && inf / x < y)
return inf + 1;
else
return x * y;
};
int N;
ll MA = 1;
rep(i, 18) MA *= 10;
cin >> N;
ll tot = 1;
rep(i, N) {
ll a;
cin >> a;
tot = mul(tot, a);
}
if (MA < tot)
cout << "-1" << endl;
else
cout << tot << endl;
return 0;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
long long int answer;
bool ans;
ans = false;
answer = 1;
cin >> N;
vector<long long int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] == 0) {
answer = 0;
}
}
for (int i = 0; i < N; i++) {
if (answer < 1000000000000000000 / A[i]) {
answer *= A[i];
} else {
ans = true;
}
}
if (answer == 0) {
cout << 0 << endl;
} else if (ans) {
cout << -1 << endl;
} else {
cout << answer << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
long long int answer;
bool ans;
ans = false;
answer = 1;
cin >> N;
vector<long long int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] == 0) {
answer = 0;
}
}
for (int i = 0; i < N; i++) {
if (answer != 0 && A[i] <= 1000000000000000000 / answer) {
answer *= A[i];
} else {
ans = true;
}
}
if (answer == 0) {
cout << 0 << endl;
} else if (ans) {
cout << -1 << endl;
} else {
cout << answer << endl;
}
}
| replace | 19 | 20 | 19 | 20 | 0 | |
p02658 | 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++) // 最初の数値を指定したループ
// 型名省略
typedef long long ll;
// 配列要素数
static const int MAX = 200000;
// 値
static const ll MX = 1e18;
using namespace std;
// #include "./lib/generic/sort.h"
std::tuple<int, int> swap(int num1, int num2) {
return std::forward_as_tuple(num1, num2);
}
void traceArray(int A[], int N) {
for (int i = 0; i < N; i++) {
cout << A[i];
if (i != N - 1) {
cout << " ";
}
}
cout << endl;
}
int push(int A[], int pointer, int tmp) {
A[pointer] = tmp;
return pointer++;
}
int main() {
/*int N;
cin >> N;
int A[N];
REP(i, N) cin >> A[i];*/
// sort::Sort test;
// test.sortByIntention(A, N);
// test.sortByBubble(A, N);
// test.sortBySelection(A, N);
// traceArray(A, N);
/*int N=200, pointer=0;
int A[N];
char tmp;
while(1){
cin >> tmp;
//pointer == push(A, pointer, tmp);
if(cin.eof()){
cout << "bbb" << endl;
break;
}
}*/
ll N;
cin >> N;
ll tmp, ans = 1;
bool ng = false;
REP(i, N) {
cin >> tmp;
if (tmp == 0) {
cout << "0" << endl;
return 0;
}
if (tmp >= MX / ans) {
ans *= tmp;
} else {
ng = true;
}
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | #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++) // 最初の数値を指定したループ
// 型名省略
typedef long long ll;
// 配列要素数
static const int MAX = 200000;
// 値
static const ll MX = 1e18;
using namespace std;
// #include "./lib/generic/sort.h"
std::tuple<int, int> swap(int num1, int num2) {
return std::forward_as_tuple(num1, num2);
}
void traceArray(int A[], int N) {
for (int i = 0; i < N; i++) {
cout << A[i];
if (i != N - 1) {
cout << " ";
}
}
cout << endl;
}
int push(int A[], int pointer, int tmp) {
A[pointer] = tmp;
return pointer++;
}
int main() {
/*int N;
cin >> N;
int A[N];
REP(i, N) cin >> A[i];*/
// sort::Sort test;
// test.sortByIntention(A, N);
// test.sortByBubble(A, N);
// test.sortBySelection(A, N);
// traceArray(A, N);
/*int N=200, pointer=0;
int A[N];
char tmp;
while(1){
cin >> tmp;
//pointer == push(A, pointer, tmp);
if(cin.eof()){
cout << "bbb" << endl;
break;
}
}*/
ll N;
cin >> N;
ll tmp, ans = 1;
bool ng = false;
REP(i, N) {
cin >> tmp;
if (tmp == 0) {
cout << "0" << endl;
return 0;
}
if (tmp <= MX / ans) {
ans *= tmp;
} else {
ng = true;
}
}
if (ng)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | replace | 74 | 75 | 74 | 75 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
template <typename T> T gcd(T a, T b) {
while (b != 0) {
T temp = a;
a = b;
b = temp % b;
}
return a;
}
// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string
void solve() {
int n;
cin >> n;
std::vector<ull> a(n);
ull sum = 1, limit = 1e18;
bool flag = true;
for (auto &it : a) {
cin >> it;
}
sort(a.rbegin(), a.rend());
sum = a.back();
for (int i = a.size() - 2; i >= 0; --i) {
if (a[i] > limit / sum) {
flag = false;
break;
} else {
sum *= a[i];
}
}
if (flag) {
cout << sum << endl;
} else {
cout << -1 << endl;
}
}
int main() {
IOS;
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
| #include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
template <typename T> T gcd(T a, T b) {
while (b != 0) {
T temp = a;
a = b;
b = temp % b;
}
return a;
}
// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string
void solve() {
int n;
cin >> n;
std::vector<ull> a(n);
ull sum = 1, limit = 1e18;
bool flag = true;
for (auto &it : a) {
cin >> it;
}
sort(a.rbegin(), a.rend());
if (a.back() == 0) {
cout << 0 << endl;
return;
}
sum = a.back();
for (int i = a.size() - 2; i >= 0; --i) {
if (a[i] > limit / sum) {
flag = false;
break;
} else {
sum *= a[i];
}
}
if (flag) {
cout << sum << endl;
} else {
cout << -1 << endl;
}
}
int main() {
IOS;
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
| insert | 64 | 64 | 64 | 68 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p02658 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#define MAX 1000000000000000000
using namespace std;
int main() {
int n;
cin >> n;
vector<unsigned long long int> v;
// bool zeroes=false;
unsigned long long int mul = 1, prev = 1, flag = 0;
for (int i = 0; i < n; ++i) {
cin >> v[i];
if (v[i] == 0) {
flag = 1;
break;
}
}
if (flag) {
cout << "0" << endl;
return 0;
}
for (int i = 0; i < n; ++i) {
mul *= v[i];
if (mul / v[i] != prev || mul > MAX) {
cout << "-1" << endl;
return 0;
}
prev = mul;
}
cout << mul << endl;
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#define MAX 1000000000000000000
using namespace std;
int main() {
int n;
cin >> n;
vector<unsigned long long int> v(n);
// bool zeroes=false;
unsigned long long int mul = 1, prev = 1, flag = 0;
for (int i = 0; i < n; ++i) {
cin >> v[i];
if (v[i] == 0) {
flag = 1;
break;
}
}
if (flag) {
cout << "0" << endl;
return 0;
}
for (int i = 0; i < n; ++i) {
mul *= v[i];
if (mul / v[i] != prev || mul > MAX) {
cout << "-1" << endl;
return 0;
}
prev = mul;
}
cout << mul << endl;
return 0;
}
| replace | 9 | 10 | 9 | 10 | -11 | |
p02658 | C++ | Runtime Error | // J'aime
// Chemise Blanche
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define int unsigned long long
#define ii pair<int, int>
#define fi first
#define sc second
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl
#define i1e18 1000000000000000000
void MAIN() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a)
cin >> i;
sort(all(a));
int ans = 1;
for (auto &t : a) {
if (ans <= i1e18 / t) {
ans *= t;
if (ans > i1e18) {
cout << -1 << '\n';
return;
}
} else {
cout << -1 << '\n';
return;
}
}
cout << ans << '\n';
}
signed main() {
#ifdef _DEBUG
// freopen("in" , "r", stdin );
// freopen("out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
// cin >> T;
while (T--)
MAIN();
}
| // J'aime
// Chemise Blanche
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define int unsigned long long
#define ii pair<int, int>
#define fi first
#define sc second
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl
#define i1e18 1000000000000000000
void MAIN() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a)
cin >> i;
sort(all(a));
if (a[0] == 0) {
cout << 0 << '\n';
return;
}
int ans = 1;
for (auto &t : a) {
if (ans <= i1e18 / t) {
ans *= t;
if (ans > i1e18) {
cout << -1 << '\n';
return;
}
} else {
cout << -1 << '\n';
return;
}
}
cout << ans << '\n';
}
signed main() {
#ifdef _DEBUG
// freopen("in" , "r", stdin );
// freopen("out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
// cin >> T;
while (T--)
MAIN();
}
| insert | 25 | 25 | 25 | 29 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int N;
int main() {
cin >> N;
long long a[10101], ans = 1;
for (int i = 0; i < N; i++) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
for (int i = 0; i < N; i++) {
if (a[i] > 1000000000000000000 / ans) {
cout << -1 << endl;
return 0;
} else {
ans *= a[i];
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int N;
int main() {
cin >> N;
long long a[1000000], ans = 1;
for (int i = 0; i < N; i++) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
for (int i = 0; i < N; i++) {
if (a[i] > 1000000000000000000 / ans) {
cout << -1 << endl;
return 0;
} else {
ans *= a[i];
}
}
cout << ans << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int long long
#define FF(i, a, b) for (int i = a; i < b; i++)
#define BF(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define MAP map<int, int>
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define pi pair<int, int>
#define all(v) v.begin(), v.end()
#define PIE 3.1415926535897932384626433832795
#define FastIO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
// #define ordered_set
// tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*
order_of_key (k) : Number of items strictly smaller than k .
find_by_order(k) : K-th element in a set (counting from zero).
*/
/**************************************************************************************/
/*Global Variables*/
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int inf = 3e18;
/**************************************************************************************/
template <typename A> istream &operator>>(istream &input, vector<A> &x) {
for (auto &i : x)
input >> i;
return input;
}
template <typename A> ostream &operator<<(ostream &output, vector<A> &x) {
for (auto &i : x)
output << i << ' ';
return output;
}
int add(int a, int b) { return (a % mod + b % mod + mod) % mod; }
int sub(int a, int b) { return (a % mod - b % mod + mod) % mod; }
int mul(int a, int b) { return ((a % mod) * (b % mod) + mod) % mod; }
int Power(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
signed main() {
FastIO;
int T = 1;
// cin>>T;
while (T--) {
int n;
cin >> n;
vi a(n);
cin >> a;
int ans = 1;
int k = 1e18;
sort(all(a));
bool ok = true;
for (auto it : a) {
if (it > (k / ans)) {
cout << -1 << "\n";
ok = false;
break;
} else
ans *= it;
}
if (ok)
cout << ans << "\n";
}
}
/*
|| Do what you can with all you have,wherever you are. ||
|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||
|| A goal is a dream with deadline. ||
|| Whether you think you can or you think you can't, you're right. ||
|| A year from now you may wish you had started today ||
*/
| #include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int long long
#define FF(i, a, b) for (int i = a; i < b; i++)
#define BF(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define MAP map<int, int>
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define pi pair<int, int>
#define all(v) v.begin(), v.end()
#define PIE 3.1415926535897932384626433832795
#define FastIO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
// #define ordered_set
// tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*
order_of_key (k) : Number of items strictly smaller than k .
find_by_order(k) : K-th element in a set (counting from zero).
*/
/**************************************************************************************/
/*Global Variables*/
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int inf = 3e18;
/**************************************************************************************/
template <typename A> istream &operator>>(istream &input, vector<A> &x) {
for (auto &i : x)
input >> i;
return input;
}
template <typename A> ostream &operator<<(ostream &output, vector<A> &x) {
for (auto &i : x)
output << i << ' ';
return output;
}
int add(int a, int b) { return (a % mod + b % mod + mod) % mod; }
int sub(int a, int b) { return (a % mod - b % mod + mod) % mod; }
int mul(int a, int b) { return ((a % mod) * (b % mod) + mod) % mod; }
int Power(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
signed main() {
FastIO;
int T = 1;
// cin>>T;
while (T--) {
int n;
cin >> n;
vi a(n);
cin >> a;
int ans = 1;
int k = 1e18;
sort(all(a));
bool ok = true;
for (auto it : a) {
if (ans == 0) {
cout << 0 << "\n";
ok = false;
break;
}
if (it > (k / ans)) {
cout << -1 << "\n";
ok = false;
break;
} else
ans *= it;
}
if (ok)
cout << ans << "\n";
}
}
/*
|| Do what you can with all you have,wherever you are. ||
|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||
|| A goal is a dream with deadline. ||
|| Whether you think you can or you think you can't, you're right. ||
|| A year from now you may wish you had started today ||
*/
| insert | 73 | 73 | 73 | 78 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define lld long long double
#define pb push_back
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
unsigned long long prod = 1;
vector<unsigned long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end());
for (int i = 0; i < n; i++) {
if (arr[i] > 1000000000000000000 / prod) {
cout << -1;
return 0;
}
prod = prod * arr[i];
}
// if(prod<0) {cout <<-1;return 0;}
cout << prod;
}
| #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define lld long long double
#define pb push_back
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
unsigned long long prod = 1;
vector<unsigned long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end());
if (arr[0] == 0) {
cout << 0;
return 0;
}
for (long long i = 0; i < n; i++) {
if (arr[i] > 1000000000000000000 / prod) {
cout << -1;
return 0;
}
prod = prod * arr[i];
}
// if(prod<0) {cout <<-1;return 0;}
cout << prod;
}
| replace | 19 | 20 | 19 | 24 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define lld long long double
#define pb push_back
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
unsigned long long prod = 1;
vector<unsigned long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end());
// if(arr[0]==0){cout<<0;return 0;}
for (long long i = 0; i < n; i++) {
if (arr[i] > 1000000000000000000 / prod) {
cout << -1;
return 0;
}
prod = prod * arr[i];
}
// if(prod<0) {cout <<-1;return 0;}
cout << prod;
}
| #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define lld long long double
#define pb push_back
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
unsigned long long prod = 1;
vector<unsigned long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end());
if (arr[0] == 0) {
cout << 0;
return 0;
}
for (long long i = 0; i < n; i++) {
if (arr[i] > 1000000000000000000 / prod) {
cout << -1;
return 0;
}
prod = prod * arr[i];
}
// if(prod<0) {cout <<-1;return 0;}
cout << prod;
}
| replace | 19 | 20 | 19 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long teisuu = 1000000000000000000;
int main() {
long long n;
cin >> n;
vector<long long> a(n);
for (long long i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
long long kotae = a[0];
for (long long i = 1; i < n; i++) {
if (teisuu / kotae > a[i]) {
cout << -1 << endl;
return 0;
}
kotae *= a[i];
}
cout << kotae << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long teisuu = 1000000000000000000;
int main() {
long long n;
cin >> n;
vector<long long> a(n);
for (long long i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
cout << 0 << endl;
return 0;
}
}
long long kotae = 1;
for (long long i = 0; i < n; i++) {
if (teisuu / kotae < a[i]) {
cout << -1 << endl;
return 0;
}
kotae *= a[i];
}
cout << kotae << endl;
return 0;
}
| replace | 15 | 18 | 15 | 18 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
// headers {{{
using namespace std;
// using namespace rel_ops;
typedef long long int64;
typedef unsigned long long uint64;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int INF = 0x7FFFFFFF;
template <class T> inline bool checkmin(T &a, T b) {
return b < a ? a = b, 1 : 0;
}
template <class T> inline bool checkmax(T &a, T b) {
return b > a ? a = b, 1 : 0;
}
template <class T> inline T sqr(T x) { return x * x; }
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A, B) make_pair(A, B)
#define PB(X) push_back(X)
#define mem(a, b) memset(a, b, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ff first
#define ss second
#ifdef LOCAL
#define dbg(args...) printf(args); // ##__VA_ARGS__
#define dout cout
#define out(x) (cout << #x << ": " << x << endl)
template <class T> void show(T a, int n) {
for (int i = 0; i < n; ++i)
cout << a[i] << ' ';
cout << endl;
}
template <class T> void show(T a, int r, int l) {
for (int i = 0; i < r; ++i)
show(a[i], l);
cout << endl;
}
#else
#define dbg(...)
#define dout \
if (true) \
; \
else \
cout
#define out(...)
#define show(...)
#endif
// }}}
int main() {
int N;
while (cin >> N) {
vector<int64> v(N);
rep(i, N) cin >> v[i];
int64 s = 1e18, ans = 1;
rep(i, N) {
s /= v[i];
ans *= v[i];
}
if (s < 1)
cout << -1 << endl;
else
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
// headers {{{
using namespace std;
// using namespace rel_ops;
typedef long long int64;
typedef unsigned long long uint64;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int INF = 0x7FFFFFFF;
template <class T> inline bool checkmin(T &a, T b) {
return b < a ? a = b, 1 : 0;
}
template <class T> inline bool checkmax(T &a, T b) {
return b > a ? a = b, 1 : 0;
}
template <class T> inline T sqr(T x) { return x * x; }
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A, B) make_pair(A, B)
#define PB(X) push_back(X)
#define mem(a, b) memset(a, b, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ff first
#define ss second
#ifdef LOCAL
#define dbg(args...) printf(args); // ##__VA_ARGS__
#define dout cout
#define out(x) (cout << #x << ": " << x << endl)
template <class T> void show(T a, int n) {
for (int i = 0; i < n; ++i)
cout << a[i] << ' ';
cout << endl;
}
template <class T> void show(T a, int r, int l) {
for (int i = 0; i < r; ++i)
show(a[i], l);
cout << endl;
}
#else
#define dbg(...)
#define dout \
if (true) \
; \
else \
cout
#define out(...)
#define show(...)
#endif
// }}}
int main() {
int N;
while (cin >> N) {
auto solve = [&]() {
vector<int64> v(N);
rep(i, N) cin >> v[i];
int64 s = 1e18, ans = 1;
rep(i, N) {
if (v[i] == 0) {
cout << 0 << endl;
return;
}
s /= v[i];
ans *= v[i];
}
if (s < 1)
cout << -1 << endl;
else
cout << ans << endl;
};
solve();
}
return 0;
}
| replace | 57 | 68 | 57 | 75 | 0 | |
p02658 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main() {
int n;
std::cin >> n;
std::vector<std::string> a(n);
bool zero = false;
unsigned int lensum = 0;
for (int i = 0; i < n; ++i) {
std::cin >> a.at(i);
if (a.at(i) == "0") {
zero = true;
}
lensum += a.at(i).size() - 1;
}
if (zero) {
std::cout << "0" << std::endl;
return 0;
}
if (lensum > 19) {
std::cout << "-1" << std::endl;
}
std::string final_result = a.at(0);
for (int i = 1; i < n; ++i) {
std::string u = a.at(i);
std::vector<std::string> temps(u.size(), "");
for (unsigned int j = 0; j < u.size(); ++j) {
int p = std::stoi(u.substr(u.size() - 1 - j, 1));
int kuriagari = 0;
for (unsigned int k = 0; k < final_result.size(); ++k) {
int q = std::stoi(final_result.substr(final_result.size() - 1 - k, 1));
int r = p * q;
temps.at(j) += std::to_string((kuriagari + r) % 10);
kuriagari = (kuriagari + r) / 10;
if (k == final_result.size() - 1 && kuriagari != 0) {
temps.at(j) += std::to_string(kuriagari);
}
}
std::reverse(temps.at(j).begin(), temps.at(j).end());
for (unsigned int l = 0; l < j; ++l) {
temps.at(j) += "0";
}
// std::cout << temps.at(j) << std::endl;
}
unsigned int maxlen = 0;
for (unsigned int j = 0; j < u.size(); ++j) {
if (temps.at(j).size() > maxlen) {
maxlen = temps.at(j).size();
}
}
for (unsigned int j = 0; j < u.size(); ++j) {
while (temps.at(j).size() != maxlen) {
temps.at(j).insert(0, "0");
}
// std::cout << temps.at(j) << std::endl;
}
final_result = "";
int kuriagari = 0;
for (unsigned int l = 0; l < maxlen; ++l) {
int sum = 0;
for (unsigned int j = 0; j < u.size(); ++j) {
sum += std::stoi(temps.at(j).substr(maxlen - 1 - l, 1));
}
final_result += std::to_string((kuriagari + sum) % 10);
kuriagari = (kuriagari + sum) / 10;
if (l == maxlen - 1 && kuriagari != 0) {
final_result += std::to_string(kuriagari);
}
}
std::reverse(final_result.begin(), final_result.end());
if (final_result.substr(0, 1) == "0") {
final_result = "0";
}
// std::cout << final_result << std::endl;
}
// std::cout << final_result << std::endl;
if (final_result.size() >= 19 && final_result > "1000000000000000000") {
final_result = "-1";
}
std::cout << final_result << std::endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main() {
int n;
std::cin >> n;
std::vector<std::string> a(n);
bool zero = false;
unsigned int lensum = 0;
for (int i = 0; i < n; ++i) {
std::cin >> a.at(i);
if (a.at(i) == "0") {
zero = true;
}
lensum += a.at(i).size() - 1;
}
if (zero) {
std::cout << "0" << std::endl;
return 0;
}
if (lensum > 19) {
std::cout << "-1" << std::endl;
return 0;
}
std::string final_result = a.at(0);
for (int i = 1; i < n; ++i) {
std::string u = a.at(i);
std::vector<std::string> temps(u.size(), "");
for (unsigned int j = 0; j < u.size(); ++j) {
int p = std::stoi(u.substr(u.size() - 1 - j, 1));
int kuriagari = 0;
for (unsigned int k = 0; k < final_result.size(); ++k) {
int q = std::stoi(final_result.substr(final_result.size() - 1 - k, 1));
int r = p * q;
temps.at(j) += std::to_string((kuriagari + r) % 10);
kuriagari = (kuriagari + r) / 10;
if (k == final_result.size() - 1 && kuriagari != 0) {
temps.at(j) += std::to_string(kuriagari);
}
}
std::reverse(temps.at(j).begin(), temps.at(j).end());
for (unsigned int l = 0; l < j; ++l) {
temps.at(j) += "0";
}
// std::cout << temps.at(j) << std::endl;
}
unsigned int maxlen = 0;
for (unsigned int j = 0; j < u.size(); ++j) {
if (temps.at(j).size() > maxlen) {
maxlen = temps.at(j).size();
}
}
for (unsigned int j = 0; j < u.size(); ++j) {
while (temps.at(j).size() != maxlen) {
temps.at(j).insert(0, "0");
}
// std::cout << temps.at(j) << std::endl;
}
final_result = "";
int kuriagari = 0;
for (unsigned int l = 0; l < maxlen; ++l) {
int sum = 0;
for (unsigned int j = 0; j < u.size(); ++j) {
sum += std::stoi(temps.at(j).substr(maxlen - 1 - l, 1));
}
final_result += std::to_string((kuriagari + sum) % 10);
kuriagari = (kuriagari + sum) / 10;
if (l == maxlen - 1 && kuriagari != 0) {
final_result += std::to_string(kuriagari);
}
}
std::reverse(final_result.begin(), final_result.end());
if (final_result.substr(0, 1) == "0") {
final_result = "0";
}
// std::cout << final_result << std::endl;
}
// std::cout << final_result << std::endl;
if (final_result.size() >= 19 && final_result > "1000000000000000000") {
final_result = "-1";
}
std::cout << final_result << std::endl;
return 0;
}
| insert | 27 | 27 | 27 | 28 | TLE | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int>> vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v) \
for (int i = 0; i != v.size(); i++) \
cout << v[i] << ' '
#define vin(v) \
for (auto &i : v) \
cin >> i
ld pi = 3.141592653589793238;
ll M = 1e9 + 7;
int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
bool is_prime(ll n) {
if (n == 2)
return true;
if (n < 2)
return false;
if (n % 2 == 0)
return false;
for (int i = 3; i <= sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
return true;
}
bool is_palindrome(string s) { return equal(s.rbegin(), s.rend(), s.begin()); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t, n, m, k, q, x, y;
string s;
bool flag;
cin >> n;
vll v(n);
vin(v);
unsigned long long prod = 1;
unsigned long long up = 1000000000000000000;
sort(v.begin(), v.end());
for (int i = 0; i != v.size(); i++) {
if (prod == 0)
break;
if (prod > up / v[i]) {
print(-1);
return 0;
}
prod *= v[i];
}
print(prod);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int>> vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v) \
for (int i = 0; i != v.size(); i++) \
cout << v[i] << ' '
#define vin(v) \
for (auto &i : v) \
cin >> i
ld pi = 3.141592653589793238;
ll M = 1e9 + 7;
int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
bool is_prime(ll n) {
if (n == 2)
return true;
if (n < 2)
return false;
if (n % 2 == 0)
return false;
for (int i = 3; i <= sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
return true;
}
bool is_palindrome(string s) { return equal(s.rbegin(), s.rend(), s.begin()); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t, n, m, k, q, x, y;
string s;
bool flag;
cin >> n;
vll v(n);
vin(v);
unsigned long long prod = 1;
unsigned long long up = 1000000000000000000;
sort(v.begin(), v.end());
for (int i = 0; i != v.size(); i++) {
if (prod == 0)
break;
if (v[i] > up / prod) {
print(-1);
return 0;
}
prod *= v[i];
}
print(prod);
return 0;
} | replace | 74 | 75 | 74 | 75 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
// vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main() {
long long int n;
long long tmp;
cin >> n;
long long int res = 1;
vector<int> a(n);
int flag_zero = 0;
int flag_18 = 0;
for (int i = 0; i < n; i++) {
cin >> tmp;
if (tmp == 0) {
flag_zero = 1;
}
if (tmp <= 1000000000000000000 / res) {
res = res * tmp;
} else {
flag_18 = 1;
}
}
// flag++;
// cout << flag << endl;
// cout << res << endl;
if (flag_zero == 1) {
cout << 0 << endl;
} else if (flag_18 == 1) {
cout << -1 << endl;
} else {
cout << res << endl;
}
}
// 1000000000000000000
// 9223372036854775807
// 1000000000000000001 | #include <bits/stdc++.h>
using namespace std;
// vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main() {
long long int n;
long long tmp;
cin >> n;
long long int res = 1;
vector<int> a(n);
int flag_zero = 0;
int flag_18 = 0;
for (int i = 0; i < n; i++) {
cin >> tmp;
if (tmp == 0) {
flag_zero = 1;
break;
}
if (tmp <= 1000000000000000000 / res) {
res = res * tmp;
} else {
flag_18 = 1;
}
}
// flag++;
// cout << flag << endl;
// cout << res << endl;
if (flag_zero == 1) {
cout << 0 << endl;
} else if (flag_18 == 1) {
cout << -1 << endl;
} else {
cout << res << endl;
}
}
// 1000000000000000000
// 9223372036854775807
// 1000000000000000001 | insert | 15 | 15 | 15 | 16 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
int N;
cin >> N;
long A[N];
long long result = 1;
long long thre = 1000000000000000000;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N);
if (A[0] == 0) {
cout << 0 << endl;
return 0;
} else {
for (int i = N - 1; i >= 0; i--) {
result *= A[i];
if (thre / result > 1) {
cout << -1 << endl;
return 0;
}
}
}
cout << result << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
int N;
cin >> N;
long A[N];
long long result = 1;
long long thre = 1000000000000000000;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N);
if (A[0] == 0) {
cout << 0 << endl;
return 0;
} else {
for (int i = N - 1; i >= 0; i--) {
if (A[i] <= thre / result) {
result *= A[i];
} else {
cout << -1 << endl;
return 0;
}
}
}
cout << result << endl;
return 0;
}
| replace | 20 | 22 | 20 | 23 | 0 | |
p02658 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
#include <map>
#include <string>
typedef unsigned long long ll;
const ll inf = 1e18;
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll ans = 1, temp, t;
int flag = 0;
for (int i = 0; i < n; i++) {
cin >> temp;
if (inf / temp < ans)
flag = 1;
else
ans *= temp;
}
if (flag)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | #include <cstdio>
#include <iostream>
#include <map>
#include <string>
typedef unsigned long long ll;
const ll inf = 1e18;
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll ans = 1, temp, t;
int flag = 0;
for (int i = 0; i < n; i++) {
cin >> temp;
if (temp == 0) {
cout << 0 << endl;
return 0;
}
if (inf / temp < ans)
flag = 1;
else
ans *= temp;
}
if (flag)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
} | insert | 17 | 17 | 17 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <iostream>
typedef long long ll;
int main() {
int N;
std::cin >> N;
ll a[N];
for (ll e : a) {
std::cin >> e;
if (e == 0) {
std::cout << 0 << std::endl;
return 0;
}
}
ll max = 1e18;
ll multi = 1;
for (ll e : a) {
if (multi > max / e) {
std::cout << -1 << std::endl;
return 0;
};
multi *= e;
}
if (multi <= max) {
std::cout << multi << std::endl;
}
return 0;
}
| #include <iostream>
typedef long long ll;
int main() {
int N;
std::cin >> N;
ll a[N];
for (ll i; i < N; ++i) {
std::cin >> a[i];
if (a[i] == 0) {
std::cout << 0 << std::endl;
return 0;
}
}
ll max = 1e18;
ll multi = 1;
for (ll e : a) {
if (multi > max / e) {
std::cout << -1 << std::endl;
return 0;
};
multi *= e;
}
if (multi <= max) {
std::cout << multi << std::endl;
}
return 0;
}
| replace | 8 | 11 | 8 | 11 | 0 | |
p02658 | 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;
int main() {
int n;
cin >> n;
ll ans = 1;
rep(i, n) {
ll a;
cin >> a;
if (ans == -1) {
if (a == 0)
ans = 0;
} else {
if (a > 1'000'000'000'000'000'000 / ans) {
ans = -1;
continue;
} else {
ans *= a;
}
}
}
if (ans == -1)
cout << to_string(ans) << endl;
else
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
ll ans = 1;
rep(i, n) {
ll a;
cin >> a;
if (ans == -1) {
if (a == 0)
ans = 0;
} else {
if (a == 0 || ans == 0) {
ans *= a;
continue;
}
if (a > 1'000'000'000'000'000'000 / ans) {
ans = -1;
continue;
} else {
ans *= a;
}
}
}
if (ans == -1)
cout << to_string(ans) << endl;
else
cout << ans << endl;
return 0;
}
| insert | 16 | 16 | 16 | 20 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
ll M = 1e18;
using namespace std;
int main() {
int n;
cin >> n;
vector<ll> a(n);
ll ans = 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (a[0] == 0) {
cout << "0";
return 0;
}
for (int i = 0; i < n + 1; i++) {
if (M / ans < 1) {
cout << "-1";
return 0;
}
if (i != n)
ans *= a[i];
}
cout << ans;
}
| #include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
ll M = 1e18;
using namespace std;
int main() {
int n;
cin >> n;
vector<ll> a(n);
ll ans = 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (a[0] == 0) {
cout << "0";
return 0;
}
for (int i = 0; i < n; i++) {
if (M / ans < 1 or M / ans < a[i]) {
cout << "-1";
return 0;
}
if (i != n)
ans *= a[i];
}
cout << ans;
}
| replace | 29 | 31 | 29 | 31 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int64_t mx = 1e18;
int main() {
int N;
cin >> N;
bool ng = false;
int64_t ans = 1;
for (int i = 0; i < N; i++) {
int64_t A;
cin >> A;
if (A == 0) {
cout << 0 << endl;
return 0;
}
if (mx / ans < A) {
ng = true;
}
ans *= A;
}
if (ng) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int64_t mx = 1e18;
int main() {
int N;
cin >> N;
bool ng = false;
int64_t ans = 1;
for (int i = 0; i < N; i++) {
int64_t A;
cin >> A;
if (A == 0) {
cout << 0 << endl;
return 0;
}
if (ng || mx / ans < A) {
ng = true;
}
ans *= A;
}
if (ng) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
return 0;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main() {
ll N;
cin >> N;
vector<ll> A(N);
ll ans = 1;
for (ll i = 0; i < N; i++) {
cin >> A[i];
if (A[i] == 0) {
ans = 0;
}
}
ll judge = pow(10, 18);
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
for (ll i = 0; i < N; i++) {
if (ans <= judge / A[i]) {
ans *= A[i];
} else {
ans = -1;
break;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main() {
ll N;
cin >> N;
vector<ll> A(N);
ll ans = 1;
for (ll i = 0; i < N; i++) {
cin >> A[i];
if (A[i] == 0) {
ans = 0;
}
}
if (ans == 0) {
cout << 0 << endl;
exit(0);
}
ll judge = pow(10, 18);
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
for (ll i = 0; i < N; i++) {
if (ans <= judge / A[i]) {
ans *= A[i];
} else {
ans = -1;
break;
}
}
cout << ans << endl;
} | insert | 16 | 16 | 16 | 22 | 0 | |
p02658 | C++ | Runtime Error | #include "bits/stdc++.h"
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef unsigned long long ll;
template <typename T> T gcd(T a, T b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct Deep {
ll all;
ll notreef;
ll reef;
};
int main(void) {
int n;
ll ans = 1;
cin >> n;
vector<ll> a(n);
rep(i, n) { cin >> a[i]; }
sort(ALL(a));
rep(i, n) {
if (a[i] > 1000000000000000000 / ans) {
cout << -1;
return 0;
}
ans *= a[i];
}
cout << ans << endl;
}
/*
ans*a[i]>max
a[i]>max/ans
*/
| #include "bits/stdc++.h"
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef unsigned long long ll;
template <typename T> T gcd(T a, T b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct Deep {
ll all;
ll notreef;
ll reef;
};
int main(void) {
int n;
ll ans = 1;
cin >> n;
vector<ll> a(n);
rep(i, n) { cin >> a[i]; }
sort(ALL(a));
if (a[0] == 0) {
cout << 0;
return 0;
}
rep(i, n) {
if (a[i] > 1000000000000000000 / ans) {
cout << -1;
return 0;
}
ans *= a[i];
}
cout << ans << endl;
}
/*
ans*a[i]>max
a[i]>max/ans
*/
| insert | 30 | 30 | 30 | 34 | 0 | |
p02658 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
// problem_B
int main() {
ll n;
cin >> n;
ll a[n];
ll sum1 = 1;
// ll sum2 = 1;
ll ans1 = 0;
ll ans2 = 0;
ll a0 = pow(10, 18);
for (ll i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
ans2 += 1;
}
}
if (ans2 == 0) {
for (ll i = 0; i < n; i++) {
if (a0 / sum1 < a[i]) {
ans1 += 1;
}
sum1 *= a[i];
}
}
// cout << sum1 << endl;
// cout << ans1 << endl;
// cout << ans2 << endl;
if (ans2 != 0) {
cout << 0 << endl;
} else if (ans1 != 0) {
cout << -1 << endl;
} else {
printf("%lld\n", sum1);
}
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
// problem_B
int main() {
ll n;
cin >> n;
ll a[n];
ll sum1 = 1;
// ll sum2 = 1;
ll ans1 = 0;
ll ans2 = 0;
ll a0 = pow(10, 18);
for (ll i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
ans2 += 1;
}
}
if (ans2 == 0) {
for (ll i = 0; i < n; i++) {
if (a0 / sum1 < a[i]) {
ans1 += 1;
break;
}
sum1 *= a[i];
}
}
// cout << sum1 << endl;
// cout << ans1 << endl;
// cout << ans2 << endl;
if (ans2 != 0) {
cout << 0 << endl;
} else if (ans1 != 0) {
cout << -1 << endl;
} else {
printf("%lld\n", sum1);
}
} | insert | 30 | 30 | 30 | 31 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<long long int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
long long int ans = 1;
for (int i = 0; i < n; i++) {
if (a.at(i) == 0) {
cout << 0 << endl;
return 0;
}
if (a.at(i) <= (1000000000000000000 / ans)) {
ans *= a.at(i);
} else {
cout << -1 << endl;
return 0;
}
}
cout << ans << endl << ans / 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<long long int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
long long int ans = 1;
for (int i = 0; i < n; i++) {
if (a.at(i) == 0) {
cout << 0 << endl;
return 0;
}
if (a.at(i) <= (1000000000000000000 / ans)) {
ans *= a.at(i);
} else {
cout << -1 << endl;
return 0;
}
}
cout << ans << endl;
} | replace | 24 | 25 | 24 | 25 | -8 | |
p02658 | C++ | Runtime Error | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2 * acos(0)
#define PI 3.14159265358979323846264338
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T> inline void fastScan(T &x) {
register char c = getchar();
int neg = 0;
x = 0;
for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
;
if (c == '-') {
neg = 1;
c = getchar();
}
for (; c > 47 && c < 58; c = getchar()) {
x = (x << 1) + (x << 3) + c - 48;
}
if (neg)
x = -x;
}
// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T
// >, rb_tree_tag, tree_order_statistics_node_update >;
// typedef uint64_t hash_t;
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// const int HASH_COUNT = 2;
// const hash_t HASH_P = (uint32_t)-13337;
// uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
// const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};
ll limit = 1ll * 1e18;
int main() {
int n;
ll ans = 1;
fastScan(n);
for (int i = 1; i <= n; i++) {
ll x;
fastScan(x);
if (x == 0) {
ans = 0;
continue;
}
if (ans == -1)
continue;
if ((limit / ans) < x) {
ans = -1;
} else {
ans *= x;
}
}
if (ans > limit)
ans = -1;
printf("%lld\n", ans);
}
| #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2 * acos(0)
#define PI 3.14159265358979323846264338
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T> inline void fastScan(T &x) {
register char c = getchar();
int neg = 0;
x = 0;
for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
;
if (c == '-') {
neg = 1;
c = getchar();
}
for (; c > 47 && c < 58; c = getchar()) {
x = (x << 1) + (x << 3) + c - 48;
}
if (neg)
x = -x;
}
// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T
// >, rb_tree_tag, tree_order_statistics_node_update >;
// typedef uint64_t hash_t;
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// const int HASH_COUNT = 2;
// const hash_t HASH_P = (uint32_t)-13337;
// uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
// const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};
ll limit = 1ll * 1e18;
int main() {
int n;
ll ans = 1;
fastScan(n);
for (int i = 1; i <= n; i++) {
ll x;
fastScan(x);
if (x == 0) {
ans = 0;
continue;
}
if (ans == -1 || ans == 0)
continue;
if ((limit / ans) < x) {
ans = -1;
} else {
ans *= x;
}
}
if (ans > limit)
ans = -1;
printf("%lld\n", ans);
}
| replace | 67 | 68 | 67 | 68 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k = 1, a[10001];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
k = 0;
break;
}
if (k > 1000000000000000000 / a[i] || k == -1) {
k = -1;
} else {
k *= a[i];
}
}
cout << k;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k = 1, a[100001];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
k = 0;
break;
}
if (k > 1000000000000000000 / a[i] || k == -1) {
k = -1;
} else {
k *= a[i];
}
}
cout << k;
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long ar[n + 5];
long long res = 1;
for (int i = 0; i < n; i++) {
cin >> ar[i];
if (ar[i] == 0) {
res = 0;
continue;
}
if (ar[i] <= 1000000000000000000 / res)
res *= ar[i];
else {
res = -1;
continue;
}
}
cout << res;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long ar[n + 5];
long long res = 1;
for (int i = 0; i < n; i++) {
cin >> ar[i];
if (ar[i] == 0) {
cout << "0";
return 0;
}
if (ar[i] <= 1000000000000000000 / res)
res *= ar[i];
else {
res = -1;
continue;
}
}
cout << res;
return 0;
} | replace | 11 | 13 | 11 | 13 | 0 | |
p02658 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define K 1000000000000000000
int main() {
long long ans = 1;
int n;
bool flag = false;
cin >> n;
for (int i = 0; i < n; ++i) {
long long b;
cin >> b;
if (b == 0) {
cout << 0 << endl;
return 0;
}
if ((K + 1) / ans < b || ans * b > K) {
flag = true;
}
ans *= b;
}
if (flag) {
cout << -1 << endl;
return 0;
}
cout << ans << endl;
return 0;
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define K 1000000000000000000
int main() {
long long ans = 1;
int n;
bool flag = false;
cin >> n;
for (int i = 0; i < n; ++i) {
long long b;
cin >> b;
if (b == 0) {
cout << 0 << endl;
return 0;
}
if (flag || K / ans < b || ans * b > K) {
flag = true;
}
ans *= b;
}
if (flag) {
cout << -1 << endl;
return 0;
}
cout << ans << endl;
return 0;
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p02658 | Python | Time Limit Exceeded | n = int(input())
n_list = [int(i) for i in input().split()]
ans = 1
n_list.sort()
for i in n_list:
ans *= i
if ans > 10**18:
ans = -1
print(ans)
| n = int(input())
n_list = [int(i) for i in input().split()]
ans = 1
n_list.sort()
n_list = list(reversed(n_list))
if 0 in n_list:
print(0)
else:
for i in n_list:
ans *= i
if ans > 10**18:
ans = -1
break
print(ans)
| replace | 4 | 9 | 4 | 14 | TLE | |
p02658 | Python | Time Limit Exceeded | import sys
n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))
if 0 in list_input:
print(0)
exit()
a = 1
for i in list_input:
a *= i
if a > pow(10, 18):
print(-1)
else:
print(a)
| import sys
n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))
if 0 in list_input:
print(0)
exit()
a = 1
for i in list_input:
a *= i
if a > pow(10, 18):
break
if a > pow(10, 18):
print(-1)
else:
print(a)
| insert | 12 | 12 | 12 | 14 | TLE | |
p02658 | Python | Time Limit Exceeded | from operator import mul
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
ans = reduce(mul, a)
if ans > 10**18:
print(-1)
else:
print(ans)
| from operator import mul
from functools import reduce
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
cnt = 1
if 0 in a:
print(0)
exit()
for i in range(len(a)):
cnt *= a[i]
if cnt > 10**18:
print(-1)
exit()
print(cnt)
| replace | 4 | 10 | 4 | 17 | TLE | |
p02658 | Python | Time Limit Exceeded | N = int(input())
A = list(map(int, input().split()))
if 0 in A:
print(0)
else:
total = 1
for i in range(N):
total *= A[i]
if total > 10**18:
print(-1)
else:
print(total)
| N = int(input())
A = list(map(int, input().split()))
if 0 in A:
print(0)
else:
total = 1
for i in range(N):
total *= A[i]
if total > 10**18:
total = -1
break
print(total)
| replace | 10 | 15 | 10 | 14 | TLE | |
p02658 | Python | Time Limit Exceeded | n = int(input())
A = list(map(int, input().split()))
if 0 in A:
print(0)
else:
out = 1
for a in A:
out *= a
out = -1 if (out > 10**18) else out
print(out)
| n = int(input())
A = list(map(int, input().split()))
if 0 in A:
print(0)
else:
out = 1
for a in A:
out *= a
if out > 10**18:
out = -1
break
print(out)
| replace | 9 | 10 | 9 | 12 | TLE | |
p02658 | Python | Time Limit Exceeded | # B - Multiplication 2
n = int(input())
a = list(map(int, input().split()))
limit = 10**18
for i in range(1, n):
a[i] *= a[i - 1]
if a[i] > limit:
a[i] = -1
print(a[-1])
| # B - Multiplication 2
n = int(input())
a = list(map(int, input().split()))
limit = 10**18
for i in range(1, n):
a[i] = min(a[i] * a[i - 1], limit + 1)
print(a[-1] if a[-1] <= limit else -1)
| replace | 6 | 10 | 6 | 9 | TLE | |
p02658 | Python | Time Limit Exceeded | n = int(input())
res = 1
a = map(int, input().split())
for x in a:
res *= x
if res > 1e18:
res = -1
print(res)
| def solve():
_ = int(input())
a = list(map(int, input().split()))
res = 1
for x in a:
if x == 0:
print(0)
return
for x in a:
res *= x
if res > int(1e18):
print(-1)
return
print(res)
solve()
| replace | 0 | 8 | 0 | 17 | TLE | |
p02658 | Python | Time Limit Exceeded | from collections import Counter
N = input()
A_str = input().split()
if "0" in A_str:
print(0)
exit()
c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
res *= int(i) ** v
if res > 10**18:
res = -1
print(res)
| from collections import Counter
N = input()
A_str = input().split()
if "0" in A_str:
print(0)
exit()
c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
res *= int(i) ** v
if res > 10**18:
res = -1
break
print(res)
| replace | 14 | 16 | 14 | 17 | TLE | |
p02658 | Python | Time Limit Exceeded | N = int(input())
A = sorted(list(map(int, input().split())))
ans = 1
for a in A:
ans *= a
print(-1 if ans > 10**18 else ans)
| N = int(input())
A = sorted(list(map(int, input().split())))
ans = 1
for a in A:
ans *= a
if ans > 10**18:
print(-1)
exit()
print(ans)
| replace | 5 | 6 | 5 | 9 | TLE | |
p02658 | Python | Runtime Error | def main():
_ = input()
lst = list(map(int, input().split()))
ans = 1
if 0 in lst:
print(0)
exit()
for i in map(int, input().split()):
ans *= i
if ans > 10**18:
print(-1)
exit()
print(ans)
if __name__ == "__main__":
main()
| def main():
_ = input()
lst = list(map(int, input().split()))
ans = 1
if 0 in lst:
print(0)
exit()
for i in lst:
ans *= i
if ans > 10**18:
print(-1)
exit()
print(ans)
if __name__ == "__main__":
main()
| replace | 8 | 9 | 8 | 9 | EOFError: EOF when reading a line | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02658/Python/s195636172.py", line 18, in <module>
main()
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02658/Python/s195636172.py", line 9, in main
for i in map(int, input().split()):
EOFError: EOF when reading a line
|
p02658 | Python | Time Limit Exceeded | N = int(input())
an = list(map(int, input().split()))
ans = 1
for a in an:
if 0 in an:
ans = 0
break
ans *= a
if ans > 10**18:
ans = -1
break
print(ans)
| N = int(input())
an = list(map(int, input().split()))
ans = 1
if 0 in an:
ans = 0
else:
for a in an:
ans *= a
if ans > 10**18:
ans = -1
break
print(ans)
| replace | 3 | 11 | 3 | 11 | TLE | |
p02658 | Python | Runtime Error | N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
for a in A:
if a == 0:
zero_flag = 1
result = 0
break
else:
result = result * a
if result > pow(10, 18):
flag = 1
result = 0
if flag == 1 and zero_flag != 1:
print(-1)
else:
print(result)
| N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
zero_flag = 0
for a in A:
if a == 0:
zero_flag = 1
result = 0
break
else:
result = result * a
if result > pow(10, 18):
flag = 1
result = 0
if flag == 1 and zero_flag != 1:
print(-1)
else:
print(result)
| insert | 4 | 4 | 4 | 5 | 0 | |
p02658 | Python | Time Limit Exceeded | import sys
n = int(input())
a = [int(i) for i in input().split()]
tmp = 10**18
if 0 in a:
print(0)
sys.exit()
else:
acc = 1
for i in a:
acc *= i
if len(str(i)) + len(str(acc)) < 19:
pass
elif acc > tmp:
print(-1)
sys.exit()
print(acc)
| import sys
n = int(input())
a = [int(i) for i in input().split()]
tmp = 10**18
if 0 in a:
print(0)
sys.exit()
else:
acc = 1
for i in a:
acc *= i
if acc > tmp:
print(-1)
sys.exit()
print(acc)
| replace | 12 | 17 | 12 | 15 | TLE | |
p02658 | Python | Time Limit Exceeded | n = int(input())
li = list(map(int, input().split()))
x = 1
if 0 in li:
print(0)
else:
for i in li:
x = x * i
if x > 10**18:
print(-1)
else:
print(x)
| n = int(input())
li = list(map(int, input().split()))
x = 1
if 0 in li:
print(0)
else:
for i in li:
x = x * i
if x > 10**18:
print(-1)
exit()
print(x)
| replace | 8 | 12 | 8 | 12 | TLE | |
p02658 | Python | Time Limit Exceeded | n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
print(0)
exit()
for i in range(n):
ans *= a[i]
if ans > 10**18:
ans = "-1"
print(ans)
| n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
print(0)
exit()
for i in range(n):
ans *= a[i]
if ans > 10**18:
print(-1)
exit()
print(ans)
| replace | 8 | 10 | 8 | 11 | TLE | |
p02658 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long llong;
const llong N = 1e18;
int main() {
int n;
llong a = 1, b, c;
scanf("%d", &n);
while (n--) {
scanf("%lld", &b);
c = N / b;
if (a > c) {
a = -1;
}
a = a * b;
}
a = a < 0 ? -1 : a;
cout << a;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long llong;
const llong N = 1e18;
int main() {
int n;
llong a = 1, b, c;
scanf("%d", &n);
while (n--) {
scanf("%lld", &b);
if (b == 0) {
a = 0;
break;
}
c = N / a;
if (b > c) {
a = -1;
}
a = a * b;
}
a = a < 0 ? -1 : a;
cout << a;
return 0;
}
| replace | 10 | 12 | 10 | 16 | 0 | |
p02658 | Python | Time Limit Exceeded | n = int(input())
a = list(map(int, input().split()))
a.sort()
judge = True
ans = 1
for i in a:
ans *= i
if ans > 1000000000000000000:
judge = False
if judge:
print(ans)
else:
print(-1)
| n = int(input())
a = list(map(int, input().split()))
a.sort()
judge = True
ans = 1
for i in a:
ans *= i
if ans > 1000000000000000000:
judge = False
break
if judge:
print(ans)
else:
print(-1)
| insert | 9 | 9 | 9 | 10 | TLE | |
p02658 | Python | Time Limit Exceeded | N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
print(0)
else:
for a in A:
ans *= a
if ans > 10**18:
ans = -1
print(ans)
| N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
print(0)
else:
for a in A:
ans *= a
if ans > 10**18:
ans = -1
break
print(ans)
| insert | 10 | 10 | 10 | 11 | TLE | |
p02658 | Python | Time Limit Exceeded | n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
ans *= i
print(ans if not ans > 10**18 else -1)
| n = int(input())
a = list(map(int, input().split()))
if 0 in a:
print(0)
else:
ans = 1
for i in a:
ans *= i
if ans > 10**18:
ans = -1
break
print(ans)
| replace | 2 | 6 | 2 | 12 | TLE | |
p02658 | Python | Time Limit Exceeded | import sys
input = sys.stdin.readline
"""
"""
tot = 1
n = int(input())
arr = map(int, input().split())
for v in arr:
tot *= v
if tot > 10**18:
print(-1)
else:
print(tot)
| import sys
input = sys.stdin.readline
"""
"""
tot = 1
n = int(input())
arr = map(int, input().split())
for v in arr:
if v == 0:
tot = 0
break
if tot <= 10**18:
tot *= v
if tot > 10**18:
print(-1)
else:
print(tot)
| replace | 13 | 14 | 13 | 19 | TLE | |
p02658 | Python | Time Limit Exceeded | import sys
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
print(0)
sys.exit()
for i in range(N):
ans *= A[i]
if ans > 10**18:
ans = -1
print(ans)
| import sys
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
print(0)
sys.exit()
for i in range(N):
ans *= A[i]
if ans > 10**18:
ans = -1
break
print(ans)
| insert | 15 | 15 | 15 | 16 | TLE | |
p02658 | Python | Runtime Error | n = int(input())
arr = list(map(int, input().split()))
while len(arr) > 1:
m = len(arr)
if m & 1:
arr.append(1)
m += 1
left, right = arr[: n // 2], arr[n // 2 :]
arr = [x * y for x, y in zip(left, right)]
x = arr[0]
if x > 10**18:
print(-1)
else:
print(x)
| n = int(input())
arr = list(map(int, input().split()))
while len(arr) > 1:
m = len(arr)
if m & 1:
arr.append(1)
m += 1
left, right = arr[: m // 2], arr[m // 2 :]
arr = [x * y for x, y in zip(left, right)]
x = arr[0]
if x > 10**18:
print(-1)
else:
print(x)
| replace | 9 | 10 | 9 | 10 | 0 | |
p02658 | Python | Time Limit Exceeded | n = int(input())
a = list(map(int, input().split()))
m = 1
if 0 in a:
m = 0
else:
for i in a:
m *= i
if m > 10**18:
m = -1
print(m)
| n = int(input())
a = list(map(int, input().split()))
m = 1
if 0 in a:
m = 0
else:
for i in a:
m *= i
if m > 10**18:
m = -1
break
print(m)
| insert | 10 | 10 | 10 | 11 | TLE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.