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
p02619
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = (0); i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define show(x) cout << #x << " = " << (x) << endl #define show2(x, y) \ cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl #define show3(x, y, z) \ cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z \ << " = " << (z) << endl #define showv(v) \ rep(i, v.size()) printf("%d%c", v[i], i == v.size() - 1 ? '\n' : ' ') #define showv2(v) rep(j, v.size()) showv(v[j]) #define showt(t, n) rep(i, n) printf("%d%c", t[i], i == n - 1 ? '\n' : ' ') #define showt2(t, r, c) rep(j, r) showt(t[j], c) #define showvp(p) rep(i, p.size()) printf("%d %d\n", p[i].first, p[i].second) #define printv(v) rep(i, v.size()) printf("%d\n", v[i]) #define printt(t, n) rep(i, n) printf("%d\n", t[i]) #define incl(v, x) (find(all(v), x) != v.end()) #define incls(s, c) (s.find(c) != string::npos) #define lb(a, x) distance((a).begin(), lower_bound(all(a), (x))) #define ub(a, x) distance((a).begin(), upper_bound(all(a), (x))) #define fi first #define se second #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define bit(n, k) ((n >> k) & 1) // nのk bit目 #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define uni(x) x.erase(unique(all(x)), x.end()) #define SP << " " << using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>; using vb = vector<bool>; using vvb = vector<vb>; using P = pair<int, int>; using T = tuple<int, int, int>; using vp = vector<P>; using vt = vector<T>; const int mod = 1000000007; const double EPS = 1e-9; // const long double EPS = 1e-14; const int INF = (1 << 30) - 1; const ll LINF = (1LL << 62) - 1; #define dame \ { \ puts("No"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } inline int in() { int x; cin >> x; return x; } inline ll lin() { ll x; cin >> x; return x; } inline char chin() { char x; cin >> x; return x; } inline string stin() { string x; cin >> x; return x; } inline double din() { double x; cin >> x; return x; } // template<class T = int> inline T in() { T x; cin >> x; return (x);} template <typename T> inline ll suma(const vector<T> &a) { ll res(0); for (auto &&x : a) res += x; return res; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } char itoa(int n) { return n + '0'; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { int d; cin >> d; vi c(26 + 1); rrep(i, 26) cin >> c[i]; vvi s(d + 1, vi(26 + 1)); rrep(i, d) rrep(j, 26) cin >> s[i][j]; vi t(d + 1); rrep(i, d) { cin >> t[i]; } vi last(26); vi v(d + 1); rrep(i, d) { v[i] = v[i - 1] + s[i][t[i]]; last[t[i]] = i; rrep(j, 26) { v[i] -= c[j] * (i - last[j]); } printf("%d\n", v[i]); } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = (0); i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define show(x) cout << #x << " = " << (x) << endl #define show2(x, y) \ cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl #define show3(x, y, z) \ cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z \ << " = " << (z) << endl #define showv(v) \ rep(i, v.size()) printf("%d%c", v[i], i == v.size() - 1 ? '\n' : ' ') #define showv2(v) rep(j, v.size()) showv(v[j]) #define showt(t, n) rep(i, n) printf("%d%c", t[i], i == n - 1 ? '\n' : ' ') #define showt2(t, r, c) rep(j, r) showt(t[j], c) #define showvp(p) rep(i, p.size()) printf("%d %d\n", p[i].first, p[i].second) #define printv(v) rep(i, v.size()) printf("%d\n", v[i]) #define printt(t, n) rep(i, n) printf("%d\n", t[i]) #define incl(v, x) (find(all(v), x) != v.end()) #define incls(s, c) (s.find(c) != string::npos) #define lb(a, x) distance((a).begin(), lower_bound(all(a), (x))) #define ub(a, x) distance((a).begin(), upper_bound(all(a), (x))) #define fi first #define se second #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define bit(n, k) ((n >> k) & 1) // nのk bit目 #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define uni(x) x.erase(unique(all(x)), x.end()) #define SP << " " << using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>; using vb = vector<bool>; using vvb = vector<vb>; using P = pair<int, int>; using T = tuple<int, int, int>; using vp = vector<P>; using vt = vector<T>; const int mod = 1000000007; const double EPS = 1e-9; // const long double EPS = 1e-14; const int INF = (1 << 30) - 1; const ll LINF = (1LL << 62) - 1; #define dame \ { \ puts("No"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } inline int in() { int x; cin >> x; return x; } inline ll lin() { ll x; cin >> x; return x; } inline char chin() { char x; cin >> x; return x; } inline string stin() { string x; cin >> x; return x; } inline double din() { double x; cin >> x; return x; } // template<class T = int> inline T in() { T x; cin >> x; return (x);} template <typename T> inline ll suma(const vector<T> &a) { ll res(0); for (auto &&x : a) res += x; return res; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } char itoa(int n) { return n + '0'; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { int d; cin >> d; vi c(26 + 1); rrep(i, 26) cin >> c[i]; vvi s(d + 1, vi(26 + 1)); rrep(i, d) rrep(j, 26) cin >> s[i][j]; vi t(d + 1); rrep(i, d) { cin >> t[i]; } vi last(26 + 1); vi v(d + 1); rrep(i, d) { v[i] = v[i - 1] + s[i][t[i]]; last[t[i]] = i; rrep(j, 26) { v[i] -= c[j] * (i - last[j]); } printf("%d\n", v[i]); } return 0; }
replace
133
134
133
134
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) typedef long long ll; long long mod = 1e9 + 7; const int iINF = 0x3f3f3f3f; const long long INF = 1LL << 60; using namespace std; using pint = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int d; cin >> d; int c[30], last[30], s[30][30], v = 0; rep(i, 26) cin >> c[i]; rep(i, d) rep(j, 26) cin >> s[i][j]; rep(i, 26) last[i] = 0; rep(i, d) { int t; cin >> t; t--; v += s[i][t]; last[t] = i + 1; rep(j, 26) { if (j == t) continue; v -= c[j] * (i + 1 - last[j]); } cout << v << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) typedef long long ll; long long mod = 1e9 + 7; const int iINF = 0x3f3f3f3f; const long long INF = 1LL << 60; using namespace std; using pint = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int d; cin >> d; int c[30] = {}, last[30] = {}, s[400][30] = {}, v = 0; rep(i, 26) cin >> c[i]; rep(i, d) rep(j, 26) cin >> s[i][j]; rep(i, 26) last[i] = 0; rep(i, d) { int t; cin >> t; t--; v += s[i][t]; last[t] = i + 1; rep(j, 26) { if (j == t) continue; v -= c[j] * (i + 1 - last[j]); } cout << v << endl; } return 0; }
replace
29
30
29
30
0
p02619
C++
Runtime Error
#pragma GCC optimize("O3") // #pragma GCC target ("avx") #include <algorithm> #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) \ do { \ } while (0) #endif #include <cassert> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define EACH(i, c) \ for (__typeof((c).begin()) i = (c).begin(), i##_end = (c).end(); \ i != i##_end; ++i) template <class T> inline void amin(T &x, const T &y) { if (y < x) x = y; } template <class T> inline void amax(T &x, const T &y) { if (x < y) x = y; } template <class Iter> void rprintf(const char *fmt, Iter begin, Iter end) { for (bool sp = 0; begin != end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); } putchar('\n'); } int D; int C[26]; int S[356][26]; int T[356]; int last[26]; int calc() { int cur = 0; REP(c, 26) last[c] = -1; REP(i, D) { int t = T[i]; last[t] = i; cur += S[i][t]; REP(c, 26) cur -= C[c] * (i - last[c]); printf("%d\n", cur); } return cur; } void MAIN() { scanf("%d", &D); REP(c, 26) scanf("%d", C + c); REP(i, D) REP(c, 26) scanf("%d", S[i] + c); REP(i, D) scanf("%d", T + i), T[i]--; calc(); } int main() { int TC = 1; // scanf("%d", &TC); REP(tc, TC) MAIN(); return 0; }
#pragma GCC optimize("O3") // #pragma GCC target ("avx") #include <algorithm> #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define NDEBUG #define eprintf(...) \ do { \ } while (0) #endif #include <cassert> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define EACH(i, c) \ for (__typeof((c).begin()) i = (c).begin(), i##_end = (c).end(); \ i != i##_end; ++i) template <class T> inline void amin(T &x, const T &y) { if (y < x) x = y; } template <class T> inline void amax(T &x, const T &y) { if (x < y) x = y; } template <class Iter> void rprintf(const char *fmt, Iter begin, Iter end) { for (bool sp = 0; begin != end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); } putchar('\n'); } int D; int C[26]; int S[365][26]; int T[365]; int last[26]; int calc() { int cur = 0; REP(c, 26) last[c] = -1; REP(i, D) { int t = T[i]; last[t] = i; cur += S[i][t]; REP(c, 26) cur -= C[c] * (i - last[c]); printf("%d\n", cur); } return cur; } void MAIN() { scanf("%d", &D); REP(c, 26) scanf("%d", C + c); REP(i, D) REP(c, 26) scanf("%d", S[i] + c); REP(i, D) scanf("%d", T + i), T[i]--; calc(); } int main() { int TC = 1; // scanf("%d", &TC); REP(tc, TC) MAIN(); return 0; }
replace
50
52
50
52
0
p02619
C++
Runtime Error
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define N (1000000000 + 7) #define M 998244353 #define INF 1e16 typedef long long ll; typedef pair<ll, ll> P; ll A(ll x) { if (x >= 0) return x; else return -x; } ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a % b == 0) return b; else return gcd(b, a % b); } ll c[27]; ll s[27][27]; ll last[27]; ll score[27]; int main(void) { int D; cin >> D; for (int i = 1; i <= 26; i++) cin >> c[i]; for (int i = 1; i <= D; i++) { for (int j = 1; j <= 26; j++) { cin >> s[i][j]; } } for (ll d = 1; d <= D; d++) { ll t; cin >> t; last[t] = d; score[t] += s[d][t]; ll ans = 0; for (ll j = 1; j <= 26; j++) { score[j] -= c[j] * (d - last[j]); ans += score[j]; } cout << ans << endl; } return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define N (1000000000 + 7) #define M 998244353 #define INF 1e16 typedef long long ll; typedef pair<ll, ll> P; ll A(ll x) { if (x >= 0) return x; else return -x; } ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a % b == 0) return b; else return gcd(b, a % b); } ll c[27]; ll s[400][27]; ll last[27]; ll score[27]; int main(void) { int D; cin >> D; for (int i = 1; i <= 26; i++) cin >> c[i]; for (int i = 1; i <= D; i++) { for (int j = 1; j <= 26; j++) { cin >> s[i][j]; } } for (ll d = 1; d <= D; d++) { ll t; cin >> t; last[t] = d; score[t] += s[d][t]; ll ans = 0; for (ll j = 1; j <= 26; j++) { score[j] -= c[j] * (d - last[j]); ans += score[j]; } cout << ans << endl; } return 0; }
replace
38
39
38
39
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++) #define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--) #define sort_vec(v) sort((v).begin(), (v).end()) typedef int64_t lint; // lint mod = 998244353; // lint mod = 1000000007; template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } void app() { int d; cin >> d; int n = 26; vector<int> c(n); rep(j, n) { cin >> c[j]; } vector<vector<int>> s(d, vector<int>(n)); rep(i, d) rep(j, n) cin >> s[i][j]; vector<int> t(n); rep(i, d) { cin >> t[i]; t[i]--; } lint score = 0; vector<int> lastd(n, -1); rep(i, d) { int j = t[i]; lastd[j] = i; score += s[i][j]; rep(j, n) score -= c[j] * (i - lastd[j]); cout << score << endl; } } int main() { app(); return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++) #define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--) #define sort_vec(v) sort((v).begin(), (v).end()) typedef int64_t lint; // lint mod = 998244353; // lint mod = 1000000007; template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } void app() { int d; cin >> d; int n = 26; vector<int> c(n); rep(j, n) { cin >> c[j]; } vector<vector<int>> s(d, vector<int>(n)); rep(i, d) rep(j, n) cin >> s[i][j]; vector<int> t(d); rep(i, d) { cin >> t[i]; t[i]--; } lint score = 0; vector<int> lastd(n, -1); rep(i, d) { int j = t[i]; lastd[j] = i; score += s[i][j]; rep(j, n) score -= c[j] * (i - lastd[j]); cout << score << endl; } } int main() { app(); return 0; }
replace
26
27
26
27
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io; template <class T, class U> bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } constexpr size_t D = 5; constexpr size_t type = 26; constexpr int INF = (1 << 30); array<int, type> c, last; array<array<int, type>, D> s; array<int, D> contest; void input() { int buff; cin >> buff; for (int i = 0; i < type; i++) { cin >> c[i]; last[i] = 0; } for (int i = 0; i < D; i++) { for (int j = 0; j < type; j++) { cin >> s[i][j]; } } for (int i = 0; i < D; i++) { cin >> contest[i]; contest[i]--; } } int score(int day, int idx) { int ans = s[day][idx]; for (int i = 0; i < type; i++) { ans -= c[i] * (day + 1 - last[i]); } return ans; } int main() { input(); int ans = 0; for (int i = 0; i < D; i++) { const int &id = contest[i]; last[id] = i + 1; ans += score(i, id); cout << ans << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io; template <class T, class U> bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } constexpr size_t D = 365; constexpr size_t type = 26; constexpr int INF = (1 << 30); array<int, type> c, last; array<array<int, type>, D> s; array<int, D> contest; void input() { int buff; cin >> buff; for (int i = 0; i < type; i++) { cin >> c[i]; last[i] = 0; } for (int i = 0; i < D; i++) { for (int j = 0; j < type; j++) { cin >> s[i][j]; } } for (int i = 0; i < D; i++) { cin >> contest[i]; contest[i]--; } } int score(int day, int idx) { int ans = s[day][idx]; for (int i = 0; i < type; i++) { ans -= c[i] * (day + 1 - last[i]); } return ans; } int main() { input(); int ans = 0; for (int i = 0; i < D; i++) { const int &id = contest[i]; last[id] = i + 1; ans += score(i, id); cout << ans << '\n'; } return 0; }
replace
23
24
23
24
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; constexpr double ticks_per_sec = 2800000000; constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec; inline double rdtsc() { // in seconds uint32_t lo, hi; asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv; } constexpr double TLE = 3; // sec constexpr double time_limit = TLE * 0.98; unsigned int randxor() { static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned int t; t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } template <typename hoge> void my_shuffle(vector<hoge> &v) { int sz = v.size(); for (int i = sz - 1; i >= 1; i--) { swap(v[i], v[randxor() % (i + 1)]); } } // 定数 constexpr int CONTEST_NUM = 26; // 入力 constexpr int D = 5; array<int, CONTEST_NUM> c; array<array<int, CONTEST_NUM>, D> s; ll calcScore(const array<int, D> &t) { ll score = 0; array<int, CONTEST_NUM> lasts{}; for (int i = 0; i < D; i++) { lasts[t[i]] = i + 1; score += s[i][t[i]]; for (int j = 0; j < CONTEST_NUM; j++) { score -= c[j] * (i + 1 - lasts[j]); } cout << score << newl; } return score; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); { int dummy; cin >> dummy; for (int i = 0; i < CONTEST_NUM; i++) { cin >> c[i]; } for (int i = 0; i < D; i++) { for (int j = 0; j < CONTEST_NUM; j++) { cin >> s[i][j]; } } } array<int, D> t; for (int i = 0; i < D; i++) { cin >> t[i]; --t[i]; } calcScore(t); // cout << calcScore(t) << newl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; constexpr double ticks_per_sec = 2800000000; constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec; inline double rdtsc() { // in seconds uint32_t lo, hi; asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv; } constexpr double TLE = 3; // sec constexpr double time_limit = TLE * 0.98; unsigned int randxor() { static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned int t; t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } template <typename hoge> void my_shuffle(vector<hoge> &v) { int sz = v.size(); for (int i = sz - 1; i >= 1; i--) { swap(v[i], v[randxor() % (i + 1)]); } } // 定数 constexpr int CONTEST_NUM = 26; // 入力 constexpr int D = 365; array<int, CONTEST_NUM> c; array<array<int, CONTEST_NUM>, D> s; ll calcScore(const array<int, D> &t) { ll score = 0; array<int, CONTEST_NUM> lasts{}; for (int i = 0; i < D; i++) { lasts[t[i]] = i + 1; score += s[i][t[i]]; for (int j = 0; j < CONTEST_NUM; j++) { score -= c[j] * (i + 1 - lasts[j]); } cout << score << newl; } return score; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); { int dummy; cin >> dummy; for (int i = 0; i < CONTEST_NUM; i++) { cin >> c[i]; } for (int i = 0; i < D; i++) { for (int j = 0; j < CONTEST_NUM; j++) { cin >> s[i][j]; } } } array<int, D> t; for (int i = 0; i < D; i++) { cin >> t[i]; --t[i]; } calcScore(t); // cout << calcScore(t) << newl; return 0; }
replace
39
40
39
40
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif constexpr int n = 365, m = 26; int c[m], s[n][m]; int type[n]; int score(int lim = n) { static int last[m]; fill(begin(last), end(last), -1); int res = 0; for (int i = 0; i < lim; ++i) { res += s[i][type[i]]; last[type[i]] = i; for (int j = 0; j < m; ++j) { res -= c[j] * (i - last[j]); } } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin.ignore(); for (int j = 0; j < m; ++j) { cin >> c[j]; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> s[i][j]; } } for (int i = 0; i < n; ++i) { // cout << type[i] + 1 << '\n'; cin >> type[i]; --type[i]; } for (int i = 0; i < n; ++i) { cout << score(i + 1) << '\n'; } }
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif constexpr int n = 365, m = 26; int c[m], s[n][m]; int type[n]; int score(int lim = n) { static int last[m]; fill(begin(last), end(last), -1); int res = 0; for (int i = 0; i < lim; ++i) { res += s[i][type[i]]; last[type[i]] = i; for (int j = 0; j < m; ++j) { res -= c[j] * (i - last[j]); } } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); // cin.ignore(); int _n; cin >> _n; assert(_n == n); for (int j = 0; j < m; ++j) { cin >> c[j]; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> s[i][j]; } } for (int i = 0; i < n; ++i) { // cout << type[i] + 1 << '\n'; cin >> type[i]; --type[i]; } for (int i = 0; i < n; ++i) { cout << score(i + 1) << '\n'; } }
replace
30
31
30
34
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; constexpr int N = 26; constexpr int D = 365; signed main() { int tt; cin >> tt; int c[N]; rep(i, N) { cin >> c[i]; } int s[D][N]; rep(i, D) { rep(j, N) { cin >> s[i][j]; } } int t[D]; rep(i, D) { cin >> t[i]; t[i]--; } int last[N]; fill(last, last + N, -1); int ans = 0; rep(i, D) { last[i] = t[i]; ans += s[i][t[i]]; rep(j, N) { ans -= c[j] * (i - last[j]); } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; constexpr int N = 26; constexpr int D = 365; signed main() { int tt; cin >> tt; int c[N]; rep(i, N) { cin >> c[i]; } int s[D][N]; rep(i, D) { rep(j, N) { cin >> s[i][j]; } } int t[D]; rep(i, D) { cin >> t[i]; t[i]--; } int last[N]; fill(last, last + N, -1); int ans = 0; rep(i, D) { last[t[i]] = i; ans += s[i][t[i]]; rep(j, N) { ans -= c[j] * (i - last[j]); } cout << ans << endl; } return 0; }
replace
30
31
30
31
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define N_CONTEST (26) #define N_DAY (5) static void get_input(int &D, vector<int> &c, vector<vector<int>> &s) { cin >> D; assert(D == N_DAY); for (int i = 1; i <= N_CONTEST; i++) { cin >> c.at(i); } for (int i = 1; i <= N_DAY; i++) { for (int j = 1; j <= N_CONTEST; j++) { cin >> s.at(i).at(j); } } } static long long calc_score(vector<int> &c, vector<vector<int>> &s, vector<int> &t) { vector<int> last(N_CONTEST + 1, 0); long long score = 0; for (int d = 1; d <= N_DAY; d++) { score += s.at(d).at(t.at(d)); last.at(t.at(d)) = d; for (int con = 1; con <= N_CONTEST; con++) { score -= c.at(con) * (d - last.at(con)); } cout << score << endl; } return score; } int main(void) { int D; vector<int> c(N_CONTEST + 1); vector<vector<int>> s(N_DAY + 1, vector<int>(N_CONTEST + 1, 0)); get_input(D, c, s); // for ( int i = 0; i < N_DAY; i++ ) { // cout << i % 26 + 1 << endl; // } vector<int> t(N_DAY + 1, 0); for (int i = 1; i <= N_DAY; i++) { cin >> t.at(i); } calc_score(c, s, t); return 0; }
#include <bits/stdc++.h> using namespace std; #define N_CONTEST (26) #define N_DAY (365) static void get_input(int &D, vector<int> &c, vector<vector<int>> &s) { cin >> D; assert(D == N_DAY); for (int i = 1; i <= N_CONTEST; i++) { cin >> c.at(i); } for (int i = 1; i <= N_DAY; i++) { for (int j = 1; j <= N_CONTEST; j++) { cin >> s.at(i).at(j); } } } static long long calc_score(vector<int> &c, vector<vector<int>> &s, vector<int> &t) { vector<int> last(N_CONTEST + 1, 0); long long score = 0; for (int d = 1; d <= N_DAY; d++) { score += s.at(d).at(t.at(d)); last.at(t.at(d)) = d; for (int con = 1; con <= N_CONTEST; con++) { score -= c.at(con) * (d - last.at(con)); } cout << score << endl; } return score; } int main(void) { int D; vector<int> c(N_CONTEST + 1); vector<vector<int>> s(N_DAY + 1, vector<int>(N_CONTEST + 1, 0)); get_input(D, c, s); // for ( int i = 0; i < N_DAY; i++ ) { // cout << i % 26 + 1 << endl; // } vector<int> t(N_DAY + 1, 0); for (int i = 1; i <= N_DAY; i++) { cin >> t.at(i); } calc_score(c, s, t); return 0; }
replace
5
6
5
6
0
p02619
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; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int D; vector<int> c(26 + 1); vector<vector<int>> s; int compute_score(vector<int> t) { vector<vector<int>> last(D + 1, vector<int>(26 + 1, 0)); int ans = 0; for (int d = 1; d <= D; d++) { last[d][t[d]] = d; ans += s[d][t[d]]; for (int i = 1; i <= 26; i++) { if (i == t[d]) continue; last[d][i] = last[d - 1][i]; ans -= c[i] * (d - last[d][i]); } cout << ans << endl; } } int main() { ios::sync_with_stdio(false); cin >> D; s.assign(D + 1, vector<int>(26 + 1, 0)); for (int i = 1; i <= 26; i++) cin >> c[i]; for (int d = 1; d <= D; d++) for (int i = 1; i <= 26; i++) cin >> s[d][i]; vector<int> t(D + 1); for (int d = 1; d <= D; d++) cin >> t[d]; compute_score(t); }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int D; vector<int> c(26 + 1); vector<vector<int>> s; int compute_score(vector<int> t) { vector<vector<int>> last(D + 1, vector<int>(26 + 1, 0)); int ans = 0; for (int d = 1; d <= D; d++) { last[d][t[d]] = d; ans += s[d][t[d]]; for (int i = 1; i <= 26; i++) { if (i == t[d]) continue; last[d][i] = last[d - 1][i]; ans -= c[i] * (d - last[d][i]); } cout << ans << endl; } return 0; } int main() { ios::sync_with_stdio(false); cin >> D; s.assign(D + 1, vector<int>(26 + 1, 0)); for (int i = 1; i <= 26; i++) cin >> c[i]; for (int d = 1; d <= D; d++) for (int i = 1; i <= 26; i++) cin >> s[d][i]; vector<int> t(D + 1); for (int d = 1; d <= D; d++) cin >> t[d]; compute_score(t); }
insert
37
37
37
38
0
p02619
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int D; cin >> D; vector<int> c(26); for (int i = 0; i < 26; i++) cin >> c.at(i); vector<vector<int>> s(D, vector<int>(26)); for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) { cin >> s.at(i).at(j); } } int ns = 0; vector<int> last(26, 0); for (int i = 0; i < D; i++) { int t; cin >> t; ns += s.at(i).at(t - 1) - c.at(i); // last.at(t-1) = i + 1; // for (int j = 0; j < 26; j++) { // ns -= c.at(i) * (i + 1 - last.at(j)); // } cout << ns << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int D; cin >> D; vector<int> c(26); for (int i = 0; i < 26; i++) cin >> c.at(i); vector<vector<int>> s(D, vector<int>(26)); for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) { cin >> s.at(i).at(j); } } int ns = 0; vector<int> last(26, 0); for (int i = 0; i < D; i++) { int t; cin >> t; ns += s.at(i).at(t - 1); last.at(t - 1) = i + 1; for (int j = 0; j < 26; j++) { ns -= c.at(j) * (i + 1 - last.at(j)); } cout << ns << endl; } }
replace
21
26
21
27
0
p02619
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define BIL ((ll)1e9) #define MOD ((ll)1e9 + 7) #define INF (1LL << 62) // 1LL<<63でオーバーフロー int main(int argc, char *argv[]) { int d; cin >> d; // d=365 const int contest = 26; vector<int> c(contest); for (auto &x : c) cin >> x; vector<vector<int>> s(d, vector<int>(contest, 0)); for (int i = 0; i < d; i++) { for (int j = 0; j < contest; j++) cin >> s.at(i).at(j); } vector<int> t(contest); for (auto &x : t) cin >> x; vector<int> last(contest + 1, 0), satisfaction(d + 1); satisfaction.at(0) = 0; for (int i = 1; i < d + 1; i++) { int dissatis = 0; int act = t.at(i - 1); last.at(act) = i; for (int j = 0; j < contest; j++) { dissatis += c.at(j) * (i - last.at(j + 1)); } satisfaction.at(i) = satisfaction.at(i - 1) + s.at(i - 1).at(act - 1) - dissatis; cout << satisfaction.at(i) << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define BIL ((ll)1e9) #define MOD ((ll)1e9 + 7) #define INF (1LL << 62) // 1LL<<63でオーバーフロー int main(int argc, char *argv[]) { int d; cin >> d; // d=365 const int contest = 26; vector<int> c(contest); for (auto &x : c) cin >> x; vector<vector<int>> s(d, vector<int>(contest, 0)); for (int i = 0; i < d; i++) { for (int j = 0; j < contest; j++) cin >> s.at(i).at(j); } vector<int> t(d); for (auto &x : t) cin >> x; vector<int> last(contest + 1, 0), satisfaction(d + 1); satisfaction.at(0) = 0; for (int i = 1; i < d + 1; i++) { int dissatis = 0; int act = t.at(i - 1); last.at(act) = i; for (int j = 0; j < contest; j++) { dissatis += c.at(j) * (i - last.at(j + 1)); } satisfaction.at(i) = satisfaction.at(i - 1) + s.at(i - 1).at(act - 1) - dissatis; cout << satisfaction.at(i) << endl; } return 0; }
replace
40
41
40
41
0
p02619
C++
Runtime Error
/*/ Author: kal013 /*/ /*/ Author: kal013 /*/ // #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <class key, class value, class cmp = std::less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order(k) returns iterator to kth element starting from 0; // order_of_key(k) returns count of elements strictly smaller than k; struct custom_hash { // Credits: https://codeforces.com/blog/entry/62393 static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "[ "; for (auto v : V) os << v << " "; return os << "]"; } template <class T> ostream &operator<<(ostream &os, set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, unordered_set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, multiset<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, ordered_set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { return os << "(" << P.first << "," << P.second << ")"; } template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } template <class L, class R> ostream &operator<<(ostream &os, unordered_map<L, R> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } template <class L, class R, class chash = std::hash<R>> ostream &operator<<(ostream &os, gp_hash_table<L, R, chash> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) 1 #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); inline int64_t random_long(long long l, long long r) { uniform_int_distribution<int64_t> generator(l, r); return generator(rng); } inline int64_t random_long() { uniform_int_distribution<int64_t> generator(LLONG_MIN, LLONG_MAX); return generator(rng); } /*/---------------------------Defines----------------------/*/ typedef vector<int> vi; typedef pair<int, int> pii; #define ll long long #define F first #define S second #define pb push_back #define endl "\n" #define all(v) (v).begin(), (v).end() /*/-----------------------Modular Arithmetic---------------/*/ const int mod = 1e9 + 7; inline int add(int x, int y) { x += y; if (x >= mod) return x - mod; return x; } inline int sub(int x, int y) { x -= y; if (x < 0) return x + mod; return x; } inline int mul(int x, int y) { return (x * 1ll * y) % mod; } inline int power(int x, int y) { int ans = 1; while (y) { if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } inline int inv(int x) { return power(x, mod - 2); } /*/-----------------------------Code begins----------------------------------/*/ struct contest_scheduling { int D; int c[26]; int satisfaction; vector<int> s[26]; set<int> last_occur[26]; friend istream &operator>>(istream &is, contest_scheduling &p) { is >> p.D; for (int i = 0; i < 26; ++i) { p.s[i].resize(p.D, 0); is >> p.c[i]; } for (int i = 0; i < p.D; ++i) { for (int j = 0; j < 26; ++j) { is >> p.s[j][i]; } } return is; } void calculate_whole(vector<int> t) { assert(t.size() == D); for (int i = 0; i < 26; ++i) { last_occur[i].clear(); last_occur[i].insert(-1); } satisfaction = 0; for (int i = 0; i < D; ++i) { int type = t[i] - 1; satisfaction += s[i][type]; last_occur[type].insert(i); for (int j = 0; j < 26; ++j) { satisfaction -= c[j] * (i - (*last_occur[j].rbegin())); } cout << satisfaction << endl; } } }; void solve() { contest_scheduling U; cin >> U; int D = U.D; // cin>>D; // vector<int> c(26); // int sum_c = 0; // int satisfaction = 0; // for(int i = 0 ; i < 26 ; ++i){ // cin >> c[i]; // sum_c += c[i]; // } // vector<vector<int> > s(D,vector<int> (26)); // vector<int> last_occur(26,-1); // for(int i = 0 ; i < D ; ++i){ // for(int j = 0 ; j < 26 ; ++j){ // cin >> s[i][j]; // } // } vector<int> t(D); for (int i = 0; i < D; ++i) cin >> t[i]; U.calculate_whole(t); // for(int i = 0 ; i < D ; ++i){ // --t[i]; // satisfaction += s[i][t[i]]; // last_occur[t[i]] = i; // for(int j = 0; j < 26 ; ++j){ // satisfaction -= c[j] * (i - last_occur[j]); // } // } } int main() { // Use "set_name".max_load_factor(0.25);"set_name".reserve(512); with // unordered set Or use gp_hash_table<X,null_type> ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed << setprecision(25); cerr << fixed << setprecision(10); auto start = std::chrono::high_resolution_clock::now(); int t = 1; // cin>>t; while (t--) { solve(); } auto stop = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); // cerr << "Time taken : " << ((long double)duration.count())/((long double) // 1e9) <<"s "<< endl; }
/*/ Author: kal013 /*/ /*/ Author: kal013 /*/ // #pragma GCC optimize ("O3") #include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <class key, class value, class cmp = std::less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order(k) returns iterator to kth element starting from 0; // order_of_key(k) returns count of elements strictly smaller than k; struct custom_hash { // Credits: https://codeforces.com/blog/entry/62393 static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "[ "; for (auto v : V) os << v << " "; return os << "]"; } template <class T> ostream &operator<<(ostream &os, set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, unordered_set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, multiset<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class T> ostream &operator<<(ostream &os, ordered_set<T> S) { os << "{ "; for (auto s : S) os << s << " "; return os << "}"; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { return os << "(" << P.first << "," << P.second << ")"; } template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } template <class L, class R> ostream &operator<<(ostream &os, unordered_map<L, R> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } template <class L, class R, class chash = std::hash<R>> ostream &operator<<(ostream &os, gp_hash_table<L, R, chash> M) { os << "{ "; for (auto m : M) os << "(" << m.first << ":" << m.second << ") "; return os << "}"; } #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) 1 #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); inline int64_t random_long(long long l, long long r) { uniform_int_distribution<int64_t> generator(l, r); return generator(rng); } inline int64_t random_long() { uniform_int_distribution<int64_t> generator(LLONG_MIN, LLONG_MAX); return generator(rng); } /*/---------------------------Defines----------------------/*/ typedef vector<int> vi; typedef pair<int, int> pii; #define ll long long #define F first #define S second #define pb push_back #define endl "\n" #define all(v) (v).begin(), (v).end() /*/-----------------------Modular Arithmetic---------------/*/ const int mod = 1e9 + 7; inline int add(int x, int y) { x += y; if (x >= mod) return x - mod; return x; } inline int sub(int x, int y) { x -= y; if (x < 0) return x + mod; return x; } inline int mul(int x, int y) { return (x * 1ll * y) % mod; } inline int power(int x, int y) { int ans = 1; while (y) { if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } inline int inv(int x) { return power(x, mod - 2); } /*/-----------------------------Code begins----------------------------------/*/ struct contest_scheduling { int D; int c[26]; int satisfaction; vector<int> s[26]; set<int> last_occur[26]; friend istream &operator>>(istream &is, contest_scheduling &p) { is >> p.D; for (int i = 0; i < 26; ++i) { p.s[i].resize(p.D, 0); is >> p.c[i]; } for (int i = 0; i < p.D; ++i) { for (int j = 0; j < 26; ++j) { is >> p.s[j][i]; } } return is; } void calculate_whole(vector<int> t) { assert(t.size() == D); for (int i = 0; i < 26; ++i) { last_occur[i].clear(); last_occur[i].insert(-1); } satisfaction = 0; for (int i = 0; i < D; ++i) { int type = t[i] - 1; satisfaction += s[type][i]; last_occur[type].insert(i); for (int j = 0; j < 26; ++j) { satisfaction -= c[j] * (i - (*last_occur[j].rbegin())); } cout << satisfaction << endl; } } }; void solve() { contest_scheduling U; cin >> U; int D = U.D; // cin>>D; // vector<int> c(26); // int sum_c = 0; // int satisfaction = 0; // for(int i = 0 ; i < 26 ; ++i){ // cin >> c[i]; // sum_c += c[i]; // } // vector<vector<int> > s(D,vector<int> (26)); // vector<int> last_occur(26,-1); // for(int i = 0 ; i < D ; ++i){ // for(int j = 0 ; j < 26 ; ++j){ // cin >> s[i][j]; // } // } vector<int> t(D); for (int i = 0; i < D; ++i) cin >> t[i]; U.calculate_whole(t); // for(int i = 0 ; i < D ; ++i){ // --t[i]; // satisfaction += s[i][t[i]]; // last_occur[t[i]] = i; // for(int j = 0; j < 26 ; ++j){ // satisfaction -= c[j] * (i - last_occur[j]); // } // } } int main() { // Use "set_name".max_load_factor(0.25);"set_name".reserve(512); with // unordered set Or use gp_hash_table<X,null_type> ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed << setprecision(25); cerr << fixed << setprecision(10); auto start = std::chrono::high_resolution_clock::now(); int t = 1; // cin>>t; while (t--) { solve(); } auto stop = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); // cerr << "Time taken : " << ((long double)duration.count())/((long double) // 1e9) <<"s "<< endl; }
replace
191
192
191
192
0
p02620
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int d; int c[27]; int s[400][27]; int t[400]; static int last[27]; // 最後の開催日 int ans = 0; int kotae[500]; cin >> d; rep(i, 26) cin >> c[i + 1]; rep(i, d) { rep(j, 26) { cin >> s[i + 1][j + 1]; } } rep(i, d) { cin >> t[i + 1]; } int m; cin >> m; rep(k, m) { int a, b; cin >> a >> b; t[a] = b; // 初期化 ans = 0; rep(i, 26) last[i + 1] = 0; for (int i = 1; i <= d; i++) { ans += s[i][t[i]]; last[t[i]] = i; for (int j = 1; j <= 26; j++) ans -= (i - last[j]) * c[j]; } kotae[k] = ans; } rep(i, m) cout << kotae[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int d; int c[27]; int s[400][27]; int t[400]; static int last[27]; // 最後の開催日 int ans = 0; int kotae[100005]; cin >> d; rep(i, 26) cin >> c[i + 1]; rep(i, d) { rep(j, 26) { cin >> s[i + 1][j + 1]; } } rep(i, d) { cin >> t[i + 1]; } int m; cin >> m; rep(k, m) { int a, b; cin >> a >> b; t[a] = b; // 初期化 ans = 0; rep(i, 26) last[i + 1] = 0; for (int i = 1; i <= d; i++) { ans += s[i][t[i]]; last[t[i]] = i; for (int j = 1; j <= 26; j++) ans -= (i - last[j]) * c[j]; } kotae[k] = ans; } rep(i, m) cout << kotae[i] << endl; return 0; }
replace
11
12
11
12
0
p02620
C++
Runtime Error
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll conbinationMemo[100][100]; void cmemoInit() { rep(i, 100) { rep(j, 100) { conbinationMemo[i][j] = -1; } } } ll nCr(ll n, ll r) { if (conbinationMemo[n][r] != -1) return conbinationMemo[n][r]; if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- ll d; vector<vector<ll>> s; vector<ll> c(26); vector<ll> t; ll calcScore() { ll score = 0; vector<ll> last(26, -1); rep(i, d) { score += s[i][t[i]]; last[t[i]] = i; rep(j, 26) { score -= (i - last[j]) * c[j]; } } return score; } void updateScore(ll &score, pair<ll, ll> q, vector<set<ll>> &st) { score -= s[q.first][t[q.first]]; score += s[q.first][q.second]; auto itrn = st[t[q.first]].upper_bound(q.first); auto itrp = st[t[q.first]].lower_bound(q.first); itrp--; // cout << score << endl; // cout << c[t[q.first]] << " " << c[q.second] << endl; // cout << *itrp << " " << q.first << " " << *itrn << endl; ll last = (abs(*itrp - q.first) - 1) * c[t[q.first]]; ll start = c[t[q.first]]; score += (abs(*itrp - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - q.first) - 1) * c[t[q.first]]; score += (abs(*itrn - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - *itrp) - 1) * c[t[q.first]]; score -= (abs(*itrn - *itrp) - 1) * ((last + start) / 2.0); // cout << start << " " << last << endl; // cout << (abs(*itrn - *itrp) - 1) * ((last + start) / 2.0) << endl; // cout << score << endl; st[t[q.first]].erase(q.first); st[q.second].insert(q.first); itrn = st[q.second].upper_bound(q.first); itrp = st[q.second].lower_bound(q.first); itrp--; last = (abs(*itrp - *itrn) - 1) * c[q.second]; start = c[q.second]; score += (abs(*itrp - *itrn) - 1) * ((last + start) / 2.0); last = (abs(*itrp - q.first) - 1) * c[q.second]; score -= (abs(*itrp - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - q.first) - 1) * c[q.second]; score -= (abs(*itrn - q.first) - 1) * ((last + start) / 2.0); t[q.first] = q.second; } int main(void) { cin >> d; s.resize(d, vector<ll>(26)); rep(i, 26) cin >> c[i]; rep(i, d) { rep(j, 26) { cin >> s[i][j]; } } t.resize(d); rep(i, d) { cin >> t[i]; t[i]--; } ll score = calcScore(); ll m; cin >> m; vector<pair<ll, ll>> q(m); rep(i, m) { cin >> q[i].first >> q[i].second; q[i].first--; q[i].second--; } vector<set<ll>> st(26); rep(i, d) { st[t[i]].insert(i); } rep(i, 26) { st[i].insert(-1); st[i].insert(d); } // cout << score << endl; rep(i, d) { updateScore(score, q[i], st); cout << score << endl; } }
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll conbinationMemo[100][100]; void cmemoInit() { rep(i, 100) { rep(j, 100) { conbinationMemo[i][j] = -1; } } } ll nCr(ll n, ll r) { if (conbinationMemo[n][r] != -1) return conbinationMemo[n][r]; if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- ll d; vector<vector<ll>> s; vector<ll> c(26); vector<ll> t; ll calcScore() { ll score = 0; vector<ll> last(26, -1); rep(i, d) { score += s[i][t[i]]; last[t[i]] = i; rep(j, 26) { score -= (i - last[j]) * c[j]; } } return score; } void updateScore(ll &score, pair<ll, ll> q, vector<set<ll>> &st) { score -= s[q.first][t[q.first]]; score += s[q.first][q.second]; auto itrn = st[t[q.first]].upper_bound(q.first); auto itrp = st[t[q.first]].lower_bound(q.first); itrp--; // cout << score << endl; // cout << c[t[q.first]] << " " << c[q.second] << endl; // cout << *itrp << " " << q.first << " " << *itrn << endl; ll last = (abs(*itrp - q.first) - 1) * c[t[q.first]]; ll start = c[t[q.first]]; score += (abs(*itrp - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - q.first) - 1) * c[t[q.first]]; score += (abs(*itrn - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - *itrp) - 1) * c[t[q.first]]; score -= (abs(*itrn - *itrp) - 1) * ((last + start) / 2.0); // cout << start << " " << last << endl; // cout << (abs(*itrn - *itrp) - 1) * ((last + start) / 2.0) << endl; // cout << score << endl; st[t[q.first]].erase(q.first); st[q.second].insert(q.first); itrn = st[q.second].upper_bound(q.first); itrp = st[q.second].lower_bound(q.first); itrp--; last = (abs(*itrp - *itrn) - 1) * c[q.second]; start = c[q.second]; score += (abs(*itrp - *itrn) - 1) * ((last + start) / 2.0); last = (abs(*itrp - q.first) - 1) * c[q.second]; score -= (abs(*itrp - q.first) - 1) * ((last + start) / 2.0); last = (abs(*itrn - q.first) - 1) * c[q.second]; score -= (abs(*itrn - q.first) - 1) * ((last + start) / 2.0); t[q.first] = q.second; } int main(void) { cin >> d; s.resize(d, vector<ll>(26)); rep(i, 26) cin >> c[i]; rep(i, d) { rep(j, 26) { cin >> s[i][j]; } } t.resize(d); rep(i, d) { cin >> t[i]; t[i]--; } ll score = calcScore(); ll m; cin >> m; vector<pair<ll, ll>> q(m); rep(i, m) { cin >> q[i].first >> q[i].second; q[i].first--; q[i].second--; } vector<set<ll>> st(26); rep(i, d) { st[t[i]].insert(i); } rep(i, 26) { st[i].insert(-1); st[i].insert(d); } // cout << score << endl; rep(i, m) { updateScore(score, q[i], st); cout << score << endl; } }
replace
173
174
173
174
0
p02620
C++
Runtime Error
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; using ll = long long; ll scoring(vector<int> &schedule); int D; vector<int> decline(26); vector<vector<int>> satis(365, vector<int>(26)); void solve_greedy(vector<int> &schedule) { for (int d = 0; d < D; d++) { int sel = 0; for (int i = 0; i < 26; i++) { if (satis[d][i] > satis[d][sel]) { sel = i; } } schedule[d] = sel; } } ll scoring(vector<int> &schedule) { vector<int> lastHeld(26, 0); ll sat = 0; for (int d = 1; d <= D; d++) { int contest = schedule[d - 1]; lastHeld[contest] = d; for (int i = 0; i < 26; i++) { if (i == contest) { sat += satis[d - 1][i]; } sat -= decline[i] * (d - lastHeld[i]); } // cout<<sat<<endl; } return sat; } ll calcDiff(vector<int> &schedule, vector<int> &d, vector<int> &q, int M) { vector<set<int>> sched(26, set<int>()); for (int i = 0; i < D; i++) { sched[schedule[i]].insert(i); } // cout<<"A"<<endl; for (int i = 0; i < 26; i++) { sched[i].insert(-1); sched[i].insert(D); } ll result = scoring(schedule); // cout<<"a"<<endl; for (int i = 0; i < M; i++) { result -= satis[d[i]][schedule[d[i]]]; result += satis[d[i]][q[i]]; auto lastHeldNewP = sched[q[i]].lower_bound(d[i]); lastHeldNewP--; int lastHeldNew = *lastHeldNewP; int nextHeldNew = *sched[q[i]].lower_bound(d[i] + 1); auto lastHeldOldP = (sched[schedule[d[i]]].lower_bound(d[i])); lastHeldOldP--; int lastHeldOld = *(lastHeldOldP); int nextHeldOld = *sched[schedule[d[i]]].lower_bound(d[i] + 1); result += decline[q[i]] * (nextHeldNew - d[i]) * (d[i] - lastHeldNew); result -= decline[schedule[d[i]]] * (nextHeldOld - d[i]) * (d[i] - lastHeldOld); // cout<<q[i]<<" " <<lastHeldNew<<" "<<nextHeldNew<<" "<<d[i]<<endl; // cout<<schedule[d[i]]<<" "<<lastHeldOld<<" "<<nextHeldOld<<" // "<<d[i]<<endl; sched[q[i]].insert(d[i]); sched[schedule[d[i]]].erase(d[i]); schedule[d[i]] = q[i]; cout << result << endl; // cout<<scoring(schedule)<<endl; } } int main() { cin >> D; for (int i = 0; i < 26; i++) { int c; cin >> c; decline[i] = c; } for (int d = 0; d < D; d++) { for (int i = 0; i < 26; i++) { int s; cin >> s; satis[d][i] = s; } } vector<int> schedule(D, 0); // solve_greedy(schedule); // for(int i = 0;i < schedule.size();i++){ // cout<<schedule[i]+1<<endl; // } // scoring(schedule); for (int i = 0; i < D; i++) { cin >> schedule[i]; schedule[i]--; } int M; cin >> M; vector<int> d(M), q(M); for (int i = 0; i < M; i++) { cin >> d[i] >> q[i]; d[i]--; q[i]--; } // cout<<"A"<<endl; calcDiff(schedule, d, q, M); }
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; using ll = long long; ll scoring(vector<int> &schedule); int D; vector<int> decline(26); vector<vector<int>> satis(365, vector<int>(26)); void solve_greedy(vector<int> &schedule) { for (int d = 0; d < D; d++) { int sel = 0; for (int i = 0; i < 26; i++) { if (satis[d][i] > satis[d][sel]) { sel = i; } } schedule[d] = sel; } } ll scoring(vector<int> &schedule) { vector<int> lastHeld(26, 0); ll sat = 0; for (int d = 1; d <= D; d++) { int contest = schedule[d - 1]; lastHeld[contest] = d; for (int i = 0; i < 26; i++) { if (i == contest) { sat += satis[d - 1][i]; } sat -= decline[i] * (d - lastHeld[i]); } // cout<<sat<<endl; } return sat; } ll calcDiff(vector<int> &schedule, vector<int> &d, vector<int> &q, int M) { vector<set<int>> sched(26, set<int>()); for (int i = 0; i < D; i++) { sched[schedule[i]].insert(i); } // cout<<"A"<<endl; for (int i = 0; i < 26; i++) { sched[i].insert(-1); sched[i].insert(D); } ll result = scoring(schedule); // cout<<"a"<<endl; for (int i = 0; i < M; i++) { result -= satis[d[i]][schedule[d[i]]]; result += satis[d[i]][q[i]]; auto lastHeldNewP = sched[q[i]].lower_bound(d[i]); lastHeldNewP--; int lastHeldNew = *lastHeldNewP; int nextHeldNew = *sched[q[i]].lower_bound(d[i] + 1); auto lastHeldOldP = (sched[schedule[d[i]]].lower_bound(d[i])); lastHeldOldP--; int lastHeldOld = *(lastHeldOldP); int nextHeldOld = *sched[schedule[d[i]]].lower_bound(d[i] + 1); result += decline[q[i]] * (nextHeldNew - d[i]) * (d[i] - lastHeldNew); result -= decline[schedule[d[i]]] * (nextHeldOld - d[i]) * (d[i] - lastHeldOld); // cout<<q[i]<<" " <<lastHeldNew<<" "<<nextHeldNew<<" "<<d[i]<<endl; // cout<<schedule[d[i]]<<" "<<lastHeldOld<<" "<<nextHeldOld<<" // "<<d[i]<<endl; sched[q[i]].insert(d[i]); sched[schedule[d[i]]].erase(d[i]); schedule[d[i]] = q[i]; cout << result << endl; // cout<<scoring(schedule)<<endl; } return result; } int main() { cin >> D; for (int i = 0; i < 26; i++) { int c; cin >> c; decline[i] = c; } for (int d = 0; d < D; d++) { for (int i = 0; i < 26; i++) { int s; cin >> s; satis[d][i] = s; } } vector<int> schedule(D, 0); // solve_greedy(schedule); // for(int i = 0;i < schedule.size();i++){ // cout<<schedule[i]+1<<endl; // } // scoring(schedule); for (int i = 0; i < D; i++) { cin >> schedule[i]; schedule[i]--; } int M; cin >> M; vector<int> d(M), q(M); for (int i = 0; i < M; i++) { cin >> d[i] >> q[i]; d[i]--; q[i]--; } // cout<<"A"<<endl; calcDiff(schedule, d, q, M); }
insert
78
78
78
79
0
p02620
C++
Runtime Error
#include <bits/stdc++.h> int main() { int D; std::cin >> D; std::vector<int> C(26); for (int i = 0; i < 26; i++) { std::cin >> C[i]; } std::vector<std::vector<int>> S(D, std::vector<int>(26)); for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) { std::cin >> S[i][j]; } } std::vector<int> T(D); for (int i = 0; i < D; i++) { std::cin >> T[i]; } int M; std::cin >> M; std::vector<int> D_query(M); std::vector<int> Q_query(M); for (int i = 0; i < M; i++) { std::cin >> D_query[i] >> Q_query[i]; } std::vector<int> V(D); for (int q = 0; q < M; q++) { T[D_query[q] - 1] = Q_query[q]; long long ans = 0; std::vector<int> last(26, 0); for (int i = 0; i < D; i++) { ans += S[i][T[i] - 1]; last[T[i] - 1] = i + 1; for (int j = 0; j < 26; j++) { ans -= (i + 1 - last[j]) * C[j]; } } V[q] = ans; } for (int i = 0; i < M; i++) { std::cout << V[i] << std::endl; } return 0; }
#include <bits/stdc++.h> int main() { int D; std::cin >> D; std::vector<int> C(26); for (int i = 0; i < 26; i++) { std::cin >> C[i]; } std::vector<std::vector<int>> S(D, std::vector<int>(26)); for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) { std::cin >> S[i][j]; } } std::vector<int> T(D); for (int i = 0; i < D; i++) { std::cin >> T[i]; } int M; std::cin >> M; std::vector<int> D_query(M); std::vector<int> Q_query(M); for (int i = 0; i < M; i++) { std::cin >> D_query[i] >> Q_query[i]; } std::vector<int> V(M); for (int q = 0; q < M; q++) { T[D_query[q] - 1] = Q_query[q]; long long ans = 0; std::vector<int> last(26, 0); for (int i = 0; i < D; i++) { ans += S[i][T[i] - 1]; last[T[i] - 1] = i + 1; for (int j = 0; j < 26; j++) { ans -= (i + 1 - last[j]) * C[j]; } } V[q] = ans; } for (int i = 0; i < M; i++) { std::cout << V[i] << std::endl; } return 0; }
replace
28
29
28
29
0
p02620
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int d; cin >> d; vector<int> c; for (int i = 0; i < 26; i++) { int tmp; cin >> tmp; c.push_back(tmp); } vector<vector<int>> s(d, vector<int>(26, 0)); for (int i = 0; i < d; i++) { for (int j = 0; j < 26; j++) { cin >> s[i].at(j); } } vector<int> t; for (int i = 0; i < d; i++) { int tmp; cin >> tmp; t.push_back(tmp); } int m; cin >> m; vector<int> d_; vector<int> q; for (int i = 0; i < m; i++) { int tmp1, tmp2; cin >> tmp1 >> tmp2; d_.push_back(tmp1); q.push_back(tmp2); } /* vector<int> last(26,0); int ans = 0; int i = 0; while(i<d){ int dec = 0; ans += s[i][t[i]-1]; last[t[i]-1] = i+1; for(int j=0; j<26; j++){ dec += c[j] * (i+1-last[j]); } ans -= dec; i++; cout << ans << endl; } */ vector<int> last_(26, 0); int total; for (int k = 0; k < d; k++) { // int tmp3 = t[d_[k]-1]; t[d_[k] - 1] = q[k]; /* for(int l=0;l<d;l++){ cout << t[l] << " "; } cout << endl; */ // cout << t[d_[j]-1] << endl; // cout << tmp3 << endl; int i_ = 0; long long ans_ = 0; for (int a = 0; a < 26; a++) { last_[a] = 0; } while (i_ < d) { long long dec_ = 0; // cout << t[i_] << endl; ans_ += s[i_][t[i_] - 1]; last_[t[i_] - 1] = i_ + 1; for (int j = 0; j < 26; j++) { dec_ += c[j] * (i_ + 1 - last_[j]); } ans_ -= dec_; i_++; } cout << ans_ << endl; // cout << tmp3 << endl; // total = max(ans,ans_); /* if(total == ans){ t[d_[j]-1] = tmp3; } */ // cout << total << endl; } /* //デバッグ処理 for(int i=0; i<26; i++){ cout << c[i] << " "; } cout << endl; for(int i=0; i<d; i++){ for(int j=0; j<26; j++){ cout << s[i][j] << " "; } cout << endl; } for(int i=0; i<d; i++){ cout << t[i] << " "; } */ return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int d; cin >> d; vector<int> c; for (int i = 0; i < 26; i++) { int tmp; cin >> tmp; c.push_back(tmp); } vector<vector<int>> s(d, vector<int>(26, 0)); for (int i = 0; i < d; i++) { for (int j = 0; j < 26; j++) { cin >> s[i].at(j); } } vector<int> t; for (int i = 0; i < d; i++) { int tmp; cin >> tmp; t.push_back(tmp); } int m; cin >> m; vector<int> d_; vector<int> q; for (int i = 0; i < m; i++) { int tmp1, tmp2; cin >> tmp1 >> tmp2; d_.push_back(tmp1); q.push_back(tmp2); } /* vector<int> last(26,0); int ans = 0; int i = 0; while(i<d){ int dec = 0; ans += s[i][t[i]-1]; last[t[i]-1] = i+1; for(int j=0; j<26; j++){ dec += c[j] * (i+1-last[j]); } ans -= dec; i++; cout << ans << endl; } */ vector<int> last_(26, 0); int total; for (int k = 0; k < m; k++) { // int tmp3 = t[d_[k]-1]; t[d_[k] - 1] = q[k]; /* for(int l=0;l<d;l++){ cout << t[l] << " "; } cout << endl; */ // cout << t[d_[j]-1] << endl; // cout << tmp3 << endl; int i_ = 0; long long ans_ = 0; for (int a = 0; a < 26; a++) { last_[a] = 0; } while (i_ < d) { long long dec_ = 0; // cout << t[i_] << endl; ans_ += s[i_][t[i_] - 1]; last_[t[i_] - 1] = i_ + 1; for (int j = 0; j < 26; j++) { dec_ += c[j] * (i_ + 1 - last_[j]); } ans_ -= dec_; i_++; } cout << ans_ << endl; // cout << tmp3 << endl; // total = max(ans,ans_); /* if(total == ans){ t[d_[j]-1] = tmp3; } */ // cout << total << endl; } /* //デバッグ処理 for(int i=0; i<26; i++){ cout << c[i] << " "; } cout << endl; for(int i=0; i<d; i++){ for(int j=0; j<26; j++){ cout << s[i][j] << " "; } cout << endl; } for(int i=0; i<d; i++){ cout << t[i] << " "; } */ return 0; }
replace
58
59
58
59
0
p02620
C++
Runtime Error
/* マラソン用 テンプレート */ /*力が欲しいか…? #pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags #pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX #pragma GCC target("avx") //Enable AVX */ // #include <x86intrin.h> #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; using namespace chrono; template <class T, class U> inline constexpr bool chmin(T &a, const U b) { if (a <= b) return false; a = b; return true; } template <class T, class U> inline constexpr bool chmax(T &a, const U b) { if (a >= b) return false; a = b; return true; } #define bit(n, k) (((n) >> (k)) & 1) inline void bin101() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; // Xorshift(色々なbit)とTimerを書く struct Timer { chrono::high_resolution_clock::time_point st; Timer() { start(); } void start() { st = chrono::high_resolution_clock::now(); } chrono::milliseconds::rep span() { auto ed = chrono::high_resolution_clock::now(); return chrono::duration_cast<chrono::milliseconds>(ed - st).count(); } }; struct Test { chrono::high_resolution_clock::time_point st; Test() { start(); } u64 sum = 0; u64 cnt = 0; void start() { st = chrono::high_resolution_clock::now(); } void span() { sum += chrono::duration_cast<chrono::nanoseconds>( chrono::high_resolution_clock::now() - st) .count(); cnt++; } void print() { cerr << "TEST" << endl; cerr << "cnt:" << cnt << "ave:" << (long double)sum / cnt << endl; } void reset() { sum = 0; cnt = 0; st = chrono::high_resolution_clock::now(); } }; struct Xor32 { u32 x = 1234567; inline u32 rnd_make() { x ^= (x << 13); x = x ^ (x >> 17); return x = x ^ (x << 5); } inline u32 operator()() { return rnd_make(); } //[a,b] inline int operator()(int a, int b) { int dis = b - a + 1; int add = rnd_make() % dis; return a + add; } }; struct Xor8 { uint8_t x[128]; uint8_t cnt = 0; Xor8() { uint_fast8_t y = 10; for (int i = 0; i < 128; i++) { y ^= (y >> 1); y ^= (y << 1); y ^= (y >> 2); x[i] = (y & 0b11111); } } inline uint8_t rnd_make() { if (bit(cnt, 7)) cnt = 0; return x[cnt++]; } inline uint8_t operator()() { return rnd_make(); } inline uint8_t operator()(int a, int b) { int dis = b - a + 1; int add = rnd_make() % dis; return a + add; } }; int D = 365; int c[26]; int s[366][26]; int last[366][26]; int hand[366]; set<int> used[26]; Xor32 Rand; Timer TIME; void ans_print() { for (int i = 1; i <= D; i++) { cout << hand[i] + 1 << "\n"; } } // http://shindannin.hatenadiary.com/entry/20121224/1356364040 // http://gasin.hatenadiary.jp/entry/2019/09/03/162613 inline bool yakinamashi(float plus) { static float startTemp = 2000000; // 差の最大値 static float endTemp = 10; // 差の最小値 static float endTime = 1960; float temp = startTemp + (endTemp - startTemp) * TIME.span() / endTime; // 時間がたつにつれ、startTemp→endTempに変化 // cerr<<temp<<endl; float probability = exp(plus / temp); // cerr<<plus<<" "<<probability<<endl; return probability > (float)(Rand() % 100) / 100; } int main() { bin101(); cin >> D; for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 1; i <= D; i++) { for (int j = 0; j < 26; j++) cin >> s[i][j]; } i64 ret = 0; for (int i = 1; i <= D; i++) { int t = Rand(0, 25); cin >> t; hand[i] = t; used[t].insert(i); ret += s[i][t]; last[i][t] = i; for (int j = 0; j < 26; j++) { if (j != t) last[i][j] = last[i - 1][j]; ret -= c[j] * (i - last[i][j]); } } for (int i = 0; i < 26; i++) { used[i].insert(D + 1); used[i].insert(0); } cerr << ret << endl; i64 plus; i64 max_plus = 0; int d, post, pre; u32 cnt = 0; int M; cin >> M; while (M--) { if ((cnt & 0b1111111) == 0b1111111) { if (TIME.span() > 1960) break; } cnt++; plus = 0; d = Rand(1, 365), post = Rand(0, 25); cin >> d >> post; post--; pre = hand[d]; // まずはsの反映 plus += (s[d][post] - s[d][pre]); auto pre_middle = used[pre].find(d); auto pre_sita = pre_middle; pre_sita--; auto pre_ue = pre_middle; pre_ue++; plus -= c[pre] * (*pre_ue - d) * (d - *pre_sita); auto post_ue = used[post].upper_bound(d); auto post_sita = post_ue; post_sita--; plus += c[post] * (*post_ue - d) * (d - *post_sita); if (true || plus > 0 || yakinamashi(plus)) { hand[d] = post; used[pre].erase(pre_middle); used[post].insert(d); ret += plus; } cout << ret << endl; } }
/* マラソン用 テンプレート */ /*力が欲しいか…? #pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags #pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX #pragma GCC target("avx") //Enable AVX */ // #include <x86intrin.h> #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; using namespace chrono; template <class T, class U> inline constexpr bool chmin(T &a, const U b) { if (a <= b) return false; a = b; return true; } template <class T, class U> inline constexpr bool chmax(T &a, const U b) { if (a >= b) return false; a = b; return true; } #define bit(n, k) (((n) >> (k)) & 1) inline void bin101() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; // Xorshift(色々なbit)とTimerを書く struct Timer { chrono::high_resolution_clock::time_point st; Timer() { start(); } void start() { st = chrono::high_resolution_clock::now(); } chrono::milliseconds::rep span() { auto ed = chrono::high_resolution_clock::now(); return chrono::duration_cast<chrono::milliseconds>(ed - st).count(); } }; struct Test { chrono::high_resolution_clock::time_point st; Test() { start(); } u64 sum = 0; u64 cnt = 0; void start() { st = chrono::high_resolution_clock::now(); } void span() { sum += chrono::duration_cast<chrono::nanoseconds>( chrono::high_resolution_clock::now() - st) .count(); cnt++; } void print() { cerr << "TEST" << endl; cerr << "cnt:" << cnt << "ave:" << (long double)sum / cnt << endl; } void reset() { sum = 0; cnt = 0; st = chrono::high_resolution_clock::now(); } }; struct Xor32 { u32 x = 1234567; inline u32 rnd_make() { x ^= (x << 13); x = x ^ (x >> 17); return x = x ^ (x << 5); } inline u32 operator()() { return rnd_make(); } //[a,b] inline int operator()(int a, int b) { int dis = b - a + 1; int add = rnd_make() % dis; return a + add; } }; struct Xor8 { uint8_t x[128]; uint8_t cnt = 0; Xor8() { uint_fast8_t y = 10; for (int i = 0; i < 128; i++) { y ^= (y >> 1); y ^= (y << 1); y ^= (y >> 2); x[i] = (y & 0b11111); } } inline uint8_t rnd_make() { if (bit(cnt, 7)) cnt = 0; return x[cnt++]; } inline uint8_t operator()() { return rnd_make(); } inline uint8_t operator()(int a, int b) { int dis = b - a + 1; int add = rnd_make() % dis; return a + add; } }; int D = 365; int c[26]; int s[366][26]; int last[366][26]; int hand[366]; set<int> used[26]; Xor32 Rand; Timer TIME; void ans_print() { for (int i = 1; i <= D; i++) { cout << hand[i] + 1 << "\n"; } } // http://shindannin.hatenadiary.com/entry/20121224/1356364040 // http://gasin.hatenadiary.jp/entry/2019/09/03/162613 inline bool yakinamashi(float plus) { static float startTemp = 2000000; // 差の最大値 static float endTemp = 10; // 差の最小値 static float endTime = 1960; float temp = startTemp + (endTemp - startTemp) * TIME.span() / endTime; // 時間がたつにつれ、startTemp→endTempに変化 // cerr<<temp<<endl; float probability = exp(plus / temp); // cerr<<plus<<" "<<probability<<endl; return probability > (float)(Rand() % 100) / 100; } int main() { bin101(); cin >> D; for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 1; i <= D; i++) { for (int j = 0; j < 26; j++) cin >> s[i][j]; } i64 ret = 0; for (int i = 1; i <= D; i++) { int t = Rand(0, 25); cin >> t; t--; hand[i] = t; used[t].insert(i); ret += s[i][t]; last[i][t] = i; for (int j = 0; j < 26; j++) { if (j != t) last[i][j] = last[i - 1][j]; ret -= c[j] * (i - last[i][j]); } } for (int i = 0; i < 26; i++) { used[i].insert(D + 1); used[i].insert(0); } cerr << ret << endl; i64 plus; i64 max_plus = 0; int d, post, pre; u32 cnt = 0; int M; cin >> M; while (M--) { if ((cnt & 0b1111111) == 0b1111111) { if (TIME.span() > 1960) break; } cnt++; plus = 0; d = Rand(1, 365), post = Rand(0, 25); cin >> d >> post; post--; pre = hand[d]; // まずはsの反映 plus += (s[d][post] - s[d][pre]); auto pre_middle = used[pre].find(d); auto pre_sita = pre_middle; pre_sita--; auto pre_ue = pre_middle; pre_ue++; plus -= c[pre] * (*pre_ue - d) * (d - *pre_sita); auto post_ue = used[post].upper_bound(d); auto post_sita = post_ue; post_sita--; plus += c[post] * (*post_ue - d) * (d - *post_sita); if (true || plus > 0 || yakinamashi(plus)) { hand[d] = post; used[pre].erase(pre_middle); used[post].insert(d); ret += plus; } cout << ret << endl; } }
insert
188
188
188
189
0
46381.0
p02620
C++
Runtime Error
#include <bits/stdc++.h> // #undef DEBUG // Uncomment this line to forcefully disable debug print. #if DEBUG template <typename T> void debug(T value) { std::cerr << value; } template <typename T, typename... Ts> void debug(T value, Ts... args) { std::cerr << value << ", "; debug(args...); } #define dbg(...) \ do { \ cerr << #__VA_ARGS__ << ": "; \ debug(__VA_ARGS__); \ cerr << " (L" << __LINE__ << ")" << endl; \ } while (0) #else #define dbg(...) #endif void read_from_cin() {} template <typename T, typename... Ts> void read_from_cin(T &value, Ts &...args) { std::cin >> value; read_from_cin(args...); } #define in(type, ...) \ type __VA_ARGS__; \ read_from_cin(__VA_ARGS__); template <typename T> void write_to_cout(const T &value) { std::cout << value << std::endl; } template <typename T, typename... Ts> void write_to_cout(const T &value, const Ts &...args) { std::cout << value << ' '; write_to_cout(args...); } #define out(...) write_to_cout(__VA_ARGS__); #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using ll = long long; using namespace std; struct Problem { int D; vector<int> c; vector<vector<int>> s; }; class Solution { public: Solution(const Problem &p, const vector<int> &t) : problem_(p), types_(t), held_(26, {0, p.D + 1}), sat_(0) { rep(i, p.D) { sat_ += p.s[i][t[i]]; held_[t[i]].insert(i + 1); } rep(i, 26) { const set<int> &h = held_[i]; auto it = h.begin(); ++it; for (; it != h.end(); ++it) { auto jt = it; --jt; int n = (*it - *jt - 1); sat_ -= p.c[i] * n * (n + 1) / 2; } } } void Change(int d, int q) { assert(d < types_.size()); assert(types_[d] != q); auto change = [&](int date) { int t = types_[date]; int ret = problem_.s[date][t]; auto it = held_[t].find(date + 1); assert(it != held_[t].end()); auto jt = it; --jt; int n = (*it - *jt); auto kt = it; ++kt; int m = (*kt - *it); ret += problem_.c[t] * m * n; return ret; }; sat_ -= change(d); held_[types_[d]].erase(d + 1); types_[d] = q; assert(held_[types_[d]].count(d + 1) == 0); held_[types_[d]].insert(d + 1); sat_ += change(d); } int Sat() const { return sat_; } private: const Problem &problem_; vector<int> types_; vector<set<int>> held_; int sat_; }; int main() { Problem p; cin >> p.D; p.c.resize(26); rep(i, 26) cin >> p.c[i]; p.s.resize(p.D); rep(i, p.D) { p.s[i].resize(26); rep(j, 26) cin >> p.s[i][j]; } vector<int> t(p.D); rep(i, p.D) { cin >> t[i]; --t[i]; } Solution s(p, t); in(int, m); while (m--) { in(int, d, q); --d, --q; assert(q != t[d]); s.Change(d, q); out(s.Sat()); } }
#include <bits/stdc++.h> // #undef DEBUG // Uncomment this line to forcefully disable debug print. #if DEBUG template <typename T> void debug(T value) { std::cerr << value; } template <typename T, typename... Ts> void debug(T value, Ts... args) { std::cerr << value << ", "; debug(args...); } #define dbg(...) \ do { \ cerr << #__VA_ARGS__ << ": "; \ debug(__VA_ARGS__); \ cerr << " (L" << __LINE__ << ")" << endl; \ } while (0) #else #define dbg(...) #endif void read_from_cin() {} template <typename T, typename... Ts> void read_from_cin(T &value, Ts &...args) { std::cin >> value; read_from_cin(args...); } #define in(type, ...) \ type __VA_ARGS__; \ read_from_cin(__VA_ARGS__); template <typename T> void write_to_cout(const T &value) { std::cout << value << std::endl; } template <typename T, typename... Ts> void write_to_cout(const T &value, const Ts &...args) { std::cout << value << ' '; write_to_cout(args...); } #define out(...) write_to_cout(__VA_ARGS__); #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using ll = long long; using namespace std; struct Problem { int D; vector<int> c; vector<vector<int>> s; }; class Solution { public: Solution(const Problem &p, const vector<int> &t) : problem_(p), types_(t), held_(26, {0, p.D + 1}), sat_(0) { rep(i, p.D) { sat_ += p.s[i][t[i]]; held_[t[i]].insert(i + 1); } rep(i, 26) { const set<int> &h = held_[i]; auto it = h.begin(); ++it; for (; it != h.end(); ++it) { auto jt = it; --jt; int n = (*it - *jt - 1); sat_ -= p.c[i] * n * (n + 1) / 2; } } } void Change(int d, int q) { assert(d < types_.size()); assert(types_[d] != q); auto change = [&](int date) { int t = types_[date]; int ret = problem_.s[date][t]; auto it = held_[t].find(date + 1); assert(it != held_[t].end()); auto jt = it; --jt; int n = (*it - *jt); auto kt = it; ++kt; int m = (*kt - *it); ret += problem_.c[t] * m * n; return ret; }; sat_ -= change(d); held_[types_[d]].erase(d + 1); types_[d] = q; assert(held_[types_[d]].count(d + 1) == 0); held_[types_[d]].insert(d + 1); sat_ += change(d); } int Sat() const { return sat_; } private: const Problem &problem_; vector<int> types_; vector<set<int>> held_; int sat_; }; int main() { Problem p; cin >> p.D; p.c.resize(26); rep(i, 26) cin >> p.c[i]; p.s.resize(p.D); rep(i, p.D) { p.s[i].resize(26); rep(j, 26) cin >> p.s[i][j]; } vector<int> t(p.D); rep(i, p.D) { cin >> t[i]; --t[i]; } Solution s(p, t); in(int, m); while (m--) { in(int, d, q); --d, --q; s.Change(d, q); out(s.Sat()); } }
delete
131
132
131
131
0
p02620
C++
Runtime Error
#include <cassert> #include <iostream> #include <set> #include <vector> using namespace std; int D; vector<int> C; vector<vector<int>> S; struct State { vector<int> T; vector<set<int>> X; long long score; State() : T(26, -1), X(26, set<int>{-1, D}) { score = 0; for (int i = 0; i < 26; i++) score -= (long long)C[i] * D * (D + 1) / 2; } void add(int d, int t) { assert(T[d] == -1); assert(X[t].count(d) == 0); auto p1 = X[t].lower_bound(d); auto p0 = p1; p0--; score += (long long)C[t] * (d - *p0) * (*p1 - d); score += S[d][t]; X[t].insert(d); T[d] = t; } void remove(int d) { assert(T[d] != -1); assert(X[T[d]].count(d) > 0); int t = T[d]; auto p = X[t].find(d); auto p0 = p; p0--; auto p1 = p; p1++; score -= (long long)C[t] * (d - *p0) * (*p1 - d); score -= S[d][t]; X[t].erase(d); T[d] = -1; } }; int main() { cin >> D; C = vector<int>(26); for (int &c : C) cin >> c; S = vector<vector<int>>(D, vector<int>(26)); for (auto &s : S) for (auto &x : s) cin >> x; State state; for (int i = 0; i < D; i++) { int t; cin >> t; t--; state.add(i, t); } int M; cin >> M; for (int i = 0; i < M; i++) { int d; int q; cin >> d >> q; d--, q--; state.remove(d); state.add(d, q); cout << state.score << endl; } }
#include <cassert> #include <iostream> #include <set> #include <vector> using namespace std; int D; vector<int> C; vector<vector<int>> S; struct State { vector<int> T; vector<set<int>> X; long long score; State() : T(D, -1), X(26, set<int>{-1, D}) { score = 0; for (int i = 0; i < 26; i++) score -= (long long)C[i] * D * (D + 1) / 2; } void add(int d, int t) { assert(T[d] == -1); assert(X[t].count(d) == 0); auto p1 = X[t].lower_bound(d); auto p0 = p1; p0--; score += (long long)C[t] * (d - *p0) * (*p1 - d); score += S[d][t]; X[t].insert(d); T[d] = t; } void remove(int d) { assert(T[d] != -1); assert(X[T[d]].count(d) > 0); int t = T[d]; auto p = X[t].find(d); auto p0 = p; p0--; auto p1 = p; p1++; score -= (long long)C[t] * (d - *p0) * (*p1 - d); score -= S[d][t]; X[t].erase(d); T[d] = -1; } }; int main() { cin >> D; C = vector<int>(26); for (int &c : C) cin >> c; S = vector<vector<int>>(D, vector<int>(26)); for (auto &s : S) for (auto &x : s) cin >> x; State state; for (int i = 0; i < D; i++) { int t; cin >> t; t--; state.add(i, t); } int M; cin >> M; for (int i = 0; i < M; i++) { int d; int q; cin >> d >> q; d--, q--; state.remove(d); state.add(d, q); cout << state.score << endl; } }
replace
14
15
14
15
0
p02620
C++
Runtime Error
// #define _DEBUG #include "bits/stdc++.h" #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x #define debug_1(x1) cout << #x1 << ": " << x1 << endl #define debug_2(x1, x2) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl #define debug_3(x1, x2, x3) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << endl #define debug_4(x1, x2, x3, x4) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << ", " #x4 << ": " << x4 << endl #define debug_5(x1, x2, x3, x4, x5) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl #ifdef _DEBUG #define debug(...) \ CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \ (__VA_ARGS__) #else #define debug(...) #endif #define rep(index, num) for (int index = 0; index < (int)num; index++) #define rep1(index, num) for (int index = 1; index <= (int)num; index++) #define brep(index, num) for (int index = (int)num - 1; index >= 0; index--) #define brep1(index, num) for (int index = (int)num; index > 0; index--) #define scan(argument) cin >> argument #define prin(argument) cout << argument << endl #define kaigyo cout << endl #define eps 1e-7 #define mp(a1, a2) make_pair(a1, a2) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef long long ll; typedef long double ld; using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<pint> vpint; typedef vector<pll> vpll; ll INFl = (ll)1e+18 + 1; int INF = 1e+9 + 1; ll D, c[27], s[366][27]; ll t[366]; set<ll> tst[26]; int main() { srand(time(NULL)); std::chrono::system_clock::time_point start = std::chrono::system_clock::now(); int nowtime = 0; int TIMEMAX = 1950; nowtime = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now() - start) .count(); scan(D); /* rep(i,26) scan(c[i]); rep(i,D){ rep(j,26){ scan(s[i][j]); } }*/ rep(i, 26) c[i] = 1; rep(i, D) rep(j, 26) s[i][j] = 0; ll pt = 0; rep(i, 26) { tst[i].insert(-1); tst[i].insert(D); } rep(i, D) { scan(t[i]); t[i]--; tst[t[i]].insert(i); pt += s[i][t[i]]; } rep(i, 26) { for (auto itr = tst[i].begin(); itr != tst[i].end(); itr++) { if (itr == tst[i].begin()) continue; auto itr2 = itr; itr2--; pt -= ((*itr) - (*itr2)) * ((*itr) - (*itr2) - 1) * c[i] / 2; } } int M; scan(M); rep(k, M) { ll d, q; scan(d >> q); d--; q--; ll befq = t[d]; t[d] = q; pt += s[d][q] - s[d][befq]; auto itr = tst[befq].lower_bound(d); auto itrb = itr; itrb--; auto itrn = itr; itrn++; pt -= ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[befq]; tst[befq].erase(itr); tst[q].insert(d); auto nitr = tst[q].lower_bound(d); auto nitrb = nitr; nitrb--; auto nitrn = nitr; nitrn++; pt += ((*nitrn) - (*nitr)) * ((*nitr) - (*nitrb)) * c[q]; debug(befq, *itrb, *itr, *itrn, ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[befq]); debug(q, *nitrb, *nitr, *nitrn, ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[q]); prin(pt); } return 0; }
// #define _DEBUG #include "bits/stdc++.h" #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x #define debug_1(x1) cout << #x1 << ": " << x1 << endl #define debug_2(x1, x2) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl #define debug_3(x1, x2, x3) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << endl #define debug_4(x1, x2, x3, x4) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << ", " #x4 << ": " << x4 << endl #define debug_5(x1, x2, x3, x4, x5) \ cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \ << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl #ifdef _DEBUG #define debug(...) \ CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \ (__VA_ARGS__) #else #define debug(...) #endif #define rep(index, num) for (int index = 0; index < (int)num; index++) #define rep1(index, num) for (int index = 1; index <= (int)num; index++) #define brep(index, num) for (int index = (int)num - 1; index >= 0; index--) #define brep1(index, num) for (int index = (int)num; index > 0; index--) #define scan(argument) cin >> argument #define prin(argument) cout << argument << endl #define kaigyo cout << endl #define eps 1e-7 #define mp(a1, a2) make_pair(a1, a2) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef long long ll; typedef long double ld; using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<pint> vpint; typedef vector<pll> vpll; ll INFl = (ll)1e+18 + 1; int INF = 1e+9 + 1; ll D, c[27], s[366][27]; ll t[366]; set<ll> tst[26]; int main() { srand(time(NULL)); std::chrono::system_clock::time_point start = std::chrono::system_clock::now(); int nowtime = 0; int TIMEMAX = 1950; nowtime = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now() - start) .count(); scan(D); rep(i, 26) scan(c[i]); rep(i, D) { rep(j, 26) { scan(s[i][j]); } } ll pt = 0; rep(i, 26) { tst[i].insert(-1); tst[i].insert(D); } rep(i, D) { scan(t[i]); t[i]--; tst[t[i]].insert(i); pt += s[i][t[i]]; } rep(i, 26) { for (auto itr = tst[i].begin(); itr != tst[i].end(); itr++) { if (itr == tst[i].begin()) continue; auto itr2 = itr; itr2--; pt -= ((*itr) - (*itr2)) * ((*itr) - (*itr2) - 1) * c[i] / 2; } } int M; scan(M); rep(k, M) { ll d, q; scan(d >> q); d--; q--; ll befq = t[d]; t[d] = q; pt += s[d][q] - s[d][befq]; auto itr = tst[befq].lower_bound(d); auto itrb = itr; itrb--; auto itrn = itr; itrn++; pt -= ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[befq]; tst[befq].erase(itr); tst[q].insert(d); auto nitr = tst[q].lower_bound(d); auto nitrb = nitr; nitrb--; auto nitrn = nitr; nitrn++; pt += ((*nitrn) - (*nitr)) * ((*nitr) - (*nitrb)) * c[q]; debug(befq, *itrb, *itr, *itrn, ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[befq]); debug(q, *nitrb, *nitr, *nitrn, ((*itrn) - (*itr)) * ((*itr) - (*itrb)) * c[q]); prin(pt); } return 0; }
replace
59
67
59
63
-11
p02620
C++
Runtime Error
#include <algorithm> #include <cmath> #include <ctime> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) // #include <bits/stdc++.h> using namespace std; int main() { int D; cin >> D; vector<long int> c(26); vector<vector<long int>> s(D, vector<long int>(26)); for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) cin >> s[i][j]; } vector<int> t(D, -1); vector<vector<int>> memo(26); vector<int> memo2(26, -1); vector<long int> ans; long int ans2 = 0; for (int i = 0; i < 26; i++) memo[i].push_back(-1); for (int i = 0; i < D; i++) { cin >> t[i]; t[i]--; memo[t[i]].push_back(i); memo2[t[i]] = i; ans2 += s[i][t[i]]; for (int j = 0; j < 26; j++) { ans2 -= c[j] * (i - memo2[j]); } } for (int i = 0; i < 26; i++) memo[i].push_back(D); ans.push_back(ans2); int M; cin >> M; int k = 0; vector<int> d(M), q(M); for (int i = 0; i < M; i++) { cin >> d[i] >> q[i]; d[i]--; q[i]--; auto it = lower_bound(memo[t[d[i]]].begin(), memo[t[d[i]]].end(), d[i]); auto it1 = it - 1; auto it2 = it + 1; long int x = ans[k] - (d[i] - *it1) * (*it2 - d[i]) * c[t[d[i]]]; memo[t[d[i]]].erase(it); auto ite = lower_bound(memo[q[i]].begin(), memo[q[i]].end(), d[i]); auto ite1 = ite - 1; x += (*ite - d[i]) * (d[i] - *ite1) * c[q[i]]; memo[q[i]].insert(ite, q[i]); x += s[d[i]][q[i]] - s[d[i]][t[d[i]]]; k++; ans.push_back(x); t[d[i]] = q[i]; } for (size_t i = 1; i < ans.size(); i++) cout << ans[i] << endl; return 0; }
#include <algorithm> #include <cmath> #include <ctime> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) // #include <bits/stdc++.h> using namespace std; int main() { int D; cin >> D; vector<long int> c(26); vector<vector<long int>> s(D, vector<long int>(26)); for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 0; i < D; i++) { for (int j = 0; j < 26; j++) cin >> s[i][j]; } vector<int> t(D, -1); vector<vector<int>> memo(26); vector<int> memo2(26, -1); vector<long int> ans; long int ans2 = 0; for (int i = 0; i < 26; i++) memo[i].push_back(-1); for (int i = 0; i < D; i++) { cin >> t[i]; t[i]--; memo[t[i]].push_back(i); memo2[t[i]] = i; ans2 += s[i][t[i]]; for (int j = 0; j < 26; j++) { ans2 -= c[j] * (i - memo2[j]); } } for (int i = 0; i < 26; i++) memo[i].push_back(D); ans.push_back(ans2); int M; cin >> M; int k = 0; vector<int> d(M), q(M); for (int i = 0; i < M; i++) { cin >> d[i] >> q[i]; d[i]--; q[i]--; auto it = lower_bound(memo[t[d[i]]].begin(), memo[t[d[i]]].end(), d[i]); auto it1 = it - 1; auto it2 = it + 1; long int x = ans[k] - (d[i] - *it1) * (*it2 - d[i]) * c[t[d[i]]]; memo[t[d[i]]].erase(it); auto ite = lower_bound(memo[q[i]].begin(), memo[q[i]].end(), d[i]); auto ite1 = ite - 1; x += (*ite - d[i]) * (d[i] - *ite1) * c[q[i]]; memo[q[i]].insert(ite, d[i]); x += s[d[i]][q[i]] - s[d[i]][t[d[i]]]; k++; ans.push_back(x); t[d[i]] = q[i]; } for (size_t i = 1; i < ans.size(); i++) cout << ans[i] << endl; return 0; }
replace
62
63
62
63
0
p02620
C++
Runtime Error
#include <algorithm> #include <array> #include <cmath> #include <iostream> #include <set> #include <vector> // const uint32_t D = 365 + 1; const uint32_t D = 5 + 1; const uint32_t contests = 26 + 1; int main() { { uint32_t Dtmp = 0; std::cin >> Dtmp; } std::array<uint32_t, contests> cost; for (size_t c = 1; c < contests; c++) std::cin >> cost[c]; std::array<std::array<uint32_t, contests>, D> sat; for (size_t d = 1; d < D; d++) for (size_t c = 1; c < contests; c++) std::cin >> sat[d][c]; // solve problem std::array<uint32_t, D> test; for (size_t d = 1; d < D; d++) std::cin >> test[d]; // for (size_t d = 1; d < D; d++) // { // uint32_t max_val = 0, max_ind = 0; // for (size_t c = 1; c < contests; c++){ // if(sat[d][c] > max_val){ // max_val = sat[d][c]; // max_ind = i; // } // } // test[d] = max_ind + 1; // } // for(size_t d = 1; d < D; d++) std::cout << test[d] << std::endl; // calc satisfaction std::array<int64_t, D> value; value[0] = 0; std::array<std::set<uint32_t>, contests> history; for (auto &&h : history) h.insert(0), h.insert(D); for (size_t d = 1; d < D; d++) { value[d] = value[d - 1] + sat[d][test[d]]; history[test[d]].insert(d); int64_t c_sum = 0; for (size_t c = 1; c < contests; c++) c_sum += cost[c] * (d - *std::next(history[c].crbegin())); value[d] -= c_sum; } // query int64_t v = value.back(); uint32_t M = 0; std::cin >> M; for (size_t m = 0; m < M; m++) { uint32_t d = 0, c = 0; std::cin >> d >> c; v += sat[d][c]; v -= sat[d][test[d]]; auto it_before = history[test[d]].find(d); v -= cost[test[d]] * (d - *std::prev(it_before)) * (*std::next(it_before) - d); history[test[d]].erase(it_before); history[c].insert(d); auto it_after = history[c].find(d); v += cost[c] * (d - *std::prev(it_after)) * (*std::next(it_after) - d); test[d] = c; std::cout << v << std::endl; } return 0; }
#include <algorithm> #include <array> #include <cmath> #include <iostream> #include <set> #include <vector> const uint32_t D = 365 + 1; const uint32_t contests = 26 + 1; int main() { { uint32_t Dtmp = 0; std::cin >> Dtmp; } std::array<uint32_t, contests> cost; for (size_t c = 1; c < contests; c++) std::cin >> cost[c]; std::array<std::array<uint32_t, contests>, D> sat; for (size_t d = 1; d < D; d++) for (size_t c = 1; c < contests; c++) std::cin >> sat[d][c]; // solve problem std::array<uint32_t, D> test; for (size_t d = 1; d < D; d++) std::cin >> test[d]; // for (size_t d = 1; d < D; d++) // { // uint32_t max_val = 0, max_ind = 0; // for (size_t c = 1; c < contests; c++){ // if(sat[d][c] > max_val){ // max_val = sat[d][c]; // max_ind = i; // } // } // test[d] = max_ind + 1; // } // for(size_t d = 1; d < D; d++) std::cout << test[d] << std::endl; // calc satisfaction std::array<int64_t, D> value; value[0] = 0; std::array<std::set<uint32_t>, contests> history; for (auto &&h : history) h.insert(0), h.insert(D); for (size_t d = 1; d < D; d++) { value[d] = value[d - 1] + sat[d][test[d]]; history[test[d]].insert(d); int64_t c_sum = 0; for (size_t c = 1; c < contests; c++) c_sum += cost[c] * (d - *std::next(history[c].crbegin())); value[d] -= c_sum; } // query int64_t v = value.back(); uint32_t M = 0; std::cin >> M; for (size_t m = 0; m < M; m++) { uint32_t d = 0, c = 0; std::cin >> d >> c; v += sat[d][c]; v -= sat[d][test[d]]; auto it_before = history[test[d]].find(d); v -= cost[test[d]] * (d - *std::prev(it_before)) * (*std::next(it_before) - d); history[test[d]].erase(it_before); history[c].insert(d); auto it_after = history[c].find(d); v += cost[c] * (d - *std::prev(it_after)) * (*std::next(it_after) - d); test[d] = c; std::cout << v << std::endl; } return 0; }
replace
7
9
7
8
0
p02620
C++
Runtime Error
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> //memset(dp,0,sizeof(dp)) #include <functional> #include <iomanip> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() using namespace std; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } typedef pair<int, int> P; typedef pair<long long, long long> Pll; #define fout(num) cout << fixed << setprecision(20) << (num) << endl // s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ // vector<vector<ll>> dp(n,vector<ll>(n)) // exist x map o set int D; ll c[26]; ll s[365][26]; void input() { scanf("%d", &D); for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 0; i < D; i++) for (int j = 0; j < 26; j++) cin >> s[i][j]; } signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); input(); vector<int> last(26, 0); vector<ll> ans(D); set<ll> day[26]; rep(i, 26) day[i].insert(0); ll score = 0; rep(i, D) { cin >> ans[i]; ans[i]--; last[ans[i]] = i + 1; score += s[i][ans[i]]; rep(j, 26) { score -= c[j] * (i + 1 - last[j]); } day[ans[i]].insert(i + 1); } rep(i, 26) day[i].insert(D + 1); int m; cin >> m; while (m--) { ll d, q; cin >> d >> q; q--; ll p = ans[d - 1]; ans[d - 1] = q; score += (s[d - 1][q] - s[d - 1][p]); ll prev = 0, nxt = D + 1; for (ll u : day[p]) { if (u < d) chmax(prev, u); else if (u > d) chmin(nxt, u); } score -= c[p] * (d - prev) * (nxt - d); day[p].erase(d); prev = 0, nxt = D + 1; for (ll u : day[q]) { if (u < d) chmax(prev, u); else if (u > d) chmin(nxt, u); } score += c[q] * (d - prev) * (nxt - d); day[q].insert(d); cout << score << endl; } }
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> //memset(dp,0,sizeof(dp)) #include <functional> #include <iomanip> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() using namespace std; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } typedef pair<int, int> P; typedef pair<long long, long long> Pll; #define fout(num) cout << fixed << setprecision(20) << (num) << endl // s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ // vector<vector<ll>> dp(n,vector<ll>(n)) // exist x map o set int D; ll c[26]; ll s[365][26]; void input() { cin >> D; for (int i = 0; i < 26; i++) cin >> c[i]; for (int i = 0; i < D; i++) for (int j = 0; j < 26; j++) cin >> s[i][j]; } signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); input(); vector<int> last(26, 0); vector<ll> ans(D); set<ll> day[26]; rep(i, 26) day[i].insert(0); ll score = 0; rep(i, D) { cin >> ans[i]; ans[i]--; last[ans[i]] = i + 1; score += s[i][ans[i]]; rep(j, 26) { score -= c[j] * (i + 1 - last[j]); } day[ans[i]].insert(i + 1); } rep(i, 26) day[i].insert(D + 1); int m; cin >> m; while (m--) { ll d, q; cin >> d >> q; q--; ll p = ans[d - 1]; ans[d - 1] = q; score += (s[d - 1][q] - s[d - 1][p]); ll prev = 0, nxt = D + 1; for (ll u : day[p]) { if (u < d) chmax(prev, u); else if (u > d) chmin(nxt, u); } score -= c[p] * (d - prev) * (nxt - d); day[p].erase(d); prev = 0, nxt = D + 1; for (ll u : day[q]) { if (u < d) chmax(prev, u); else if (u > d) chmin(nxt, u); } score += c[q] * (d - prev) * (nxt - d); day[q].insert(d); cout << score << endl; } }
replace
41
42
41
42
-11
p02621
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(void) { int a; cin >> a; cout << a * (a * a * a - 1) / (a - 1) << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(void) { int a; cin >> a; int temp = 1; int ans = 0; for (int i = 0; i < 3; i++) { temp *= a; ans += temp; } cout << ans << endl; }
replace
9
10
9
16
0
p02621
C++
Runtime Error
#include <bits/stdc++.h> typedef long long ll; typedef long double lld; using namespace std; #define endl "\n" #define fi first #define se second #define MEMS(a, b) memset(a, b, sizeof(a)) #define _ \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define __ \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define all(c) c.begin(), c.end() #define pii pair<int, int> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } #define tr(...) \ cout << __FUNCTION__ << ' ' << __LINE__ << " = "; \ trace(#__VA_ARGS__, __VA_ARGS__) template <typename S, typename T> ostream &operator<<(ostream &out, pair<S, T> const &p) { out << '(' << p.fi << ", " << p.se << ')'; return out; } template <typename T> ostream &operator<<(ostream &out, vector<T> const &v) { ll l = v.size(); for (ll i = 0; i < l - 1; i++) out << v[i] << ' '; if (l > 0) out << v[l - 1]; return out; } template <typename T> ostream &operator<<(ostream &out, set<T> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << (*i) << ' '; return out; } template <typename T> ostream &operator<<(ostream &out, multiset<T> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << (*i) << ' '; return out; } template <typename T, typename V> ostream &operator<<(ostream &out, map<T, V> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << "\n" << (i->first) << ":" << (i->second); return out; } template <typename T> void trace(const char *name, T &&arg1) { cout << name << " : " << arg1 << endl; } template <typename T, typename... Args> void trace(const char *names, T &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; trace(comma + 1, args...); } #define int ll int solve() { int a; cin >> a; cout << a + a * a + a * a * a << endl; } int32_t main() { _ int t; // cin >> t; t = 1; while (t--) solve(); return EXIT_SUCCESS; }
#include <bits/stdc++.h> typedef long long ll; typedef long double lld; using namespace std; #define endl "\n" #define fi first #define se second #define MEMS(a, b) memset(a, b, sizeof(a)) #define _ \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define __ \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define all(c) c.begin(), c.end() #define pii pair<int, int> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } #define tr(...) \ cout << __FUNCTION__ << ' ' << __LINE__ << " = "; \ trace(#__VA_ARGS__, __VA_ARGS__) template <typename S, typename T> ostream &operator<<(ostream &out, pair<S, T> const &p) { out << '(' << p.fi << ", " << p.se << ')'; return out; } template <typename T> ostream &operator<<(ostream &out, vector<T> const &v) { ll l = v.size(); for (ll i = 0; i < l - 1; i++) out << v[i] << ' '; if (l > 0) out << v[l - 1]; return out; } template <typename T> ostream &operator<<(ostream &out, set<T> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << (*i) << ' '; return out; } template <typename T> ostream &operator<<(ostream &out, multiset<T> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << (*i) << ' '; return out; } template <typename T, typename V> ostream &operator<<(ostream &out, map<T, V> const &v) { for (auto i = v.begin(); i != v.end(); i++) out << "\n" << (i->first) << ":" << (i->second); return out; } template <typename T> void trace(const char *name, T &&arg1) { cout << name << " : " << arg1 << endl; } template <typename T, typename... Args> void trace(const char *names, T &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; trace(comma + 1, args...); } #define int ll int solve() { int a; cin >> a; cout << a + a * a + a * a * a << endl; return 0; } int32_t main() { _ int t; // cin >> t; t = 1; while (t--) solve(); return EXIT_SUCCESS; }
insert
78
78
78
79
0
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int a; int main() { cin >> a; cout << ((a * a * a * a - 1) / (a - 1)) - 1 << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int a; int main() { cin >> a; if (a == 1) cout << "3\n"; else cout << ((a * a * a * a - 1) / (a - 1)) - 1 << "\n"; return 0; }
replace
5
6
5
9
0
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define mod (int)1000000007 #define pb push_back #define endl "\n" #define all(a) a.begin(), a.end() #define mx(a) *max_element(all(a)) #define mn(a) *min_element(all(a)) #define rep(i, a, b) for (int i = a; i < b; i++) #define repe(i, a, b) for (int i = a; i <= b; i++) #define repo(i, b) for (int i = (int)0; i < b; i++) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) signed solve() { int a; cin >> a; cout << a + a * a + a * a * a << endl; } signed main() { fast; int tests = 1; // cin>>tests; while (tests--) { solve(); } }
#include <bits/stdc++.h> using namespace std; #define int long long #define mod (int)1000000007 #define pb push_back #define endl "\n" #define all(a) a.begin(), a.end() #define mx(a) *max_element(all(a)) #define mn(a) *min_element(all(a)) #define rep(i, a, b) for (int i = a; i < b; i++) #define repe(i, a, b) for (int i = a; i <= b; i++) #define repo(i, b) for (int i = (int)0; i < b; i++) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) signed solve() { int a; cin >> a; cout << a + a * a + a * a * a << endl; return 0; } signed main() { fast; int tests = 1; // cin>>tests; while (tests--) { solve(); } }
insert
21
21
21
22
0
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int sum(int a) { int Tong = 0; while (a >= 1 && a <= 10) { for (int i = 1; i <= 3; ++i) { Tong += pow(a, i); } cout << Tong; break; } } int main() { int a; cin >> a; sum(a); return 0; }
#include <bits/stdc++.h> using namespace std; int sum(int a) { int Tong = 0; while (a >= 1 && a <= 10) { for (int i = 1; i <= 3; ++i) { Tong += pow(a, i); } cout << Tong; break; } return 0; } int main() { int a; cin >> a; sum(a); return 0; }
insert
12
12
12
13
0
p02621
C++
Runtime Error
#include <math.h> #include <stdio.h> using namespace std; int main() { int a; scanf("%d", a); int ans = a + (a * a) + (a * a * a); printf("%d", ans); return 0; }
#include <math.h> #include <stdio.h> using namespace std; int main() { int a; scanf("%d", &a); int ans = a + (a * a) + (a * a * a); printf("%d", ans); return 0; }
replace
6
7
6
7
-11
p02621
C++
Memory Limit Exceeded
#include <bits/stdc++.h> #define ll long long int using namespace std; #define mod 1000000007 long long int fastexpo(long long int a, long long int b) { long long int ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; b = b / 2; a = (a * a) % mod; } return ans; } bool vis[500000000] = {0}; bool child[50000000] = {0}; vector<int> vec[50000000]; int ans = 1; int bfs(int node) { queue<int> qu; qu.push(node); while (!qu.empty()) { int t = qu.front(); vis[t] = 1; qu.pop(); // cout << t << "\n"; for (int i = 0; i < vec[t].size(); i++) { if (child[t]) if (!vis[vec[t][i]]) { qu.push(vec[t][i]); vis[vec[t][i]] = 1; // child[vec[t][i]] = 1; ans++; } if (!child[t]) { if (!vis[vec[t][i]]) { qu.push(vec[t][i]); vis[vec[t][i]] = 1; child[vec[t][i]] = 1; // ans++; } } } } return ans; } int main() { int a; string str; cin >> a; cout << a + a * a + a * a * a << "\n"; return 0; }
#include <bits/stdc++.h> #define ll long long int using namespace std; #define mod 1000000007 int main() { int a; string str; cin >> a; cout << a + a * a + a * a * a << "\n"; return 0; }
delete
4
47
4
4
MLE
p02621
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; int main() { ll a; cin >> a; return a + (a * a) + (a * a * a); }
#include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; int main() { ll a; cin >> a; cout << a + (a * a) + (a * a * a) << endl; }
replace
8
9
8
9
14
p02621
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int a; cin >> a; cout << a + a * a + a * a * a; return 1; }
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int a; cin >> a; cout << a + a * a + a * a * a; return 0; }
replace
9
10
9
10
1
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; return (a + a * a + a * a * a); }
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; cout << (a + a * a + a * a * a) << endl; }
replace
6
7
6
7
14
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, s, n) for (int i = (s); i < (n); i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (int i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front const int mod = 1e9 + 7; const int INF = 1e9; const double pi = acos(-1.0); typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; int main() { int a; cin >> a; cout << a * (1 - a * a * a) / (1 - a) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, s, n) for (int i = (s); i < (n); i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (int i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front const int mod = 1e9 + 7; const int INF = 1e9; const double pi = acos(-1.0); typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; int main() { int a; cin >> a; cout << a + a * a + a * a * a << endl; return 0; }
replace
19
20
19
20
0
p02621
C++
Runtime Error
#include <iostream> using namespace std; int a; int main() { cin >> a; int s = 0; for (int i = 0; i < a; i++) s = s + a + 1 + a * a; return s; }
#include <iostream> using namespace std; int a; int main() { cin >> a; cout << a + a * a + a * a * a << endl; return 0; }
replace
7
11
7
9
14
p02621
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { string s, t; cin >> s >> t; ll n; cin >> n; vector<ll> a(n, 0); rep1(i, n) cin >> a[i]; ll ans = 0; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { ll a; cin >> a; ll ans = a + a * a + a * a * a; cout << ans << endl; }
replace
23
30
23
26
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p02621
Python
Time Limit Exceeded
N = 10**7 def f(x): return x M = 10**5 arr = list(range(M)) for i in range(N): t = (i + i * i - i) % M # 四則演算 b = arr[t] # 配列ランダムアクセス b = f(b) # 関数呼び出し # 答え a = int(input()) print(a + a**2 + a**3)
N = 10**6 def f(x): return x M = 10**5 arr = list(range(M)) for i in range(N): t = (i + i * i - i) % M # 四則演算 b = arr[t] # 配列ランダムアクセス b = f(b) # 関数呼び出し # 答え a = int(input()) print(a + a**2 + a**3)
replace
0
1
0
1
TLE
p02621
Python
Time Limit Exceeded
N = 10**9 def f(x): return x M = 10**5 arr = list(range(M)) for i in range(N): t = (i + i * i - i) % M # 四則演算 b = arr[t] # 配列ランダムアクセス b = f(b) # 関数呼び出し # 答え a = int(input()) print(a + a**2 + a**3)
N = 5 * 10**8 def f(x): return x M = 10**5 arr = list(range(M)) for i in range(N): t = (i + i * i - i) % M # 四則演算 b = arr[t] # 配列ランダムアクセス b = f(b) # 関数呼び出し # 答え a = int(input()) print(a + a**2 + a**3)
replace
0
1
0
1
TLE
p02621
Python
Runtime Error
a = input() print(a + a**2 + a**3)
a = int(input()) print(a + a**2 + a**3)
replace
0
1
0
1
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02621/Python/s078567518.py", line 2, in <module> print(a + a**2 + a**3) TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
p02621
C++
Runtime Error
#include <iostream> using namespace std; int main() { int a, b, c = 0; cin >> a; b = a * a; c = a * a * a; return a + b + c; }
#include <iostream> using namespace std; int main() { int a, b, c = 0; cin >> a; b = a * a; c = a * a * a; cout << a + b + c; return 0; }
replace
7
9
7
9
14
p02622
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main() { int count = 0; unsigned char n; string s, t; cin >> s >> t; for (n = 0; n < s.size(); n++) { if (s[n] != t[n]) { s[n] = t[n]; count++; } } cout << count << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int count = 0; unsigned int n; string s, t; cin >> s >> t; for (n = 0; n < s.size(); n++) { if (s[n] != t[n]) { s[n] = t[n]; count++; } } cout << count << endl; return 0; }
replace
6
7
6
7
TLE
p02622
C++
Runtime Error
#include <iostream> using namespace std; int main() { char s[200000], t[200000]; cin >> s >> t; int i = 0, c = 0; while (s[i] != 0) { if (s[i] != t[i]) { s[i] = t[i]; c++; } i++; } cout << c << endl; }
#include <iostream> using namespace std; int main() { string s, t; cin >> s >> t; int i = 0, c = 0; while (s[i] != 0) { if (s[i] != t[i]) { s[i] = t[i]; c++; } i++; } cout << c << endl; }
replace
4
5
4
6
0
p02622
C++
Runtime Error
#include <iostream> using namespace std; int main() { char s[200000], t[200000]; int ct = 0; cin >> s; cin >> t; for (int i = 0; s[i] != '\0'; i++) { ct += (s[i] != t[i]); } cout << ct << endl; return 0; }
#include <iostream> using namespace std; int main() { char s[200001], t[200001]; int ct = 0; cin >> s; cin >> t; for (int i = 0; s[i] != '\0'; i++) { ct += (s[i] != t[i]); } cout << ct << endl; return 0; }
replace
4
5
4
5
0
p02622
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; int cnt = 0; int x = s.size(); for (int i = 0; i < x; i++) { if (s.at(i) != t.at(i)) { for (int j = 0; j < x; j++) { if (s.at(j) == s.at(i)) { s.at(j) = t.at(i); } } cnt++; } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; int cnt = 0; int x = s.size(); for (int i = 0; i < x; i++) { if (s.at(i) != t.at(i)) { cnt++; } } cout << cnt << endl; return 0; }
delete
10
15
10
10
TLE
p02622
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s, a; int o = 0; cin >> s >> a; for (int i = 0; i < s.length(); i++) for (int j = 0; j < a.length(); j++) if (s[i] != a[j] && i == j) o++; cout << o; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, a; int o = 0; cin >> s >> a; for (int i = 0; i < s.length(); i++) { if (s[i] != a[i]) { o++; } } cout << o; return 0; }
replace
6
10
6
11
TLE
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { char s[200000]; char t[200000]; cin >> s >> t; int ans = 0; int size = strlen(s); for (int i = 0; i < size; i++) { if (s[i] != t[i]) { ans += 1; } else { continue; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char s[2000000]; char t[2000000]; cin >> s >> t; int ans = 0; int size = strlen(s); for (int i = 0; i < size; i++) { if (s[i] != t[i]) { ans += 1; } else { continue; } } cout << ans << endl; return 0; }
replace
4
6
4
6
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #include <istream> #include <vector> #define rep(I, N) for (int I = 0; I < N; I++) using ll = long long int; using namespace std; int main() { int N = 0; char s[200000], t[200000]; vector<char> ss(0); vector<char> tt(0); cin >> s; cin >> t; string S = s; rep(i, S.size()) { if (!(s[i] == t[i])) N++; } cout << N; }
#include <bits/stdc++.h> #include <istream> #include <vector> #define rep(I, N) for (int I = 0; I < N; I++) using ll = long long int; using namespace std; int main() { ll N = 0; char s[2000000], t[2000000]; cin >> s; cin >> t; string S = s; rep(i, S.size()) { if (!(s[i] == t[i])) N++; } cout << N; }
replace
8
12
8
10
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { char s[100006], t[100006]; cin >> s >> t; int l, c = 0, i; l = strlen(s); for (i = 0; i < l; i++) { if (s[i] != t[i]) c++; } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { char s[200006], t[200006]; cin >> s >> t; int l, c = 0, i; l = strlen(s); for (i = 0; i < l; i++) { if (s[i] != t[i]) c++; } cout << c << endl; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <iostream> #include <string> using namespace std; int main() { string s, t; int num = 0; cin >> s, t; for (int i = 0; i < (int)s.size(); ++i) { if (s[i] != t[i]) { num++; } } cout << num; }
#include <iostream> #include <string> using namespace std; int main() { string s, t; int num = 0; cin >> s >> t; for (int i = 0; i < (int)s.size(); ++i) { if (s[i] != t[i]) { num++; } } cout << num; }
replace
8
9
8
9
0
p02622
C++
Runtime Error
#include <iostream> using namespace std; int main() { char S[200000], T[200000]; int ans = 0, j = 0; cin >> S >> T; while (S[j] != '\0') { j++; } for (int i = 0; i < j; i++) { if (S[i] != T[i]) ans++; } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { char S[200001], T[200001]; int ans = 0, j = 0; cin >> S >> T; while (S[j] != '\0') { j++; } for (int i = 0; i < j; i++) { if (S[i] != T[i]) ans++; } cout << ans << endl; return 0; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i, n) for (i = 0; i < n; i++) #define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1) #define ll long long #define si(x) scanf("%d", &x) #define sl(x) scanf("%lld", &x) #define sc(x) scanf("%c", &x); #define ss(s) scanf("%s", &s) #define pi(x) printf("%d\n", x) #define pl(x) printf("%lld\n", x) #define ps(s) printf("%s\n", s) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) #define PI 3.1415926535897932384626 typedef pair<int, int> pii; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pl> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; int mpow(int base, int exp); bool isprime(ll n); const int mod = 1000000007; const int N = 3e5, M = N; //===================================================== // vi g[N]; // int a[N]; void solve() { int ans = 0, i; string s, w; ss(s); ss(w); fo(i, s.length()) { if (s[i] != w[i]) ++ans; } cout << (ans); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; } bool isprime(ll n) { if (n <= 1) return false; if (n == 2) return true; if (n % 2 == 0) return false; ll rt = sqrt(n); for (ll i = 3; i < rt; i += 2) { if (n % i == 0) return false; } return true; }
#include <bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i, n) for (i = 0; i < n; i++) #define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1) #define ll long long #define si(x) scanf("%d", &x) #define sl(x) scanf("%lld", &x) #define sc(x) scanf("%c", &x); #define ss(s) scanf("%s", &s) #define pi(x) printf("%d\n", x) #define pl(x) printf("%lld\n", x) #define ps(s) printf("%s\n", s) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) #define PI 3.1415926535897932384626 typedef pair<int, int> pii; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pl> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; int mpow(int base, int exp); bool isprime(ll n); const int mod = 1000000007; const int N = 3e5, M = N; //===================================================== // vi g[N]; // int a[N]; void solve() { int ans = 0, i; string s, w; cin >> s >> w; fo(i, s.length()) { if (s[i] != w[i]) ++ans; } cout << (ans); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; } bool isprime(ll n) { if (n <= 1) return false; if (n == 2) return true; if (n % 2 == 0) return false; ll rt = sqrt(n); for (ll i = 3; i < rt; i += 2) { if (n % i == 0) return false; } return true; }
replace
46
48
46
47
-11
p02622
C++
Runtime Error
#include <iostream> using namespace std; int main() { string S; string T; cin >> S >> T; int ans = 0; for (long long int i = 0; i < 2 * 10000; i++) { if (S[i] != T[i]) { ans += 1; } } cout << ans << endl; }
#include <iostream> using namespace std; int main() { string S; string T; cin >> S >> T; int ans = 0; int N = S.size(); for (long long int i = 0; i < N; i++) { if (S[i] != T[i]) { ans += 1; } } cout << ans << endl; }
replace
7
8
7
9
-11
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, ans; char s[10005], t[10005]; int main() { scanf("%s%s", s + 1, t + 1); n = strlen(s + 1); for (i = 1; i <= n; i++) { if (s[i] != t[i]) ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, ans; char s[1000005], t[1000005]; int main() { scanf("%s%s", s + 1, t + 1); n = strlen(s + 1); for (i = 1; i <= n; i++) { if (s[i] != t[i]) ans++; } cout << ans; return 0; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int len, i, j, cnt = 0; char s[100005], t[100005]; scanf(" %s %s", s, t); len = strlen(s); for (i = 0; i < len; i++) { if (s[i] != t[i]) cnt++; } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int leng, i, j, cnt = 0; // char s[100005],t[100005]; string s, t; // scanf(" %s %s",s,t); // leng = s.size(); // cout<<leng; cin >> s >> t; for (i = 0; i < (s.length()); i++) { if (s[i] != t[i]) cnt++; } printf("%d\n", cnt); return 0; }
replace
5
10
5
13
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1000000007; int main() { char s[20010] = {}; char t[20010] = {}; cin >> s >> t; int p = strlen(s); int ans = 0; rep(i, p) { if (s[i] != t[i]) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int mod = 1000000007; int main() { char s[2 * 100000 + 1] = {}; char t[2 * 100000 + 1] = {}; cin >> s >> t; int p = strlen(s); int ans = 0; rep(i, p) { if (s[i] != t[i]) { ans++; } } cout << ans << endl; }
replace
7
9
7
9
0
p02622
C++
Runtime Error
#include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { char M[100020], R[100010]; int count = 0, i = 0; cin >> M >> R; // cout << M << ' ' << R; while (M[i] != NULL) { if (M[i] != R[i]) { count++; } i++; } cout << count << endl; }
#include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { char M[200020], R[200010]; int count = 0, i = 0; cin >> M >> R; // cout << M << ' ' << R; while (M[i] != NULL) { if (M[i] != R[i]) { count++; } i++; } cout << count << endl; }
replace
5
6
5
6
0
p02622
C++
Runtime Error
#include <cstring> #include <iostream> #include <stdio.h> #define N 100005 using namespace std; char s[N], t[N]; int n, i, ans; int main() { scanf("%s\n%s", s, t); n = strlen(s); for (i = 0; i < n; i++) { if (s[i] != t[i]) ans++; } printf("%d", ans); return 0; }
#include <cstring> #include <iostream> #include <stdio.h> #define N 200005 using namespace std; char s[N], t[N]; int n, i, ans; int main() { scanf("%s\n%s", s, t); n = strlen(s); for (i = 0; i < n; i++) { if (s[i] != t[i]) ans++; } printf("%d", ans); return 0; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <stdio.h> int main(void) { char s[20001], t[20001]; int i, cnt = 0; scanf("%s", s); scanf("%s", t); for (i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) cnt++; } printf("%d", cnt); return 0; }
#include <stdio.h> int main(void) { char s[200001], t[200001]; int i, cnt = 0; scanf("%s", s); scanf("%s", t); for (i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) cnt++; } printf("%d", cnt); return 0; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #define endl "\n" #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #define all(c) c.begin(), c.end() #define mp(x, y) make_pair(x, y) #define mem(a, val) memset(a, val, sizeof(a)) #define eb emplace_back #define f first #define s second #define pb push_back using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); char arr1[10000]; char arr2[10000]; cin >> arr1 >> arr2; ll sum = 0; for (int i = 0; i < strlen(arr1); ++i) { if (arr1[i] != arr2[i]) sum++; } cout << sum; return 0; }
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #define endl "\n" #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define pii pair<int, int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #define all(c) c.begin(), c.end() #define mp(x, y) make_pair(x, y) #define mem(a, val) memset(a, val, sizeof(a)) #define eb emplace_back #define f first #define s second #define pb push_back using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); char arr1[1000000]; char arr2[1000000]; cin >> arr1 >> arr2; ll sum = 0; for (int i = 0; i < strlen(arr1); ++i) { if (arr1[i] != arr2[i]) sum++; } cout << sum; return 0; }
replace
29
31
29
31
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define x first #define y second #define getbit(x, i) (((x) >> (i)) & 1) using namespace std; typedef pair<int, int> pii; #define hashset unordered_set #define hashmap unordered_map #define newline fast_writechar('\n') #define unify(arr) arr.resize(unique(arr.begin(), arr.end()) - arr.begin()) #define getbit(x, i) (((x) >> (i)) & 1) template <typename T> vector<T> readvector(size_t sz) { vector<T> res(sz); for (size_t i = 0; i < sz; ++i) { cin >> res[i]; } return res; } template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " ")); return out; } int mylog(int n) { return 63 - __builtin_clzll(n); } inline int binPow(int x, int deg, int mod) { int ans = 1; for (int i = sizeof(deg) * CHAR_BIT - 1; i >= 0; i--) { ans *= ans; ans %= mod; if (getbit(deg, i)) ans *= x; ans %= mod; } return ans; } /** Interface */ inline int readInt(); inline int readUInt(); inline void readWord(char *s); inline int fast_readchar(); // you may use readchar() instead of it inline void writeInt(int x); inline void fast_writechar(int x); // you may use putchar() instead of it inline void writeWord(const char *s); inline void fast_flush(); // ====================== END ====================== const int MAXN = 5e5 + 10; const int MOD = 1e9 + 7; const int INF = 1e18; int tree[MAXN * 4]; int get(int v, int tl, int tr, int l, int r) { if (r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return tree[v]; int tm = (tl + tr) / 2; return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm, tr, l, r); } void update(int v, int tl, int tr, int pos, int mod) { if (pos < tl || tr <= pos) return; tree[v] += mod; if (tl + 1 == tr) return; int tm = (tl + tr) / 2; update(v * 2, tl, tm, pos, mod); update(v * 2 + 1, tm, tr, pos, mod); } void solve() { string s, t; cin >> s >> t; int cnt = 0; cout << accumulate(s.begin(), s.end(), 0ll, [s, t](const int a, const char &b) { return a + (b != t[&b - &s[0]]); }) << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; // t = readInt(); // cin >> t; for (int i = 1; i <= t; ++i) { // cout << "Case #" << i << ": "; solve(); } // fast_flush(); return 0; } /** Read */ static const int buf_size = 4096; inline int fast_readchar() { static char buf[buf_size]; static int len = 0, pos = 0; if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin); if (pos == len) return -1; return buf[pos++]; } inline int readUInt() { int c = fast_readchar(), x = 0; while (c <= 32) c = fast_readchar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = fast_readchar(); return x; } inline int readInt() { int s = 1, c = fast_readchar(); int x = 0; while (c <= 32) c = fast_readchar(); if (c == '-') s = -1, c = fast_readchar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = fast_readchar(); return x * s; } inline void readWord(char *s) { int c = fast_readchar(); while (c <= 32) c = fast_readchar(); while (c > 32) *s++ = c, c = fast_readchar(); *s = 0; } /** Write */ static int write_pos = 0; static char write_buf[buf_size]; inline void fast_writechar(int x) { if (write_pos == buf_size) fwrite(write_buf, 1, buf_size, stdout), write_pos = 0; write_buf[write_pos++] = x; } inline void fast_flush() { if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0; } inline void writeInt(int x) { if (x < 0) fast_writechar('-'), x = -x; char s[24]; int n = 0; while (x || !n) s[n++] = '0' + x % 10, x /= 10; while (n--) fast_writechar(s[n]); } inline void writeWord(const char *s) { while (*s) fast_writechar(*s++); }
#include <bits/stdc++.h> #define int long long #define x first #define y second #define getbit(x, i) (((x) >> (i)) & 1) using namespace std; typedef pair<int, int> pii; #define hashset unordered_set #define hashmap unordered_map #define newline fast_writechar('\n') #define unify(arr) arr.resize(unique(arr.begin(), arr.end()) - arr.begin()) #define getbit(x, i) (((x) >> (i)) & 1) template <typename T> vector<T> readvector(size_t sz) { vector<T> res(sz); for (size_t i = 0; i < sz; ++i) { cin >> res[i]; } return res; } template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " ")); return out; } int mylog(int n) { return 63 - __builtin_clzll(n); } inline int binPow(int x, int deg, int mod) { int ans = 1; for (int i = sizeof(deg) * CHAR_BIT - 1; i >= 0; i--) { ans *= ans; ans %= mod; if (getbit(deg, i)) ans *= x; ans %= mod; } return ans; } /** Interface */ inline int readInt(); inline int readUInt(); inline void readWord(char *s); inline int fast_readchar(); // you may use readchar() instead of it inline void writeInt(int x); inline void fast_writechar(int x); // you may use putchar() instead of it inline void writeWord(const char *s); inline void fast_flush(); // ====================== END ====================== const int MAXN = 5e5 + 10; const int MOD = 1e9 + 7; const int INF = 1e18; int tree[MAXN * 4]; int get(int v, int tl, int tr, int l, int r) { if (r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return tree[v]; int tm = (tl + tr) / 2; return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm, tr, l, r); } void update(int v, int tl, int tr, int pos, int mod) { if (pos < tl || tr <= pos) return; tree[v] += mod; if (tl + 1 == tr) return; int tm = (tl + tr) / 2; update(v * 2, tl, tm, pos, mod); update(v * 2 + 1, tm, tr, pos, mod); } void solve() { string s, t; cin >> s >> t; int cnt = 0; for (int i = 0; i < s.size(); i++) { cnt += (s[i] != t[i]); } cout << cnt << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; // t = readInt(); // cin >> t; for (int i = 1; i <= t; ++i) { // cout << "Case #" << i << ": "; solve(); } // fast_flush(); return 0; } /** Read */ static const int buf_size = 4096; inline int fast_readchar() { static char buf[buf_size]; static int len = 0, pos = 0; if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin); if (pos == len) return -1; return buf[pos++]; } inline int readUInt() { int c = fast_readchar(), x = 0; while (c <= 32) c = fast_readchar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = fast_readchar(); return x; } inline int readInt() { int s = 1, c = fast_readchar(); int x = 0; while (c <= 32) c = fast_readchar(); if (c == '-') s = -1, c = fast_readchar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = fast_readchar(); return x * s; } inline void readWord(char *s) { int c = fast_readchar(); while (c <= 32) c = fast_readchar(); while (c > 32) *s++ = c, c = fast_readchar(); *s = 0; } /** Write */ static int write_pos = 0; static char write_buf[buf_size]; inline void fast_writechar(int x) { if (write_pos == buf_size) fwrite(write_buf, 1, buf_size, stdout), write_pos = 0; write_buf[write_pos++] = x; } inline void fast_flush() { if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0; } inline void writeInt(int x) { if (x < 0) fast_writechar('-'), x = -x; char s[24]; int n = 0; while (x || !n) s[n++] = '0' + x % 10, x /= 10; while (n--) fast_writechar(s[n]); } inline void writeWord(const char *s) { while (*s) fast_writechar(*s++); }
replace
83
88
83
87
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int ans = 0; char a[20000], b[20000]; int main() { for (int i = 0;; i++) { a[i] = getchar(); if (a[i] == '\n') { break; } } for (int i = 0;; i++) { b[i] = getchar(); if (a[i] == '\n') { break; } } int len = strlen(a); for (int i = 0; i < len; i++) { if (a[i] != b[i]) { ans++; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int ans = 0; char a[200005], b[200005]; int main() { for (int i = 0;; i++) { a[i] = getchar(); if (a[i] == '\n') { break; } } for (int i = 0;; i++) { b[i] = getchar(); if (a[i] == '\n') { break; } } int len = strlen(a); for (int i = 0; i < len; i++) { if (a[i] != b[i]) { ans++; } } cout << ans; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <string> using namespace std; int main() { long long int a, b, c, d, i, x[100000], y = 0; char s[100000], z[100000]; cin >> s >> z; for (i = 0; s[i]; i++) { if (s[i] != z[i]) { y++; } } cout << y << endl; }
#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <string> using namespace std; int main() { long long int a, b, c, d, i, x[100000], y = 0; // char s[100000],z[100000]; string s, z; cin >> s >> z; for (i = 0; s[i]; i++) { if (s[i] != z[i]) { y++; } } cout << y << endl; }
replace
8
9
8
10
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef double db; typedef long double ldb; typedef complex<db> cd; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<db, db> pdd; typedef pair<ldb, ldb> pldb; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<char> vc; typedef vector<string> vs; typedef vector<db> vd; typedef vector<ldb> vldb; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<pdd> vpd; typedef vector<pldb> vpldb; typedef vector<pil> vpil; typedef vector<pli> vpli; int si(); ll sl(); string ss(int); char sc(); float sf(); db sd(); ldb sld(); template <typename T> void print(T, char = '\n'); template <typename T, typename... Args> void print(T, Args...); void pi(const int &, char = '\n'); void pl(const ll &, char = '\n'); void pf(const float &, char = '\n'); void pc(const char &, char = '\n'); void pd(const db &, char = '\n'); void pld(const ldb &, char = '\n'); void ps(const string &, char = '\n'); template <typename T> void pv(const vector<T> &v, char = ' ', char = '\n'); template <typename It> void out(It begin, It end, char = ' ', char = '\n'); ll russian(ll, ll, ll); ll fastpow(ll, ll, ll); ll slowpow(ll, ll, ll); ll _gcd(ll, ll); ll _lcm(ll, ll); ll extgcd(ll, ll, ll &, ll &); ll _inv(ll, ll); const int INF = 1e9; const ll LINF = 1e18; const int N = 1e5 + 7; int main() { string s = ss(N), t = ss(N); int res = 0; for (int i = 0; i < s.size(); ++i) if (s[i] != t[i]) ++res; pi(res); return 0; } template <typename T> T scanf_t(string &&token) { T a; scanf(token.c_str(), &a); return a; } int si() { return scanf_t<int>("%d"); } ll sl() { return scanf_t<ll>("%lld"); } string ss(int n) { char T[n + 7]; scanf("%s", T); return string(T); } char sc() { return scanf_t<char>(" %c"); } float sf() { return scanf_t<float>("%f"); } db sd() { return scanf_t<db>("%lf"); } ldb sld() { return scanf_t<ldb>("%Lf"); } template <typename T> void print(T a, char sep) { string token; if (is_same<T, int>::value) token = "%d"; else if (is_same<T, ll>::value) token = "%lld"; else if (is_same<T, string>::value) token = "%s"; else if (is_same<T, char>::value) token = "%c"; else if (is_same<T, float>::value) token = "%.6f"; else if (is_same<T, db>::value) token = "%.8lf"; else if (is_same<T, ldb>::value) token = "%.10Lf"; token.push_back(sep); printf(token.c_str(), a); } template <typename T, typename... Args> void print(T first, Args... rest) { print(first, ' '); print(rest...); } void pi(const int &a, char sep) { printf("%d%c", a, sep); } void pl(const ll &a, char sep) { printf("%lld%c", a, sep); } void pf(const float &a, char sep) { printf("%.6f%c", a, sep); } void pc(const char &a, char sep) { printf("%c%c", a, sep); } void pd(const db &a, char sep) { printf("%.8lf%c", a, sep); } void pld(const ldb &a, char sep) { printf("%.12Lf%c", a, sep); } void ps(const string &a, char sep) { printf("%s%c", a.c_str(), sep); } template <typename It> void out(It begin, It end, char sep, char endl) { if (begin == end) { printf("%c", endl); return; } while (begin + 1 != end) print(*begin, sep), ++begin; if (begin != end) print(*begin, ' '), printf("%c", endl); } template <typename T> void pv(const vector<T> &v, char sep, char endl) { out(v.begin(), v.end(), sep, endl); } ll russian(ll a, ll k, ll m) { ll res = 0; while (k) { if (k & 1LL) res = (res + a) % m; a = (a + a) % m; k >>= 1LL; } return res; } ll fastpow(ll a, ll k, ll m) { ll res = 1; while (k) { if (k & 1LL) res = (res * a) % m; a = (a * a) % m; k >>= 1LL; } return res; } ll slowpow(ll a, ll k, ll m) { ll res = 1; while (k) { if (k & 1LL) res = russian(res, a, m); a = russian(a, a, m); k >>= 1LL; } return res; } ll _gcd(ll a, ll b) { while (b) swap(a %= b, b); return a; } ll _lcm(ll a, ll b) { return a / _gcd(a, b) * b; } ll extgcd(ll a, ll b, ll &k, ll &l) { if (b == 0) { k = 1; l = 0; return a; } ll res = extgcd(b, a % b, l, k); l -= a / b * k; return res; } ll _inv(ll a, ll p) { return fastpow(a, p - 2, p); }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef double db; typedef long double ldb; typedef complex<db> cd; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<db, db> pdd; typedef pair<ldb, ldb> pldb; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<char> vc; typedef vector<string> vs; typedef vector<db> vd; typedef vector<ldb> vldb; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<pdd> vpd; typedef vector<pldb> vpldb; typedef vector<pil> vpil; typedef vector<pli> vpli; int si(); ll sl(); string ss(int); char sc(); float sf(); db sd(); ldb sld(); template <typename T> void print(T, char = '\n'); template <typename T, typename... Args> void print(T, Args...); void pi(const int &, char = '\n'); void pl(const ll &, char = '\n'); void pf(const float &, char = '\n'); void pc(const char &, char = '\n'); void pd(const db &, char = '\n'); void pld(const ldb &, char = '\n'); void ps(const string &, char = '\n'); template <typename T> void pv(const vector<T> &v, char = ' ', char = '\n'); template <typename It> void out(It begin, It end, char = ' ', char = '\n'); ll russian(ll, ll, ll); ll fastpow(ll, ll, ll); ll slowpow(ll, ll, ll); ll _gcd(ll, ll); ll _lcm(ll, ll); ll extgcd(ll, ll, ll &, ll &); ll _inv(ll, ll); const int INF = 1e9; const ll LINF = 1e18; const int N = 2e5 + 7; int main() { string s = ss(N), t = ss(N); int res = 0; for (int i = 0; i < s.size(); ++i) if (s[i] != t[i]) ++res; pi(res); return 0; } template <typename T> T scanf_t(string &&token) { T a; scanf(token.c_str(), &a); return a; } int si() { return scanf_t<int>("%d"); } ll sl() { return scanf_t<ll>("%lld"); } string ss(int n) { char T[n + 7]; scanf("%s", T); return string(T); } char sc() { return scanf_t<char>(" %c"); } float sf() { return scanf_t<float>("%f"); } db sd() { return scanf_t<db>("%lf"); } ldb sld() { return scanf_t<ldb>("%Lf"); } template <typename T> void print(T a, char sep) { string token; if (is_same<T, int>::value) token = "%d"; else if (is_same<T, ll>::value) token = "%lld"; else if (is_same<T, string>::value) token = "%s"; else if (is_same<T, char>::value) token = "%c"; else if (is_same<T, float>::value) token = "%.6f"; else if (is_same<T, db>::value) token = "%.8lf"; else if (is_same<T, ldb>::value) token = "%.10Lf"; token.push_back(sep); printf(token.c_str(), a); } template <typename T, typename... Args> void print(T first, Args... rest) { print(first, ' '); print(rest...); } void pi(const int &a, char sep) { printf("%d%c", a, sep); } void pl(const ll &a, char sep) { printf("%lld%c", a, sep); } void pf(const float &a, char sep) { printf("%.6f%c", a, sep); } void pc(const char &a, char sep) { printf("%c%c", a, sep); } void pd(const db &a, char sep) { printf("%.8lf%c", a, sep); } void pld(const ldb &a, char sep) { printf("%.12Lf%c", a, sep); } void ps(const string &a, char sep) { printf("%s%c", a.c_str(), sep); } template <typename It> void out(It begin, It end, char sep, char endl) { if (begin == end) { printf("%c", endl); return; } while (begin + 1 != end) print(*begin, sep), ++begin; if (begin != end) print(*begin, ' '), printf("%c", endl); } template <typename T> void pv(const vector<T> &v, char sep, char endl) { out(v.begin(), v.end(), sep, endl); } ll russian(ll a, ll k, ll m) { ll res = 0; while (k) { if (k & 1LL) res = (res + a) % m; a = (a + a) % m; k >>= 1LL; } return res; } ll fastpow(ll a, ll k, ll m) { ll res = 1; while (k) { if (k & 1LL) res = (res * a) % m; a = (a * a) % m; k >>= 1LL; } return res; } ll slowpow(ll a, ll k, ll m) { ll res = 1; while (k) { if (k & 1LL) res = russian(res, a, m); a = russian(a, a, m); k >>= 1LL; } return res; } ll _gcd(ll a, ll b) { while (b) swap(a %= b, b); return a; } ll _lcm(ll a, ll b) { return a / _gcd(a, b) * b; } ll extgcd(ll a, ll b, ll &k, ll &l) { if (b == 0) { k = 1; l = 0; return a; } ll res = extgcd(b, a % b, l, k); l -= a / b * k; return res; } ll _inv(ll a, ll p) { return fastpow(a, p - 2, p); }
replace
64
65
64
65
0
p02622
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; using P = pair<int, int>; const int M = 100005; int main() { char S[M] = ""; char T[M] = ""; cin >> S; cin >> T; int ans = 0; rep(i, strlen(S)) { if (S[i] != T[i]) ++ans; } 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; using P = pair<int, int>; const int M = 200005; int main() { char S[M] = ""; char T[M] = ""; cin >> S; cin >> T; int ans = 0; rep(i, strlen(S)) { if (S[i] != T[i]) ++ans; } cout << ans << endl; return 0; }
replace
6
7
6
7
0
p02622
C++
Runtime Error
#include <stdio.h> #include <string.h> using namespace std; typedef long long llong; #define MAX 20001 int main() { int ans = 0; char S[MAX], T[MAX]; scanf("%s", S); scanf("%s", T); int len = strlen(S); for (int i = 0; i < len; i++) { if (S[i] != T[i]) ans++; } printf("%d\n", ans); return 0; }
#include <stdio.h> #include <string.h> using namespace std; typedef long long llong; #define MAX 200010 int main() { int ans = 0; char S[MAX], T[MAX]; scanf("%s", S); scanf("%s", T); int len = strlen(S); for (int i = 0; i < len; i++) { if (S[i] != T[i]) ans++; } printf("%d\n", ans); return 0; }
replace
6
7
6
7
0
p02622
C++
Runtime Error
#include <stdio.h> #include <string.h> int main() { char S[200000], T[200000]; long long a = 0; if (!scanf("%s %s", S, T)) return 0; for (long long i = 0; i < (long long)strlen(S); i++) { if (S[i] != T[i]) a++; } return printf("%lld\n", a), 0; }
#include <stdio.h> #include <string.h> int main() { char S[200001], T[200001]; long long a = 0; if (!scanf("%s %s", S, T)) return 0; for (long long i = 0; i < (long long)strlen(S); i++) { if (S[i] != T[i]) a++; } return printf("%lld\n", a), 0; }
replace
3
4
3
4
0
p02622
Python
Runtime Error
S = input() T = input() N = len(S) ans = 0 for i in range(N): if not S[i] == T[i]: S[i] = T[i] ans += 1 print(ans)
S = input() T = input() N = len(S) ans = 0 for i in range(N): if S[i] != T[i]: ans += 1 print(ans)
replace
5
7
5
6
TypeError: 'str' object does not support item assignment
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02622/Python/s028680665.py", line 7, in <module> S[i] = T[i] TypeError: 'str' object does not support item assignment
p02622
Python
Runtime Error
S = input() T = input() replaces = 0 for ch in range(S): if S[ch] == T[ch]: replaces += 1 print(replaces)
S = input() T = input() replaces = 0 for ch in range(len(S)): if S[ch] != T[ch]: replaces += 1 print(replaces)
replace
3
5
3
5
TypeError: 'str' object cannot be interpreted as an integer
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02622/Python/s517520692.py", line 4, in <module> for ch in range(S): TypeError: 'str' object cannot be interpreted as an integer
p02622
C++
Runtime Error
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { char txt1[200000], txt2[200000]; cin >> txt1; cin >> txt2; int count = 0; int n = strlen(txt1); int i; for (i = 0; i < n; i++) { if (txt1[i] != txt2[i]) { count++; } } cout << count; }
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { /* int a,b; cin >> a; b=a*a; b=b+b*a+a; cout << b; */ char txt1[200010], txt2[200010]; cin >> txt1; cin >> txt2; int count = 0; int n = strlen(txt1); int i; for (i = 0; i < n; i++) { if (txt1[i] != txt2[i]) { count++; } } cout << count; }
replace
5
7
5
13
0
p02622
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main(void) { string S, T; cin >> S >> T; int ans = 0; for (int i = 0; S.size(); i++) { if (S[i] != T[i]) ans++; } cout << ans << endl; }
#include <iostream> #include <string> using namespace std; int main(void) { string S, T; cin >> S >> T; int ans = 0; for (int i = 0; i < S.size(); i++) { if (S[i] != T[i]) ans++; } cout << ans << endl; }
replace
9
10
9
10
TLE
p02622
C++
Runtime Error
// Tue May 26 19:06:02 IST 2020 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define forn(ii, a, b) for (int ii = (int)a; ii < (int)b; ii++) #define debug(x) cerr << #x << " " << x << " -- \n" #define I__O ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define int64 long long #define MOD 998244353 #define pb push_back #define f1 first #define s1 second #define all(x) (x).begin(), (x).end() #define precise(x) cout << fixed << setprecision(12) << x << '\n'; #define tough_nut numeric_limits<int64>::min() const double pi = 3.141592653589793238; using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int N = 3e5 + 7; const int INF = INT_MAX; struct comp { bool operator()(const pair<int, int> A, const pair<int, int> &B) const { if (A.first == B.first) return A.second < B.second; return A.first > B.first; } }; int tests() { string S, T; cin >> S >> T; int c = 0; int n = S.size(); for (int i = 0; i < n; i++) c += (S[i] != T[i]); cout << c << '\n'; // cout << (n+1-min(a,b)+max(a,b)-1)/max(a,b) << '\n'; } int32_t main() { I__O; int cases = 1; // cin >> cases ; while (cases--) tests(); return 0; } // g++ -std=c++17 -O2 -Wall test.cpp
// Tue May 26 19:06:02 IST 2020 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define forn(ii, a, b) for (int ii = (int)a; ii < (int)b; ii++) #define debug(x) cerr << #x << " " << x << " -- \n" #define I__O ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define int64 long long #define MOD 998244353 #define pb push_back #define f1 first #define s1 second #define all(x) (x).begin(), (x).end() #define precise(x) cout << fixed << setprecision(12) << x << '\n'; #define tough_nut numeric_limits<int64>::min() const double pi = 3.141592653589793238; using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int N = 3e5 + 7; const int INF = INT_MAX; struct comp { bool operator()(const pair<int, int> A, const pair<int, int> &B) const { if (A.first == B.first) return A.second < B.second; return A.first > B.first; } }; int tests() { string S, T; cin >> S >> T; int c = 0; int n = S.size(); for (int i = 0; i < n; i++) c += (S[i] != T[i]); cout << c << '\n'; return 0; // cout << (n+1-min(a,b)+max(a,b)-1)/max(a,b) << '\n'; } int32_t main() { I__O; int cases = 1; // cin >> cases ; while (cases--) tests(); return 0; } // g++ -std=c++17 -O2 -Wall test.cpp
insert
40
40
40
41
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { char arr1[20001]; char arr2[20001]; char c; for (int i = 0; 1; i++) { c = getchar(); if (c == '\n') { arr1[i] = '\0'; break; } arr1[i] = c; } for (int i = 0; 1; i++) { c = getchar(); if (c == '\n') { arr2[i] = '\0'; break; } arr2[i] = c; } int cnt = 0; for (int i = 0; arr1[i] != '\0'; i++) { if (arr1[i] != arr2[i]) cnt++; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char arr1[200001]; char arr2[200001]; char c; for (int i = 0; 1; i++) { c = getchar(); if (c == '\n') { arr1[i] = '\0'; break; } arr1[i] = c; } for (int i = 0; 1; i++) { c = getchar(); if (c == '\n') { arr2[i] = '\0'; break; } arr2[i] = c; } int cnt = 0; for (int i = 0; arr1[i] != '\0'; i++) { if (arr1[i] != arr2[i]) cnt++; } cout << cnt; return 0; }
replace
4
6
4
6
0
p02622
C++
Runtime Error
#include <stdio.h> int main() { char s[20010], t[20010]; scanf("%s", s); scanf("%s", t); int i = 0; int diff = 0; while (s[i] != '\0') { if (s[i] != t[i]) { diff++; } i++; } printf("%d", diff); }
#include <stdio.h> int main() { char s[200010], t[200010]; scanf("%s", s); scanf("%s", t); int i = 0; int diff = 0; while (s[i] != '\0') { if (s[i] != t[i]) { diff++; } i++; } printf("%d", diff); }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { char s[20010], t[20010]; int c = 0; scanf("%s %s", s, t); for (int i = 0; i < strlen(s); i++) { // printf("%c ",s[i]); if (s[i] == t[i]) { c++; } } printf("%ld\n", (strlen(s) - c)); }
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { char s[200010], t[200010]; int c = 0; scanf("%s %s", s, t); for (int i = 0; i < strlen(s); i++) { // printf("%c ",s[i]); if (s[i] == t[i]) { c++; } } printf("%ld\n", (strlen(s) - c)); }
replace
4
5
4
5
0
p02622
C++
Runtime Error
#include <stdio.h> int main() { char S[200000], T[200000]; int ans = 0; scanf("%s", S); scanf("%s", T); for (int i = 0; S[i] != '\0'; i++) { if (S[i] != T[i]) ans++; } printf("%d\n", ans); return 0; }
#include <stdio.h> int main() { char S[200001], T[200001]; int ans = 0; scanf("%s", S); scanf("%s", T); for (int i = 0; S[i] != '\0'; i++) { if (S[i] != T[i]) ans++; } printf("%d\n", ans); return 0; }
replace
3
4
3
4
0
p02622
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string A, B; int m, n, count = 0; n = A.length(); m = B.length(); while (n == m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (A[i] == B[j]) continue; else if (A[i] != B[j]) count++; i++; j++; } } } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; int64_t sum = 0; for (int i = 0; i < s1.size(); i++) sum += (s1[i] != s2[i]); cout << sum << "\n"; return 0; }
replace
3
20
3
9
TLE
p02622
C++
Runtime Error
#include <stdio.h> #define NUM 20001 int main() { int i, cnt = 0, errno; char s[NUM], t[NUM]; errno = scanf("%s", s); errno = scanf("%s", t); if (errno) { ; } for (i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) { cnt++; } } printf("%d", cnt); }
#include <stdio.h> #define NUM 200001 int main() { int i, cnt = 0, errno; char s[NUM], t[NUM]; errno = scanf("%s", s); errno = scanf("%s", t); if (errno) { ; } for (i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) { cnt++; } } printf("%d", cnt); }
replace
1
2
1
2
0
p02622
C++
Runtime Error
// BadWaper gg #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define inf 1e9 #define eps 1e-6 #define mp make_pair #define N 10010 using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { char ch = getchar(); ll s = 0, w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0'; ch = getchar(); } return s * w; } char s[N], t[N]; int main() { // freopen(".in","r",stdin); // freopen(".out","w",stdout); scanf("%s", s + 1); scanf("%s", t + 1); int len = strlen(s + 1); int ans = 0; for (register int i = 1; i <= len; i++) if (s[i] != t[i]) ans++; cout << ans << endl; return 0; }
// BadWaper gg #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define inf 1e9 #define eps 1e-6 #define mp make_pair #define N 200010 using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { char ch = getchar(); ll s = 0, w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0'; ch = getchar(); } return s * w; } char s[N], t[N]; int main() { // freopen(".in","r",stdin); // freopen(".out","w",stdout); scanf("%s", s + 1); scanf("%s", t + 1); int len = strlen(s + 1); int ans = 0; for (register int i = 1; i <= len; i++) if (s[i] != t[i]) ans++; cout << ans << endl; return 0; }
replace
15
16
15
16
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define SORT(c) sort((c).begin(), (c).end()); #define pb push_back #define MP make_pair #define pii pair<int, int> #define pcc pair<char, char> #define pic pair<int, char> #define pci pair<char, int> #define VS vector<string> #define VI vector<int> #define pi 3.141592653589793 #define ll long long #define ull unsigned long long #define w(x) \ int x; \ cin >> x; \ while (x--) #define fast ios_base::sync_with_stdio(0) #define sz size() #define cu cout << #define en endl #define sp " " #define RE(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define RI(i, n) for (int i = 1, _n = (n); i <= _n; ++i) #include <cstdio> #include <cstring> typedef unsigned long long UL; template <typename T> inline T S(T a) { return a * a; } template <class T> inline string tostring(T a) { ostringstream os(""); os << a; return os.str(); } template <typename T> inline ll tolong(T a) { ll res; istringstream os(a); os >> res; return res; } template <typename T> inline T gcd(T a, T b) { if (b == 0) return a; else return gcd(b, a % b); } template <typename T> inline T bigmod(T a, T b, T m) { if (b == 0) return 1; else if (b % 2 == 0) return S(bigmod(a, b / 2, m)) % m; else return (a % m * bigmod(a, b - 1, m)) % m; } const int inf = (int)1e9 + 5; const ll linf = (ll)1e16 + 5; const ll modd = (ll)1e9 + 7; const int mod = 10000007; /*#define N 20000009 bool prime[N]; vector<ll> prm; void seive () { memset(prime, true, sizeof(prime)); for( ll i=2; i*i<=N; i++) { if (prime[i] == true) { prm.pb(i); for (ll j=i*i; j<=N; j += i) pe[j] = false; } } }*/ /*bool isprime(ll n) { if(n<2) return 0; if(n==2) return 1; else { for(int i=2; i*i<=n; i++) if(n%i==0) return 0; } return 1; }*/ void pr(int f) { if (f == 1) cout << "YES\n"; else cout << "NO\n"; } int main() { fast; string s, ss; cin >> s >> s; int c = 0; for (int i = 0; i < s.sz; i++) { if (s[i] != ss[i]) c++; } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; #define SORT(c) sort((c).begin(), (c).end()); #define pb push_back #define MP make_pair #define pii pair<int, int> #define pcc pair<char, char> #define pic pair<int, char> #define pci pair<char, int> #define VS vector<string> #define VI vector<int> #define pi 3.141592653589793 #define ll long long #define ull unsigned long long #define w(x) \ int x; \ cin >> x; \ while (x--) #define fast ios_base::sync_with_stdio(0) #define sz size() #define cu cout << #define en endl #define sp " " #define RE(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define RI(i, n) for (int i = 1, _n = (n); i <= _n; ++i) #include <cstdio> #include <cstring> typedef unsigned long long UL; template <typename T> inline T S(T a) { return a * a; } template <class T> inline string tostring(T a) { ostringstream os(""); os << a; return os.str(); } template <typename T> inline ll tolong(T a) { ll res; istringstream os(a); os >> res; return res; } template <typename T> inline T gcd(T a, T b) { if (b == 0) return a; else return gcd(b, a % b); } template <typename T> inline T bigmod(T a, T b, T m) { if (b == 0) return 1; else if (b % 2 == 0) return S(bigmod(a, b / 2, m)) % m; else return (a % m * bigmod(a, b - 1, m)) % m; } const int inf = (int)1e9 + 5; const ll linf = (ll)1e16 + 5; const ll modd = (ll)1e9 + 7; const int mod = 10000007; /*#define N 20000009 bool prime[N]; vector<ll> prm; void seive () { memset(prime, true, sizeof(prime)); for( ll i=2; i*i<=N; i++) { if (prime[i] == true) { prm.pb(i); for (ll j=i*i; j<=N; j += i) pe[j] = false; } } }*/ /*bool isprime(ll n) { if(n<2) return 0; if(n==2) return 1; else { for(int i=2; i*i<=n; i++) if(n%i==0) return 0; } return 1; }*/ void pr(int f) { if (f == 1) cout << "YES\n"; else cout << "NO\n"; } int main() { fast; string s, ss; cin >> s >> ss; int c = 0; for (int i = 0; i < s.sz; i++) { if (s[i] != ss[i]) c++; } cout << c << endl; }
replace
97
98
97
98
0
p02622
C++
Runtime Error
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <iostream> #include <string.h> using namespace std; int main() { char ch1[1000]; char ch2[1000]; cin >> ch1 >> ch2; int n = strlen(ch1); int m = strlen(ch2); int count = 0; for (int i = 0; i < n; i++) { if (ch1[i] != ch2[i]) { count++; } } cout << count; return 0; }
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <iostream> #include <string.h> using namespace std; int main() { char ch1[400000]; char ch2[400000]; cin >> ch1 >> ch2; int n = strlen(ch1); int m = strlen(ch2); int count = 0; for (int i = 0; i < n; i++) { if (ch1[i] != ch2[i]) { count++; } } cout << count; return 0; }
replace
14
16
14
16
0
p02622
C++
Runtime Error
#include <stdio.h> #include <string.h> int main(void) { char s[200000]; scanf("%s", &s); char t[200000]; scanf("%s", &t); int count = 0; for (int i = 0; i < strlen(s); i++) { if (s[i] != t[i]) count++; } printf("%d\n", count); return 0; }
#include <stdio.h> #include <string.h> int main(void) { char s[200010]; scanf("%s", s); char t[200010]; scanf("%s", t); int count = 0; for (int i = 0; i < strlen(s); i++) { if (s[i] != t[i]) count++; } printf("%d\n", count); return 0; }
replace
4
8
4
8
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using p = pair<int, int>; typedef long long ll; int main() { char s[100000], t[100000]; cin >> s >> t; ll k = 0; ll m = strlen(s); rep(i, m) { if (s[i] != t[i]) { k++; } } cout << k << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using p = pair<int, int>; typedef long long ll; int main() { char s[1000000], t[1000000]; cin >> s >> t; ll k = 0; ll m = strlen(s); rep(i, m) { if (s[i] != t[i]) { k++; } } cout << k << endl; return 0; }
replace
8
9
8
9
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; long long n, m, i, j, k, len, ans = 0; char s1[100005], s2[100005]; int main() { cin >> s1 >> s2; len = strlen(s1); // printf("%d\n",len); for (i = 0; i < len; i++) { if (s1[i] != s2[i]) { ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, i, j, k, len, ans = 0; char s1[1000005], s2[1000005]; int main() { cin >> s1 >> s2; len = strlen(s1); // printf("%d\n",len); for (i = 0; i < len; i++) { if (s1[i] != s2[i]) { ans++; } } cout << ans << endl; return 0; }
replace
3
4
3
4
0
p02622
C++
Runtime Error
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { int count = 0; unsigned char s[200000]; unsigned char t[200000]; cin >> s; cin >> t; for (int i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) { count++; } } cout << count << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { int count = 0; string s; string t; cin >> s; cin >> t; for (int i = 0; s[i] != '\0'; i++) { if (s[i] != t[i]) { count++; } } cout << count << endl; return 0; }
replace
9
11
9
11
0
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) typedef long long ll; int main() { string S, T; cin >> S, T; ll ans = 0; for (ll i = 0; i < S.size(); ++i) { if (S[i] != T[i]) { ++ans; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) typedef long long ll; int main() { string S, T; cin >> S >> T; ll ans = 0; for (ll i = 0; i < S.size(); ++i) { if (S[i] != T[i]) { ++ans; } } cout << ans << endl; }
replace
7
8
7
8
0
p02622
C++
Runtime Error
// 設定言語check #include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <limits.h> #include <math.h> #include <string> using namespace std; int lenght(char *str) { int i = 0; while (str[i]) { i++; } return i; } int main() { char S[200000], T[200000]; int N, ans = 0, check = 0, len; cin >> S >> T; len = lenght(S); for (int i = 0; i < len; i++) { if (S[i] != T[i]) { ans++; } } cout << ans << endl; return 0; }
// 設定言語check #include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <limits.h> #include <math.h> #include <string> using namespace std; int lenght(char *str) { int i = 0; while (str[i]) { i++; } return i; } int main() { char S[200005], T[200005]; int N, ans = 0, check = 0, len; cin >> S >> T; len = lenght(S); for (int i = 0; i < len; i++) { if (S[i] != T[i]) { ans++; } } cout << ans << endl; return 0; }
replace
19
20
19
20
0
p02622
C++
Memory Limit Exceeded
#include <bits/stdc++.h> #define ll long long int using namespace std; #define mod 1000000007 long long int fastexpo(long long int a, long long int b) { long long int ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; b = b / 2; a = (a * a) % mod; } return ans; } bool vis[500000000] = {0}; bool child[50000000] = {0}; vector<int> vec[50000000]; int ans = 1; int bfs(int node) { queue<int> qu; qu.push(node); while (!qu.empty()) { int t = qu.front(); vis[t] = 1; qu.pop(); // cout << t << "\n"; for (int i = 0; i < vec[t].size(); i++) { if (child[t]) if (!vis[vec[t][i]]) { qu.push(vec[t][i]); vis[vec[t][i]] = 1; // child[vec[t][i]] = 1; ans++; } if (!child[t]) { if (!vis[vec[t][i]]) { qu.push(vec[t][i]); vis[vec[t][i]] = 1; child[vec[t][i]] = 1; // ans++; } } } } return ans; } int main() { int a; string str; // cin >> a; string str1; cin >> str; cin >> str1; int count = 0; for (int i = 0; i < str.length(); i++) { if (str[i] != str1[i]) count++; } cout << count << "\n"; return 0; }
#include <bits/stdc++.h> #define ll long long int using namespace std; #define mod 1000000007 int main() { int a; string str; // cin >> a; string str1; cin >> str; cin >> str1; int count = 0; for (int i = 0; i < str.length(); i++) { if (str[i] != str1[i]) count++; } cout << count << "\n"; return 0; }
delete
4
47
4
4
MLE
p02622
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s, t; int count = s.size(); int n = s.size() + 1; for (int i = 0; i < n; i++) { if (s.at(i) == t.at(i)) { count = count - 1; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, t; int count = 0; cin >> s >> t; for (int i = 0; i < s.size(); i++) { if (s.at(i) != t.at(i)) { count++; } } cout << count << endl; return 0; }
replace
4
9
4
9
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 0) >= this->size() (which is 0)
p02623
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, m, k, ans = 0; cin >> n >> m >> k; ll a[n + 1], b[n + 1]; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); for (ll i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } for (ll i = 1; i <= m; i++) { cin >> b[i]; b[i] += b[i - 1]; } for (ll i = 0; i <= n; i++) if (k >= a[i]) ans = max(ans, upper_bound(b + 1, b + 1 + m, k - a[i]) - b - 1 + i); cout << ans; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, m, k, ans = 0; cin >> n >> m >> k; ll a[n + 1] = {0}, b[m + 1] = {0}; for (ll i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } for (ll i = 1; i <= m; i++) { cin >> b[i]; b[i] += b[i - 1]; } for (ll i = 0; i <= n; i++) if (k >= a[i]) ans = max(ans, upper_bound(b + 1, b + 1 + m, k - a[i]) - b - 1 + i); cout << ans; }
replace
6
10
6
7
0
p02623
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define MP make_pair #define SIN(x, S) (S.count(x) != 0) #define M0(x) memset(x, 0, sizeof(x)) #define FILL(x, y) memset(x, y, sizeof(x)) #define MM(x) memset(x, -1, sizeof(x)) #define ALL(x) (x).begin(), (x).end() #define DB(x) cerr << #x << " = " << x << endl #define DB2(x, y) \ cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; #define DEBUG \ int x12345; \ cin >> x12345; typedef pair<int, int> PII; typedef pair<long long, long long> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef long long ll; typedef long long integer; const long long MOD = 1e9 + 7; /////////////////////////////////////////////// // for template template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } /////////////////////////////////////////////// /// 🍈( '-' 🍈 |AC| int main() { ll N, M, K; cin >> N >> M >> K; vector<ll> A(N), B(M), Sa(N + 1), Sb(M + 1); Sa[0] = 0; Sb[0] = 0; REP(i, N) { cin >> A[i]; Sa[i + 1] = A[i] + Sa[i]; } REP(i, M) { cin >> B[i]; Sb[i + 1] = B[i] + Sb[i]; } ll ans = 0; Sb.push_back(1e10); FORq(i, 0, N) { ll Ncost = Sa[i]; if (Ncost > K) continue; auto it = upper_bound(ALL(Sb), K - Ncost); ll bcount = it - Sb.begin() - 1; ll nans = (ll)i + bcount; DB2(i, bcount); chmax(ans, nans); } // REP(i,N+1){ // DB2(i,Sa[i]); // } // REP(i,M+1){ // DB2(i,Sb[i]); // } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define MP make_pair #define SIN(x, S) (S.count(x) != 0) #define M0(x) memset(x, 0, sizeof(x)) #define FILL(x, y) memset(x, y, sizeof(x)) #define MM(x) memset(x, -1, sizeof(x)) #define ALL(x) (x).begin(), (x).end() #define DB(x) cerr << #x << " = " << x << endl #define DB2(x, y) \ cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; #define DEBUG \ int x12345; \ cin >> x12345; typedef pair<int, int> PII; typedef pair<long long, long long> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef long long ll; typedef long long integer; const long long MOD = 1e9 + 7; /////////////////////////////////////////////// // for template template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } /////////////////////////////////////////////// /// 🍈( '-' 🍈 |AC| int main() { ll N, M, K; cin >> N >> M >> K; vector<ll> A(N), B(M), Sa(N + 1), Sb(M + 1); Sa[0] = 0; Sb[0] = 0; REP(i, N) { cin >> A[i]; Sa[i + 1] = A[i] + Sa[i]; } REP(i, M) { cin >> B[i]; Sb[i + 1] = B[i] + Sb[i]; } ll ans = 0; Sb.push_back(1e10); FORq(i, 0, N) { ll Ncost = Sa[i]; if (Ncost > K) continue; auto it = upper_bound(ALL(Sb), K - Ncost); ll bcount = it - Sb.begin() - 1; ll nans = (ll)i + bcount; // DB2(i,bcount); chmax(ans, nans); } // REP(i,N+1){ // DB2(i,Sa[i]); // } // REP(i,M+1){ // DB2(i,Sb[i]); // } cout << ans << endl; }
replace
72
73
72
73
TLE
p02623
C++
Runtime Error
#include <bits/stdc++.h> #define int long long int using namespace std; signed main() { int n, m, k; cin >> n >> m >> k; int a[n], b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < m; j++) { cin >> b[j]; } int x = 0, y = 0, sum1 = 0, sum2 = 0; while (y < m && (sum2 + b[y]) <= k) { sum2 += b[y]; y++; } y--; int ans = y + 1; for (int i = 0; i < n; i++) { sum1 += a[i]; while (sum2 > (k - sum1) && y >= 0) { sum2 -= b[y]; y--; } if (sum1 <= k) { ans = max(i + y + 2, ans); } } cout << ans; }
#include <bits/stdc++.h> #define int long long int using namespace std; signed main() { int n, m, k; cin >> n >> m >> k; int a[n], b[m]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < m; j++) { cin >> b[j]; } int x = 0, y = 0, sum1 = 0, sum2 = 0; while (y < m && (sum2 + b[y]) <= k) { sum2 += b[y]; y++; } y--; int ans = y + 1; for (int i = 0; i < n; i++) { sum1 += a[i]; while (sum2 > (k - sum1) && y >= 0) { sum2 -= b[y]; y--; } if (sum1 <= k) { ans = max(i + y + 2, ans); } } cout << ans; }
replace
6
7
6
7
0
p02623
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B) { ll rv = 0; vector<ll> sA(N + 1, 0); vector<ll> sB(N + 1, 0); for (ll i = 0; i < N; ++i) { sA[i + 1] = A[i] + sA[i]; } for (ll i = 0; i < M; ++i) { sB[i + 1] = B[i] + sB[i]; } ll j = M; for (ll i = 0; i <= N;) { if (sA[i] + sB[j] <= K) { rv = max(rv, i + j); i++; continue; } else { if (j != 0) { j--; } else { i++; } } } cout << rv << endl; } int main() { long long N; scanf("%lld", &N); long long M; scanf("%lld", &M); long long K; scanf("%lld", &K); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } std::vector<long long> B(M); for (int i = 0; i < M; i++) { scanf("%lld", &B[i]); } solve(N, M, K, std::move(A), std::move(B)); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B) { ll rv = 0; vector<ll> sA(N + 1, 0); vector<ll> sB(M + 1, 0); for (ll i = 0; i < N; ++i) { sA[i + 1] = A[i] + sA[i]; } for (ll i = 0; i < M; ++i) { sB[i + 1] = B[i] + sB[i]; } ll j = M; for (ll i = 0; i <= N;) { if (sA[i] + sB[j] <= K) { rv = max(rv, i + j); i++; continue; } else { if (j != 0) { j--; } else { i++; } } } cout << rv << endl; } int main() { long long N; scanf("%lld", &N); long long M; scanf("%lld", &M); long long K; scanf("%lld", &K); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } std::vector<long long> B(M); for (int i = 0; i < M; i++) { scanf("%lld", &B[i]); } solve(N, M, K, std::move(A), std::move(B)); return 0; }
replace
9
10
9
10
0
p02623
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M, K; cin >> N >> M >> K; long long A[N + 1]; A[0] = 0; for (int i = 1; i < N + 1; i++) { cin >> A[i]; A[i] += A[i - 1]; } long long B[M + 1]; B[0] = 0; for (int i = 1; i < M + 1; i++) { cin >> B[i]; B[i] += B[i - 1]; } int ans = 0; for (int i = N; i >= 0; i--) { for (int j = M; j >= 0; j--) { if (A[i] + B[j] <= K) { ans = max(ans, i + j); break; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, K; cin >> N >> M >> K; long long A[N + 1]; A[0] = 0; for (int i = 1; i < N + 1; i++) { cin >> A[i]; A[i] += A[i - 1]; } long long B[M + 1]; B[0] = 0; for (int i = 1; i < M + 1; i++) { cin >> B[i]; B[i] += B[i - 1]; } int ans = 0; for (int i = 0; i < N + 1; i++) { int l = -1; int r = M + 1; while (r - l > 1) { int c = l + (r - l) / 2; if (A[i] + B[c] > K) { r = c; } else { ans = max(ans, i + c); l = c; } } } cout << ans << endl; return 0; }
replace
20
25
20
30
TLE
p02623
Python
Runtime Error
n, m, k = map(int, input().split()) (*A,) = map(int, input().split()) (*B,) = map(int, input().split()) A.append(0) B.append(0) time = 0 cnt = 0 a, b = 0, 0 while (a < m and time + A[a] <= k) or (b < n and time + B[b] <= k): if (a < m and time + A[a] <= k) and (b < n and time + B[b] <= k): if A[a] <= B[b]: cnt += 1 time += A[a] a += 1 else: cnt += 1 time += B[b] b += 1 elif a < m and time + A[a] <= k: cnt += 1 time += A[a] a += 1 else: cnt += 1 time += B[b] b += 1 print(cnt)
n, m, k = map(int, input().split()) (*A,) = map(int, input().split()) (*B,) = map(int, input().split()) SA, SB = [0], [0] for i in range(n): SA.append(SA[i] + A[i]) for j in range(m): SB.append(SB[j] + B[j]) ans, tmp = 0, m for i in range(n + 1): if SA[i] > k: break for j in range(tmp + 1)[::-1]: if SA[i] + SB[j] <= k: break ans = max(ans, i + j) tmp = j print(ans)
replace
3
27
3
18
0
p02623
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <vector> using namespace std; const double PI = 3.141592653589793238463; #define pb push_back #define pf push_front #define sz(v) ((int)(v).size()); #define all(v) ((v).begin()), ((v).end()) typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<ull> vul; typedef pair<int, int> pi; // 2 7 3 4 9 void printVec(vul v1) { for (int i = 0; i < v1.size(); i++) cout << v1[i] << " "; cout << endl; } ll rec(ll r, ll c) { if (r <= 1 || c <= 1) { return 1; } return rec(r - 1, c) + rec(r, c - 1); } bool bin_search(ull target, vul V) { ll low = 0; ll high = V.size() - 1; while (low <= high) { ll mid = (low + high) / 2; if (target == V[mid]) { return true; } if (target < V[mid]) { high = mid - 1; } else { low = mid + 1; } } return false; } int main() { ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); ll n, m, k; cin >> n >> m >> k; vul a(n, 0); vul b(m, 0); for (ll i = 0; i < n; i++) { cin >> b[i]; } for (ll i = 0; i < m; i++) { cin >> b[i]; } vul A(n + 1, 0); vul B(m + 1, 0); for (ll i = 0; i < n; i++) { A[i + 1] = A[i] + a[i]; } for (ll i = 0; i < m; i++) { B[i + 1] = B[i] + b[i]; } ll books = 0, A_books = 0, B_books = 0; ull sum = 0; vector<ull>::iterator lower, upper; for (ull i = 0; i <= n; i++) { ll t = k - A[i]; if (t < 0) { continue; } lower = lower_bound(B.begin(), B.end(), k - A[i]); B_books = lower - B.begin(); if (B[B_books] > k - A[i] || B_books > m) { B_books--; } // B_books--; sum = max(sum, B_books + i); } cout << sum << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <vector> using namespace std; const double PI = 3.141592653589793238463; #define pb push_back #define pf push_front #define sz(v) ((int)(v).size()); #define all(v) ((v).begin()), ((v).end()) typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<ull> vul; typedef pair<int, int> pi; // 2 7 3 4 9 void printVec(vul v1) { for (int i = 0; i < v1.size(); i++) cout << v1[i] << " "; cout << endl; } ll rec(ll r, ll c) { if (r <= 1 || c <= 1) { return 1; } return rec(r - 1, c) + rec(r, c - 1); } bool bin_search(ull target, vul V) { ll low = 0; ll high = V.size() - 1; while (low <= high) { ll mid = (low + high) / 2; if (target == V[mid]) { return true; } if (target < V[mid]) { high = mid - 1; } else { low = mid + 1; } } return false; } int main() { ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); ll n, m, k; cin >> n >> m >> k; vul a(n, 0); vul b(m, 0); for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = 0; i < m; i++) { cin >> b[i]; } vul A(n + 1, 0); vul B(m + 1, 0); for (ll i = 0; i < n; i++) { A[i + 1] = A[i] + a[i]; } for (ll i = 0; i < m; i++) { B[i + 1] = B[i] + b[i]; } ll books = 0, A_books = 0, B_books = 0; ull sum = 0; vector<ull>::iterator lower, upper; for (ull i = 0; i <= n; i++) { ll t = k - A[i]; if (t < 0) { continue; } lower = lower_bound(B.begin(), B.end(), k - A[i]); B_books = lower - B.begin(); if (B[B_books] > k - A[i] || B_books > m) { B_books--; } // B_books--; sum = max(sum, B_books + i); } cout << sum << endl; return 0; }
replace
69
70
69
70
0
p02623
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double lld; ll MOD = (1e9) + 7; const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1}; const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1}; const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2}; const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1}; // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") inline void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template <typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__) #else #define debug(...) 47 #endif int main() { fastIO(); ll ans = 0, n, m, k; cin >> n >> m >> k; vector<ll> a(n + 1); vector<ll> b(m + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } for (int i = 1; i <= m; i++) { cin >> b[i]; b[i] += b[i - 1]; } ll pos = m; for (int i = 0; i <= n; i++) { while (a[i] + b[pos] > k) pos--; if (a[i] + b[pos] > k) continue; ans = max(ans, i + pos); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double lld; ll MOD = (1e9) + 7; const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1}; const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1}; const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2}; const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1}; // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") inline void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template <typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__) #else #define debug(...) 47 #endif int main() { fastIO(); ll ans = 0, n, m, k; cin >> n >> m >> k; vector<ll> a(n + 1); vector<ll> b(m + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } for (int i = 1; i <= m; i++) { cin >> b[i]; b[i] += b[i - 1]; } ll pos = m; for (int i = 0; i <= n; i++) { while (a[i] + b[pos] > k && pos > 0) pos--; if (a[i] + b[pos] > k) continue; ans = max(ans, i + pos); } cout << ans << endl; return 0; }
replace
64
65
64
65
-11
p02623
C++
Time Limit Exceeded
// Problem : C - Tsundoku // Contest : AtCoder - AtCoder Beginner Contest 172 // URL : https://atcoder.jp/contests/abc172/tasks/abc172_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) /* WINNERS NEVER QUIT AND QUITTERS NEVER WIN!! */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long, long> pl; typedef pair<ll, ll> pll; typedef vector<long> vl; typedef vector<bool> vb; typedef vector<ll> vll; typedef vector<vl> vvl; typedef vector<vb> vvb; typedef vector<vll> vvll; typedef vector<pll> vpll; typedef vector<string> vs; typedef unordered_map<ll, ll> umll; #define FOR(i, a, b) for (long long i = a; i < b; ++i) #define REV(i, a, b) for (long long i = a; i >= b; i--) #define F first #define S second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define tc \ ll tests; \ cin >> tests; \ while (tests--) #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define coutv(v) \ for (auto it : (v)) \ cout << it << " "; \ newl; #define cout2d(v) \ for (auto it : (v)) { \ for (auto j : it) \ cout << j << " "; \ newl; \ } #define cinv(v, n) \ vll(v)(n); \ FOR(i, 0, (n)) { cin >> v[i]; } #define cinvg(v, n) \ (v).resize(n); \ FOR(i, 0, (n)) { cin >> v[i]; } #define cin2d(v, n, m) \ vvll(v)(n, vll(m, 0)); \ FOR(i, 0, n) { \ FOR(j, 0, m) { cin >> v[i][j]; } \ } #define cin2dg(v, n, m) \ (v).resize(n, vll(m)); \ FOR(i, 0, n) { \ FOR(j, 0, m) { cin >> v[i][j]; } \ } #define newl cout << "\n" #define mod 1000000007 #define INF LLONG_MAX / 2 int main() { io; ll n, m, k, ans = 0; cin >> n >> m >> k; cinv(a, n) cinv(b, m) vll pre_a(n + 3), pre_b(m + 3); pre_a[0] = 0; pre_b[0] = 0; FOR(i, 1, n + 1) { pre_a[i] = pre_a[i - 1] + a[i - 1]; } FOR(i, 1, m + 1) { pre_b[i] = pre_b[i - 1] + b[i - 1]; } ll ind = 0; REV(i, n, 0) // start with max index in a and decrease { FOR(j, ind, m + 1) // increase index of B { if (pre_a[i] + pre_b[j] <= k) { ans = max(ans, i + j); } else { ind = j; break; } } } cout << ans; return 0; }
// Problem : C - Tsundoku // Contest : AtCoder - AtCoder Beginner Contest 172 // URL : https://atcoder.jp/contests/abc172/tasks/abc172_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) /* WINNERS NEVER QUIT AND QUITTERS NEVER WIN!! */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long, long> pl; typedef pair<ll, ll> pll; typedef vector<long> vl; typedef vector<bool> vb; typedef vector<ll> vll; typedef vector<vl> vvl; typedef vector<vb> vvb; typedef vector<vll> vvll; typedef vector<pll> vpll; typedef vector<string> vs; typedef unordered_map<ll, ll> umll; #define FOR(i, a, b) for (long long i = a; i < b; ++i) #define REV(i, a, b) for (long long i = a; i >= b; i--) #define F first #define S second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define tc \ ll tests; \ cin >> tests; \ while (tests--) #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define coutv(v) \ for (auto it : (v)) \ cout << it << " "; \ newl; #define cout2d(v) \ for (auto it : (v)) { \ for (auto j : it) \ cout << j << " "; \ newl; \ } #define cinv(v, n) \ vll(v)(n); \ FOR(i, 0, (n)) { cin >> v[i]; } #define cinvg(v, n) \ (v).resize(n); \ FOR(i, 0, (n)) { cin >> v[i]; } #define cin2d(v, n, m) \ vvll(v)(n, vll(m, 0)); \ FOR(i, 0, n) { \ FOR(j, 0, m) { cin >> v[i][j]; } \ } #define cin2dg(v, n, m) \ (v).resize(n, vll(m)); \ FOR(i, 0, n) { \ FOR(j, 0, m) { cin >> v[i][j]; } \ } #define newl cout << "\n" #define mod 1000000007 #define INF LLONG_MAX / 2 int main() { io; ll n, m, k, ans = 0; cin >> n >> m >> k; cinv(a, n) cinv(b, m) vll pre_a(n + 3), pre_b(m + 3); pre_a[0] = 0; pre_b[0] = 0; FOR(i, 1, n + 1) { pre_a[i] = pre_a[i - 1] + a[i - 1]; } FOR(i, 1, m + 1) { pre_b[i] = pre_b[i - 1] + b[i - 1]; } ll ind = 0; REV(i, n, 0) // start with max index in a and decrease { FOR(j, ind, m + 1) // increase index of B { if (pre_a[i] + pre_b[j] <= k) { ans = max(ans, i + j); } else { ind = j; break; } } if (ans == n + m) { break; } } cout << ans; return 0; }
insert
102
102
102
105
TLE