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
p02246
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX_T 50 #define WIDTH 2400 pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH]; vector<vector<int>> X; int hantei(vector<vector<int>> a) { int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX_T 50 #define WIDTH 9600 pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH]; vector<vector<int>> X; int hantei(vector<vector<int>> a) { int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ...
replace
5
6
5
6
0
p02246
C++
Memory Limit Exceeded
#include <array> #include <cmath> #include <iostream> #include <queue> #include <set> #include <vector> using namespace std; const int N = 4; const int N2 = N * N; int MDT[N2][N2]; struct Puzzle { array<char, N2> board; int empty; int cost; int rank; bool operator<(const Puzzle &other) const { return...
#include <array> #include <cmath> #include <iostream> #include <queue> #include <set> #include <vector> using namespace std; const int N = 4; const int N2 = N * N; int MDT[N2][N2]; struct Puzzle { array<char, N2> board; int empty; int cost; int rank; bool operator<(const Puzzle &other) const { return...
insert
28
28
28
30
MLE
p02246
C++
Runtime Error
#include <assert.h> #include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <climits> #include <cmath> #include <set> #include <stack> #include <string> #define N 4 #define N2 16 using namespace std; // const int N = 4; // const int N2 = 16; static const int dx[4] = {0, -1, 0, 1}; st...
#include <assert.h> #include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <climits> #include <cmath> #include <set> #include <stack> #include <string> #define N 4 #define N2 16 using namespace std; // const int N = 4; // const int N2 = 16; static const int dx[4] = {0, -1, 0, 1}; st...
replace
60
61
60
61
-11
p02246
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX_T 50 #define WIDTH 21000 pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH]; vector<vector<int>> X; int hantei(vector<vector<int>> a) { int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define MAX_T 50 #define WIDTH 20000 pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH]; vector<vector<int>> X; int hantei(vector<vector<int>> a) { int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ...
replace
5
6
5
6
TLE
p02247
C++
Runtime Error
// ALDS1_14_A #include <iostream> #include <string> using namespace std; int main() { string T, P; cin >> T; cin >> P; for (int i = 0; i <= T.length() - P.length(); i++) if (T.substr(i, P.length()) == P) cout << i << endl; return 0; }
// ALDS1_14_A #include <iostream> #include <string> using namespace std; int main() { string T, P; cin >> T; cin >> P; if (T.length() >= P.length()) for (int i = 0; i <= T.length() - P.length(); i++) if (T.substr(i, P.length()) == P) cout << i << endl; return 0; }
replace
11
14
11
15
0
p02247
C++
Runtime Error
#include <iostream> #include <string> using namespace std; int main() { string a, b; int tmp; cin >> a >> b; for (int i = 0; i < a.size() - b.size() + 1; i++) { if (a[i] == b[0]) { tmp = 1; for (int j = 0; j < b.size(); j++) if (a[i + j] != b[j]) { tmp = 0; break; ...
#include <iostream> #include <string> using namespace std; int main() { string a, b; int tmp; cin >> a >> b; if (a.size() < b.size()) return 0; for (int i = 0; i < a.size() - b.size() + 1; i++) { if (a[i] == b[0]) { tmp = 1; for (int j = 0; j < b.size(); j++) if (a[i + j] != b[j])...
insert
8
8
8
10
0
p02247
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long using namespace std; typedef pair<int, int> P; struct RollingHash { typedef long long ll; typedef pair<ll, ll> pll; ll base1; ll ...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long using namespace std; typedef pair<int, int> P; struct RollingHash { typedef long long ll; typedef pair<ll, ll> pll; ll base1; ll ...
insert
55
55
55
57
0
p02247
C++
Runtime Error
#include <iostream> int main() { std::ios_base::sync_with_stdio(false); std::string a; std::string b; std::cin >> a; std::cin >> b; bool match = false; for (int i = 0; i <= (a.size() - b.size()); i++) { match = true; for (int j = 0; j < b.size(); j++) { if (a[i + j] != b[j]) { ...
#include <iostream> int main() { std::ios_base::sync_with_stdio(false); std::string a; std::string b; std::cin >> a; std::cin >> b; bool match = false; if (a.size() < b.size()) { return 0; } for (int i = 0; i <= (a.size() - b.size()); i++) { match = true; for (int j = 0; j < b.size(...
insert
12
12
12
16
0
p02247
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { int count = 0; vector<int> index; string a, b; cin >> a >> b; for (int i = 0; i <= a.size() - b.size(); i++) { if (a.substr(i, b.size()) == b) { count++; index.push_back(i); } } if (count != 0...
#include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { int count = 0; vector<int> index; string a, b; cin >> a >> b; if (a.size() < b.size()) return 0; for (int i = 0; i <= a.size() - b.size(); i++) { if (a.substr(i, b.size()) == b) { count++; index...
insert
8
8
8
10
0
p02247
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string t, p; cin >> t >> p; for (int i = 0; i < t.size() - p.size() + 1; i++) { int f = 0; for (int j = 0; j < p.size(); j++) if (t[i + j] != p[j]) f = 1; if (f) continue; cout << i << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string t, p; cin >> t >> p; if (t.size() >= p.size()) for (int i = 0; i < t.size() - p.size() + 1; i++) { int f = 0; for (int j = 0; j < p.size(); j++) if (t[i + j] != p[j]) f = 1; if (f) continue; cou...
replace
5
14
5
15
0
p02247
C++
Runtime Error
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; void brute_force(string T, string P) { const char *Tc = T.c...
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; void brute_force(string T, string P) { const char *Tc = T.c...
replace
19
20
19
20
0
p02247
C++
Runtime Error
#include <iostream> #include <string> using namespace std; string s, t; int main() { cin >> s >> t; for (int i = 0; i < s.size() - t.size() + 1; i++) { for (int j = 0; j < t.size(); j++) { if (s[i + j] != t[j]) { break; } if (j == t.size() - 1 && s[i + j] == t[j]) { cout << i...
#include <iostream> #include <string> using namespace std; string s, t; int main() { cin >> s >> t; if (s.size() < t.size()) { return 0; } for (int i = 0; i < s.size() - t.size() + 1; i++) { for (int j = 0; j < t.size(); j++) { if (s[i + j] != t[j]) { break; } if (j == t.size...
insert
8
8
8
11
0
p02247
C++
Runtime Error
#include <iostream> #include <string> using namespace std; int main() { string S, T; cin >> S >> T; for (int i = 0; i <= S.size() - T.size(); i++) { if (T == S.substr(i, T.size())) { cout << i << endl; } } return 0; }
#include <iostream> #include <string> using namespace std; int main() { string S, T; cin >> S >> T; if (S.size() >= T.size()) { for (int i = 0; i <= S.size() - T.size(); i++) { if (T == S.substr(i, T.size())) { cout << i << endl; } } } return 0; }
replace
10
13
10
15
0
p02247
C++
Time Limit Exceeded
#include <iostream> #include <string> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int main(void) { string t; string p; cin >> t; cin >> p; rep(i, t.size() - p.size() + 1) { rep(j, p.size()) { if (i + j >= t.size() || t[i + j] != p[j]) break; ; if (j == p....
#include <iostream> #include <string> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int main(void) { string t; string p; cin >> t; cin >> p; rep(i, (int)t.size() - (int)p.size() + 1) { rep(j, p.size()) { if (i + j >= t.size() || t[i + j] != p[j]) break; ; i...
replace
11
12
11
12
TLE
p02247
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
insert
81
81
81
83
0
p02247
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct RollingHash { typedef long long int_type; typedef pair<int_type, int_type> hash_type; int_type base, mod[2]; vector<int_type> hashed[2], power[2]; RollingHash() { base = 9973LL, mod[0] = 999999937LL, mod[1] = 1000000007LL; } void init(const string &...
#include <bits/stdc++.h> using namespace std; struct RollingHash { typedef long long int_type; typedef pair<int_type, int_type> hash_type; int_type base, mod[2]; vector<int_type> hashed[2], power[2]; RollingHash() { base = 9973LL, mod[0] = 999999937LL, mod[1] = 1000000007LL; } void init(const string &...
replace
55
56
55
56
0
p02248
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string t, p; cin >> t >> p; int tl = t.length(); int pl = p.length(); int skip[256]; for (int i = 0; i < 256; i++) skip[i] = pl; for (int i = 0; i < pl - 1; i++) skip[(unsigned)p[i...
#include <iostream> #include <string> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string t, p; cin >> t >> p; for (int pos = 0; pos < t.length(); pos++) { pos = t.find(p, pos); if (pos == string::npos) break; cout << pos << '\n'; } return 0; }
replace
9
23
9
14
TLE
p02248
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef unsigned long long ull; using namespace std; void Rolling_Hash(const string &a, const string &b) { const ull B = 100000007; int al = a.length(), bl = b.length(); if (al > bl) return; ull t = 1; for (int i = 0; i < al; i++) t *= B; ull ah = 0, bh = 0; for (int i ...
#include <bits/stdc++.h> typedef unsigned long long ull; using namespace std; void Rolling_Hash(const string &a, const string &b) { const ull B = 100000007; int al = a.length(), bl = b.length(); if (al > bl) return; ull t = 1; for (int i = 0; i < al; i++) t *= B; ull ah = 0, bh = 0; for (int i ...
replace
21
22
21
22
TLE
p02248
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define base 950527 using namespace std; typedef unsigned long long ll; map<ll, ll> map; int main() { string a, b; cin >> a >> b; ll hs = 0, n = 0, t = 1; for (int i = 0; i < b.size(); i++) { hs = hs * base + b[i]; n = n * base + a[i]; t *= base; } if (hs == n) co...
#include <bits/stdc++.h> #define base 950527 using namespace std; typedef unsigned long long ll; map<ll, ll> map; int main() { string a, b; cin >> a >> b; ll hs = 0, n = 0, t = 1; for (int i = 0; i < b.size(); i++) { hs = hs * base + b[i]; n = n * base + a[i]; t *= base; } if (hs == n) co...
replace
23
24
23
24
TLE
p02248
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef unsigned long long lli; typedef unsigned long long ull; typedef vector<lli> vll; typedef vector<bo...
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef unsigned long long lli; typedef unsigned long long ull; typedef vector<lli> vll; typedef vector<bo...
insert
32
32
32
34
0
p02248
C++
Time Limit Exceeded
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, a) REP(i, 0, a)...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, a) REP(i, 0, a)...
replace
66
67
66
67
TLE
p02248
C++
Time Limit Exceeded
#include <iostream> #include <string> #include <vector> #define CLEN 256 using namespace std; template <typename T> std::vector<std::vector<T>> makeMatrix(int row, int col) { std::vector<std::vector<T>> vv(row); for (auto it = vv.begin(); it != vv.end(); it++) { (*it).resize(col); } return vv; } vector<ve...
#include <iostream> #include <string> #include <vector> #define CLEN 256 using namespace std; template <typename T> std::vector<std::vector<T>> makeMatrix(int row, int col) { std::vector<std::vector<T>> vv(row); for (auto it = vv.begin(); it != vv.end(); it++) { (*it).resize(col); } return vv; } vector<ve...
replace
103
105
103
107
TLE
p02248
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define pb emplace_back typedef unsigned long long ll; typedef pair<int, int> pint; const ll x = 1000000007; string t, p; int main() { cin >> t >> p; ll st = t.size(), sp = p.size(); ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define pb emplace_back typedef unsigned long long ll; typedef pair<int, int> pint; const ll x = 1000000007; string t, p; int main() { cin >> t >> p; ll st = t.size(), sp = p.size(); ...
insert
13
13
13
15
0
p02248
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #inclu...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #inclu...
replace
43
44
43
46
TLE
p02248
C++
Time Limit Exceeded
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
replace
141
142
141
142
TLE
p02248
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; ull B = 950527; int n, m; char str[1000005]; ull a[1000005]; int main() { scanf("%s", str); n = strlen(str); for (int i = 0; i < n; i++) { a[i] = str[i]; if (i) a[i] += a[i - 1] * B; } scanf("%s", str); m = strlen(s...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; ull B = 950527; int n, m; char str[1000005]; ull a[1000005]; int main() { scanf("%s", str); n = strlen(str); for (int i = 0; i < n; i++) { a[i] = str[i]; if (i) a[i] += a[i - 1] * B; } scanf("%s", str); m = strlen(s...
replace
28
29
28
29
TLE
p02248
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string T[2]; cin >> T[0] >> T[1]; typedef unsigned int int_type; const int_type base = 9973; vector<int_type> hashed[2], power[2]; for (int i = 0; i < 2; i++) { int sz = T[i].size(); hashed[i].assign(sz + 1, 0); power[i].assign(sz +...
#include <bits/stdc++.h> using namespace std; int main() { string T[2]; cin >> T[0] >> T[1]; typedef unsigned int int_type; const int_type base = 9973; vector<int_type> hashed[2], power[2]; for (int i = 0; i < 2; i++) { int sz = T[i].size(); hashed[i].assign(sz + 1, 0); power[i].assign(sz +...
replace
29
30
29
30
TLE
p02248
C++
Time Limit Exceeded
/* * b.cc: */ #include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <util...
/* * b.cc: */ #include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <util...
replace
84
94
84
86
TLE
p02248
C++
Runtime Error
#include <cstdio> #include <string> #include <vector> using namespace std; const long long MOD = 1e9 + 7; const long long BASE = 0x234567; struct RollingHash { string s; long long mod, base; vector<long long> hash, pow; RollingHash() {} RollingHash(string s, long long m, long long b) : s(s), mod(m), base(b...
#include <cstdio> #include <string> #include <vector> using namespace std; const long long MOD = 1e9 + 7; const long long BASE = 0x234567; struct RollingHash { string s; long long mod, base; vector<long long> hash, pow; RollingHash() {} RollingHash(string s, long long m, long long b) : s(s), mod(m), base(b...
replace
43
44
43
44
0
p02248
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vec...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vec...
replace
27
33
27
32
TLE
p02249
C++
Runtime Error
#include <iostream> using namespace std; #include <stdio.h> #include <string> #define A 1355471101 // large prime number 1. #define B 1466700101 // large prime number 2. #define M 1522101101 // large prime number 3, larger than A and B. int main() { int i, j, H, W, R, C; string *T; scanf("%d %d", &H, &W); T ...
#include <iostream> using namespace std; #include <stdio.h> #include <string> #define A 1355471101 // large prime number 1. #define B 1466700101 // large prime number 2. #define M 1522101101 // large prime number 3, larger than A and B. int main() { int i, j, H, W, R, C; string *T; scanf("%d %d", &H, &W); T ...
replace
20
21
20
21
0
p02249
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; struct AhoCorasick { static const int ALPHABET_SIZE = 62, root = 0; inline int index(char ch) { if (isupper(ch)) return ch - 'A'; if (islower(ch)...
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; struct AhoCorasick { static const int ALPHABET_SIZE = 62, root = 0; inline int index(char ch) { if (isupper(ch)) return ch - 'A'; if (islower(ch)...
replace
52
53
52
53
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p02249
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; struct AhoCorasick { static const int ALPHABET_SIZE = 62, root = 0; inline int index(char ch) { if (isupper(ch)) return ch - 'A'; if (islower(ch)...
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; struct AhoCorasick { static const int ALPHABET_SIZE = 62, root = 0; inline int index(char ch) { if (isupper(ch)) return ch - 'A'; if (islower(ch)...
replace
76
77
76
77
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p02250
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef unsigned long long ull; typedef unsigned __int128 HASH; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll, int> plli; typedef pair<double, int> pdbi; typedef pair<int, p...
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef unsigned long long ull; typedef unsigned __int128 HASH; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll, int> plli; typedef pair<double, int> pdbi; typedef pair<int, p...
replace
139
140
139
140
0
p02250
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; class suffix_array { void create_begin_bucket(vector<int> &v, vector<int> &bucket) { fill(bucket.begin(), bucket.end(), 0); for (int i = 0; i < v.size(); i++) bucket[v[i]]++; int sum = 0; for (int i = 0; i < bucket.size(); i++) { bucket[i] += s...
#include <bits/stdc++.h> using namespace std; class suffix_array { void create_begin_bucket(vector<int> &v, vector<int> &bucket) { fill(bucket.begin(), bucket.end(), 0); for (int i = 0; i < v.size(); i++) bucket[v[i]]++; int sum = 0; for (int i = 0; i < bucket.size(); i++) { bucket[i] += s...
replace
138
140
138
141
-6
double free or corruption (out)
p02250
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long // BEGIN CUT HERE struct SuffixArray { int n, k; string S; vector<int> sa, lcp; SuffixArray() {} SuffixArray(string S) : S(S) { init(); } void init() { n = S.length(); sa.clear(); lcp.clear(); sa.resize(n + 1, 0); lcp.re...
#include <bits/stdc++.h> using namespace std; #define int long long // BEGIN CUT HERE struct SuffixArray { int n, k; string S; vector<int> sa, lcp; SuffixArray() {} SuffixArray(string S) : S(S) { init(); } void init() { n = S.length(); sa.clear(); lcp.clear(); sa.resize(n + 1, 0); lcp.re...
replace
89
91
89
91
-6
free(): invalid pointer
p02250
C++
Time Limit Exceeded
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < int(n); ++i) #define ALL(A) (A).begin(), (A).end() #define SZ(A) int(A.size()) using namespace std; typedef unsigned long long ull; struct RollingHash { static co...
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < int(n); ++i) #define ALL(A) (A).begin(), (A).end() #define SZ(A) int(A.size()) using namespace std; typedef unsigned long long ull; struct RollingHash { static co...
replace
63
64
63
64
TLE
p02250
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // #define int long long typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(), (v).end() #define rep(i, n) for (int i = 0; i < (n); i++) #...
#include <bits/stdc++.h> using namespace std; // #define int long long typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(), (v).end() #define rep(i, n) for (int i = 0; i < (n); i++) #...
replace
97
98
97
98
TLE
p02250
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = (x); i < (y); ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf = 1e9; const int64_t in...
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = (x); i < (y); ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf = 1e9; const int64_t in...
delete
86
87
86
86
0
[6,5,4,3,0,1,2,]
p02250
C++
Runtime Error
/* * Multiple string matching (suffix array) * O(T log T + \sum (P_i log T)) * * Construction: reduce to sorting the cyclic shifts of A||'$' */ #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; constexpr int kAlphabetSize = 37; int ValueOf(char ch) { if (ch == '...
/* * Multiple string matching (suffix array) * O(T log T + \sum (P_i log T)) * * Construction: reduce to sorting the cyclic shifts of A||'$' */ #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; constexpr int kAlphabetSize = 37; int ValueOf(char ch) { if (ch == '...
replace
126
127
126
127
0
p02255
C++
Runtime Error
#include <stdio.h> static const int N = 1000; void print(int a[], int n) { int k; for (k = 0; k < n; k++) { if (k > 0) printf(" "); printf("%d", a[k]); } printf("\n"); } int main(void) { int n, i, j, key; int a[N + 1]; scanf("%d", &n); // input for (i = 0; i < n; i++) { scanf("%d"...
#include <stdio.h> static const int N = 1000; void print(int a[], int n) { int k; for (k = 0; k < n; k++) { if (k > 0) printf(" "); printf("%d", a[k]); } printf("\n"); } int main(void) { int n, i, j, key; int a[N + 1]; scanf("%d", &n); // input for (i = 0; i < n; i++) { scanf("%d"...
replace
20
21
20
21
-11
p02255
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; void show(vector<int> a) { for (int i = 0; i < a.size() - 1; i++) { cout << a[i] << " "; } cout << a[a.s...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; void show(vector<int> a) { for (int i = 0; i < a.size() - 1; i++) { cout << a[i] << " "; } cout << a[a.s...
insert
33
33
33
34
-6
free(): invalid pointer
p02255
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n = 30; int k[n]; cin >> n; for (int i = 0; i < n; i++) { cin >> k[i]; } for (int i = 0; i < n; i++) { int v = k[i]; int j = i - 1; while (j >= 0 && k[j] > v) { k[j + 1] = k[j]; j--; } k[j + 1] = v; for (int ...
#include <iostream> using namespace std; int main() { int n = 100; int k[n]; cin >> n; for (int i = 0; i < n; i++) { cin >> k[i]; } for (int i = 0; i < n; i++) { int v = k[i]; int j = i - 1; while (j >= 0 && k[j] > v) { k[j + 1] = k[j]; j--; } k[j + 1] = v; for (int...
replace
4
5
4
5
0
p02255
C++
Runtime Error
#include <iostream> using namespace std; int main() { int numOfElement; int elem[99] = {}; cin >> numOfElement; for (int i = 0; i < numOfElement; i++) { cin >> elem[i]; } for (int i = 0; i < numOfElement; i++) { for (int j = i; j > 0 && elem[j] < elem[j - 1]; j--) { int buf = elem[j - 1]; ...
#include <iostream> using namespace std; int main() { int numOfElement; int elem[100] = {}; cin >> numOfElement; for (int i = 0; i < numOfElement; i++) { cin >> elem[i]; } for (int i = 0; i < numOfElement; i++) { for (int j = i; j > 0 && elem[j] < elem[j - 1]; j--) { int buf = elem[j - 1];...
replace
5
6
5
6
0
p02255
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; void insortionSort(vector<int> A) { for (int i = 0; i < A.size(); i++) { int v = A[i]; int j = i - 1; while (j >= 0 && A[j] > v) { A[j + 1] = A[j]; j--; } A[j + 1] = v; for (int i : A) { cout << i; } cout <...
#include <iostream> #include <vector> using namespace std; void insortionSort(vector<int> A) { for (int i = 0; i < A.size(); i++) { int v = A[i]; int j = i - 1; while (j >= 0 && A[j] > v) { A[j + 1] = A[j]; j--; } A[j + 1] = v; for (int i = 0; i < A.size(); i++) { cout << ...
replace
15
17
15
20
TLE
p02255
C++
Runtime Error
#include <algorithm> #include <climits> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; typedef signed long long ll; int main(void) { int N = 0; cin >> N; vector<int> A(N, 0); for (int i = 0; i < N; i++) { cin >> A[i]; if (i > 0) { ...
#include <algorithm> #include <climits> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; typedef signed long long ll; int main(void) { int N = 0; cin >> N; vector<int> A(N, 0); for (int i = 0; i < N; i++) { cin >> A[i]; if (i > 0) { ...
replace
34
35
34
35
-6
double free or corruption (out)
p02256
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { cerr << x << " " << y << endl; if (x < y) swap(x, y); if (x % y == 0) return y; return gcd(x % y, y); } int main(void) { int x, y; cin >> x >> y; cout << gcd(x, y) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { // cerr << x << " " << y << endl; if (x < y) swap(x, y); if (x % y == 0) return y; return gcd(x % y, y); } int main(void) { int x, y; cin >> x >> y; cout << gcd(x, y) << endl; return 0; }
replace
4
5
4
5
0
54 20 14 20 6 14 2 6
p02256
C++
Runtime Error
#include <cstdlib> #include <iostream> using namespace std; // a > b int gcd(int a, int b) { if (a < b) { cout << "Error : In using gcd function, must a > b.\n"; exit(1); } if (a % b == 0) { return b; } else { gcd(b, a % b); } } int main() { int a, b; cin >> a >> b; cout << gcd(a, b) <...
#include <cstdlib> #include <iostream> using namespace std; // a > b int gcd(int a, int b) { int r; while (1) { r = a % b; if (!r) { return b; } else { a = b; b = r; } } } int main() { int a, b; cin >> a >> b; cout << gcd(a, b) << endl; return 0; }
replace
6
14
6
15
0
p02256
C++
Runtime Error
#include <iostream> using namespace std; int main() { int x, y, a; cin >> x >> y; while (x % y != 0) { cout << a << endl; x = y; y = a; } cout << y << "\n"; }
#include <iostream> using namespace std; int main() { int x, y, a; cin >> x >> y; while (x % y != 0) { a = x % y; x = y; y = a; } cout << y << "\n"; }
replace
7
8
7
8
0
p02256
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (max(a, b) % min(a, b) == 0) { cout << min(a, b) << endl; return 0; } for (int i = min(a, b) / 2; i >= 1; --i) { if (a % i == 0 && b % i == 0) { cout << i << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (max(a, b) % min(a, b) == 0) { cout << min(a, b) << endl; return 0; } for (int j = 2; j <= min(a, b); ++j) { int i = min(a, b) / j; if (a % i == 0 && b % i == 0) { cout << i << endl; return 0; ...
replace
10
11
10
12
TLE
p02256
C++
Runtime Error
#include <iostream> using namespace std; int gcd(int x, int y) { int max; if (y % (x % y) == 0) { max = x % y; return max; } else { gcd(y, x % y); } } int main() { int x, y; cin >> x; cin >> y; if (x >= y) cout << gcd(x, y) << endl; if (y > x) cout << gcd(y, x) << endl; return...
#include <iostream> using namespace std; int gcd(int x, int y) { int max; if (x == y) { return x; } else if (y % (x % y) == 0) { max = x % y; return max; } else { gcd(y, x % y); } } int main() { int x, y; cin >> x; cin >> y; if (x >= y) cout << gcd(x, y) << endl; if (y > x) ...
replace
5
6
5
8
0
p02256
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); int a, b; cin >> a; cin >> b; for (;;) { if (a > b) a = a % b; else if (a < b) b = b % a; if (a * b == 0) break; } cout << a + b << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); int a, b; cin >> a; cin >> b; if (a - b == 0) { cout << a << endl; return 0; } for (;;) { if (a > b) a = a % b; else if (a < b) b = b % a; if (a * b == 0) break; } ...
insert
9
9
9
13
TLE
p02256
C++
Runtime Error
/// // File: alds1_1_b.cpp // Author: ymiyamoto // // Created on Mon Nov 13 03:00:08 2017 // #include <cstdint> #include <iostream> using namespace std; uint64_t gcd(uint64_t a, uint64_t b) { if (b > a) gcd(a, b); if (b == 0) return a; else return gcd(b, a % b); } int32_t main() { uint64_t a, b...
/// // File: alds1_1_b.cpp // Author: ymiyamoto // // Created on Mon Nov 13 03:00:08 2017 // #include <cstdint> #include <iostream> using namespace std; uint64_t gcd(uint64_t a, uint64_t b) { if (b > a) gcd(b, a); if (b == 0) return a; else return gcd(b, a % b); } int32_t main() { uint64_t a, b...
replace
14
15
14
15
0
p02256
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { long long x, y; cin >> x >> y; if (x < y) { long long t = y; y = x; x = t; } long long z = x % y; long long a = 0; for (long long i = 1; i < y + 1; i++) { if (y % i == 0 && z % i == 0) { a = i; } } cout << a << endl; }
#include <iostream> using namespace std; int main() { long long x, y; cin >> x >> y; if (x < y) { long long t = y; y = x; x = t; } while (1) { long long z = x % y; if (z == 0) { break; } else { x = y; y = z; } } long long a; for (int i = 1; i < y + 1; i++) {...
replace
10
14
10
22
TLE
p02256
C++
Runtime Error
#include <iostream> #define INPUT_FROM_FILE (1) #if INPUT_FROM_FILE #include <fstream> #endif int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } int main(int argc, char **argv) { #if INPUT_FROM_FILE std::ifstream ifs("test.txt"); #endif int a = 0; int b = 0; #if INPUT_FROM...
#include <iostream> #define INPUT_FROM_FILE (0) #if INPUT_FROM_FILE #include <fstream> #endif int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } int main(int argc, char **argv) { #if INPUT_FROM_FILE std::ifstream ifs("test.txt"); #endif int a = 0; int b = 0; #if INPUT_FROM...
replace
1
2
1
2
-8
p02256
C++
Runtime Error
#include <stdio.h> #include <stdlib.h> int main() { int a, b, c, r, x, y, flag; scanf("%d%d", &a, &b); if (a == b) { printf("%d\n", a); exit(1); } else if (a > b) { flag = 0; c = b; } else { c = a; flag = 1; } if (flag == 0) r = a % b; if (flag == 1) r = b % a; wh...
#include <stdio.h> #include <stdlib.h> int main() { int a, b, c, r, x, y, flag; scanf("%d%d", &a, &b); if (a == b) { printf("%d\n", a); return 0; } else if (a > b) { flag = 0; c = b; } else { c = a; flag = 1; } if (flag == 0) r = a % b; if (flag == 1) r = b % a; w...
replace
11
12
11
12
0
p02256
C++
Time Limit Exceeded
#include <iostream> #include <math.h> using namespace std; long long int gcd(long long int x, long long int y) { bool flag = true; while (flag) { if (x > y) { if (x % y != 0) { x = x % y; } if (x % y == 0) { return y; flag = false; } } if (y > x) { ...
#include <iostream> #include <math.h> using namespace std; int gcd(int x, int y) { if (x < y) { return gcd(y, x); } else if (x >= y && x % y != 0) { return gcd(x % y, y); } else { return y; } } int main() { long long int x, y; cin >> x >> y; cout << gcd(x, y) << endl; return 0; }
replace
4
25
4
11
TLE
p02256
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { long x, y; cin >> x >> y; while (x != 0 && y != 0) { if (x > y) { long tmp = 0; tmp = y; y = x % y; x = tmp; } else { long tmp = 0; tmp = x; x = y; y = tmp; } } if (x == 0) cout << y << endl;...
#include <iostream> using namespace std; int main() { long x, y; cin >> x >> y; while (x != 0 && y != 0) { if (x >= y) { long tmp = 0; tmp = y; y = x % y; x = tmp; } else { long tmp = 0; tmp = x; x = y; y = tmp; } } if (x == 0) cout << y << endl...
replace
7
8
7
8
TLE
p02256
C++
Runtime Error
#include <cstdlib> #include <iostream> using namespace std; int main() { int x, y; int ma, mi; cin >> x >> y; ma = max(x, y); mi = min(x, y); while (1) { int t = ma % mi; ma = max(t, mi); mi = min(t, mi); if (ma % mi == 0) break; } cout << mi << endl; return 0; }
#include <cstdlib> #include <iostream> using namespace std; int main() { int x, y; int ma, mi; cin >> x >> y; ma = max(x, y); mi = min(x, y); while (ma != mi) { int t = ma % mi; ma = max(t, mi); mi = min(t, mi); if (ma % mi == 0) break; } cout << mi << endl; return 0; }
replace
13
14
13
14
0
p02256
C++
Runtime Error
#include <iostream> using namespace std; int main() { long long x, y, c; cin >> x >> y; if (x < y) { c = y; y = x; x = c; } c = 0; while (!x == 0 || y == 0) { if (c % 2 == 0) { x = x % y; } else { y = y % x; } ++c; } cout << x + y << endl; return 0; }
#include <iostream> using namespace std; int main() { long long x, y, c; cin >> x >> y; if (x < y) { c = y; y = x; x = c; } c = 0; while (x != 0 && y != 0) { if (c % 2 == 0) { x = x % y; } else { y = y % x; } ++c; } cout << x + y << endl; return 0; }
replace
11
12
11
12
-8
p02256
C++
Runtime Error
#include <iostream> using namespace std; int main() { int a, b, c; bool check = true; cin >> a >> b; while (check) { if (a > b) { c = a % b; if (b % c == 0) check = false; a = c; } else { c = b % a; if (a % c == 0) check = false; b = c; } } co...
#include <iostream> using namespace std; int main() { int a, b, c; bool check = true; cin >> a >> b; if (a == b) { cout << a << endl; return 0; } while (check) { if (a > b) { c = a % b; if (b % c == 0) check = false; a = c; } else { c = b % a; if (a % c...
insert
7
7
7
11
0
p02256
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int x, y; cin >> x >> y; int a, b; if (x >= y) { a = x; b = y; } else { a = y; b = x; } for (int i = b; i >= 1; i--) { if (a % i == 0 && b % i == 0) { cout << i << endl; return 0; } } }
#include <iostream> #include <vector> using namespace std; int main() { int x, y; cin >> x >> y; int a, b; if (x >= y) { a = x; b = y; } else { a = y; b = x; } int c; while (true) { c = a % b; if (c == 0) { cout << b << endl; break; } else { a = b; b ...
replace
15
20
15
24
TLE
p02256
C++
Runtime Error
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> using namespace std; const double pi = acos(-1); #define nyan cout << "(=^•ω•^=)" << endl; #define int long long #define rep(i, n) for (int i = 0; i < n; i+...
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> using namespace std; const double pi = acos(-1); #define nyan cout << "(=^•ω•^=)" << endl; #define int long long #define rep(i, n) for (int i = 0; i < n; i+...
replace
18
26
18
26
-8
p02256
C++
Runtime Error
#include <cstdio> #include <iostream> #include <queue> #include <sstream> #include <stack> #include <vector> using namespace std; const int N_MAX = 1000000; int main() { int x, y; return -1; }
#include <cstdio> #include <iostream> #include <queue> #include <sstream> #include <stack> #include <vector> using namespace std; const int N_MAX = 1000000; int main() { int x, y; cin >> x; cin >> y; int residue = -1; int ans; while (residue != 0) { residue = max(x, y) % min(x, y); ans = min(x, ...
replace
13
14
13
30
255
p02256
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; void sorts(int *xx, int *yy); int main() { int x, y; cin >> x >> y; sorts(&x, &y); x = x % y; int ans = y; for (int i = x; i >= 0; i--) { if (y % i == 0 && x % i == 0) { ans = i; break; } } cout << ans << endl; } void sorts(int *xx, in...
#include <bits/stdc++.h> using namespace std; void sorts(int *xx, int *yy); int main() { int x, y; cin >> x >> y; sorts(&x, &y); x = x % y; if (!x) { cout << y << endl; return 0; } int ans = y; for (int i = x; i >= 0; i--) { if (y % i == 0 && x % i == 0) { ans = i; break; }...
insert
10
10
10
14
0
p02256
C++
Runtime Error
#include <iostream> using namespace std; int gcd(int a, int b); void swap(int *a, int *b); int main() { int a, b; cin >> a >> b; if (a < b) swap(a, b); cout << gcd(a, b) << endl; } void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int gcd(int a, int b) { while (1) { a = a %...
#include <iostream> using namespace std; int gcd(int a, int b); void swap(int *a, int *b); int main() { int a, b; cin >> a >> b; if (a < b) swap(a, b); cout << gcd(a, b) << endl; } void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int gcd(int a, int b) { if (a % b == 0) ret...
insert
24
24
24
26
0
p02256
C++
Time Limit Exceeded
// // Write a program which finds the greatest common divisor of two natural // numbers a and b // #include <iostream> using namespace std; void read(int &x, int &y); int calcGcd(const int x, const int y); void write(const int gcd); int main() { int x = 0, y = 0; int ret = 0; read(x, y); ret = x > y ? calcGc...
// // Write a program which finds the greatest common divisor of two natural // numbers a and b // #include <iostream> using namespace std; void read(int &x, int &y); int calcGcd(const int x, const int y); void write(const int gcd); int main() { int x = 0, y = 0; int ret = 0; read(x, y); ret = x > y ? calcGc...
insert
25
25
25
28
TLE
p02256
C++
Runtime Error
#include <algorithm> #include <stdio.h> int gcd(int, int); int main() { int x, y, z; scanf("%d %d\n", x, y); z = gcd(x, y); printf("%d\n", z); return 0; } int gcd(int x, int y) { int r; while (y > 0) { r = x % y; x = y; y = r; } return x; }
#include <algorithm> #include <stdio.h> int gcd(int, int); int main() { int x, y, z; scanf("%d %d", &x, &y); z = gcd(x, y); printf("%d\n", z); return 0; } int gcd(int x, int y) { int r; while (y > 0) { r = x % y; x = y; y = r; } return x; }
replace
7
8
7
8
-11
p02256
C++
Runtime Error
#include <iostream> using namespace std; long int gcd(int a, int b) { if (a < b) return gcd(b, a); if (b == 1) return a; return gcd(b, a % b); } int main() { long int x, y; cin >> x >> y; cout << gcd(x, y) << endl; return 0; }
#include <iostream> using namespace std; long int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long int x, y; cin >> x >> y; cout << gcd(x, y) << endl; return 0; }
replace
4
7
4
5
-8
p02256
C++
Runtime Error
#include <stdio.h> int main(void) { int x; int y; int r; int tmp; scanf("%d %d", &x, &y); if (y >= x) { x = tmp; x = y; y = tmp; } while (1) { r = x % y; if (r == 0) { printf("%d\n", y); break; } x = y; y = r; } return 0; }
#include <stdio.h> int main(void) { int x; int y; int r; int tmp; scanf("%d %d", &x, &y); if (y >= x) { tmp = x; x = y; y = tmp; } while (1) { r = x % y; if (r == 0) { printf("%d\n", y); break; } x = y; y = r; } return 0; }
replace
10
11
10
11
0
p02256
C++
Time Limit Exceeded
#include <stdio.h> int main() { int a, b, c; scanf("%d %d", &a, &b); c = a > b ? b : a; while (c > 0 && (a % c || b % c)) c--; printf("%d\n", c); return 0; }
#include <stdio.h> int main() { int a, b, c; scanf("%d %d", &a, &b); if (a < b) { c = a; a = b; b = c; } while (b) { c = b; b = a % b; a = c; } printf("%d\n", a); return 0; }
replace
5
9
5
16
TLE
p02256
C++
Runtime Error
#include <stdio.h> int gcd(int x, int y) { return (x % y > 0 || x > y) ? gcd(y, x % y) : y; } int main() { int x, y; int w; scanf("%d %d", &x, &y); w = gcd(x, y); printf("%d\n", w); }
#include <stdio.h> int gcd(int x, int y) { return (x % y > 0) ? gcd(y, x % y) : y; } int main() { int x, y; int w; scanf("%d %d", &x, &y); w = gcd(x, y); printf("%d\n", w); }
replace
1
2
1
2
-8
p02256
C++
Runtime Error
#include <stdio.h> int gcd(int x, int y) { int ans; if (x == 1 || y == 1) { return x * y; } else if (x > y) { ans = gcd(y, x % y); } else { ans = gcd(x, y % x); } return ans; } int main(void) { int x, y; scanf("%d %d", &x, &y); printf("%d\n", gcd(x, y)); return 0; }
#include <stdio.h> int gcd(int x, int y) { int ans; if (x == 0) { return y; } else if (y == 0) { return x; } else if (x > y) { ans = gcd(y, x % y); } else { ans = gcd(x, y % x); } return ans; } int main(void) { int x, y; scanf("%d %d", &x, &y); printf("%d\n", gcd(x, y)); return 0...
replace
4
6
4
8
-8
p02256
C++
Runtime Error
#include <cmath> #include <ctype.h> #include <iomanip> #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main(void) { int x, y, d, a, b; cin >> x >> y; if (y > x) { b = y; y = x; x = b; } a = x % y; for (d = a;; d--) { if (y % d == 0 && a % d == 0) { ...
#include <cmath> #include <ctype.h> #include <iomanip> #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main(void) { int x, y, d, a, b; cin >> x >> y; if (y > x) { b = y; y = x; x = b; } if (x == y) { cout << x << endl; return 0; } a = x % y; for ...
insert
17
17
17
21
0
p02257
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { int x, y, n, b = 0, o; cin >> n; for (o = 0; o < n; o++) { cin >> x; for (y = 2; y < x; y++) { if (x % y == 0) { goto loop; } } b++; loop:; } cout << b << endl; }
#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { int x, y, n, b = 0, o; cin >> n; for (o = 0; o < n; o++) { cin >> x; for (y = 2; y * y <= x; y++) { if (x % y == 0) { goto loop; } } b++; loop:; } cout << b << endl; }
replace
8
9
8
9
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; int A[n], count = 0; for (int i = 0; i < n; i++) { cin >> A[i]; } for (int i = 0; i < n; i++) { int L = A[i]; int M = sqrt(L); for (int x = 2; x < L; x++) { if (L % x == 0) { count--; ...
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; int A[n], count = 0; for (int i = 0; i < n; i++) { cin >> A[i]; } for (int i = 0; i < n; i++) { int L = A[i]; int M = sqrt(L); for (int x = 2; x <= M; x++) { if (L % x == 0) { count--; ...
replace
14
15
14
15
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; bool is_prime[50000000]; int main() { for (int i = 0; i < 50000000; i++) { is_prime[i] = true; } is_prime[0] = false; for (int i = 1; i < 50000000; i++) { if (is_prime[i]) { for (int j = i * 3 + 1; j < 50000000; j += 2 * i + 1) { is_prime[j] = fa...
#include <iostream> using namespace std; bool is_prime[50000000]; int main() { for (int i = 0; i < 50000000; i++) { is_prime[i] = true; } is_prime[0] = false; for (int i = 1; i * i + i < 25000000; i++) { if (is_prime[i]) { for (int j = i * 3 + 1; j < 50000000; j += 2 * i + 1) { is_prime...
replace
11
12
11
12
TLE
p02257
Python
Time Limit Exceeded
prime = set([2]) for i in range(3, 100000000, 2): for j in prime: if i % j == 0: break else: prime.add(i) n = int(input()) cnt = 0 for i in (int(input()) for _ in range(n)): if i in prime: cnt += 1 print(cnt)
import sys from math import * readline = sys.stdin.readline def isPrime(x): if x == 2 or x == 3: return True elif x % 2 == 0 or x % 3 == 0: return False s = ceil(sqrt(x)) for i in range(5, s + 1, 2): if x % i == 0: return False return True print(sum(isPrime(i...
replace
0
13
0
19
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; using ll = long long; #define debug(x) cerr << #x << ": " << x << endl; #define line() cerr << "---------------" << endl; bool isPrime(int x) { if (x == 1) return false; for (int i = 2; i < x; i++) { if (x % i == 0) { return false; } } return true; } ...
#include <iostream> using namespace std; using ll = long long; #define debug(x) cerr << #x << ": " << x << endl; #define line() cerr << "---------------" << endl; bool isPrime(int x) { if (x == 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) { return false; } } return tru...
replace
10
11
10
11
TLE
p02257
C++
Runtime Error
#include <iostream> using namespace std; #define CALC_PRIME_MAX 10000 // _/10 ^ 8 #define PRIME_ELEMENT_MAX 1229 // prime( _/10 ^ 8 ) int prime_number[PRIME_ELEMENT_MAX]; bool isPrime(int element) { for (int i = 0; prime_number[i] * prime_number[i] <= element; i++) { if (element % prime_number[i] == 0) ...
#include <iostream> using namespace std; #define CALC_PRIME_MAX 10007 // _/10 ^ 8 + next prime #define PRIME_ELEMENT_MAX 1230 // prime( _/10 ^ 8 ) + 1(10007) int prime_number[PRIME_ELEMENT_MAX]; bool isPrime(int element) { for (int i = 0; prime_number[i] * prime_number[i] <= element; i++) { if (element % pr...
replace
4
6
4
6
0
p02257
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; bool isPrime(int val); int countPrime(vector<int> &array); int main() { int size; vector<int> array; cin >> size; for (int i = 0; i < size; i++) { int tmp; cin >> tmp; array.push_back(tmp); } cout << countPrime(array) << endl; return...
#include <iostream> #include <vector> using namespace std; bool isPrime(int val); int countPrime(vector<int> &array); int main() { int size; vector<int> array; cin >> size; for (int i = 0; i < size; i++) { int tmp; cin >> tmp; array.push_back(tmp); } cout << countPrime(array) << endl; return...
replace
34
35
34
35
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> int main(void) { std::ios::sync_with_stdio(false); int n, COUNT = 0; std::cin >> n; int x; for (int i = 0; i < n; ++i) { std::cin >> x; if (x == 2) { ++COUNT; } else if (x % 2 != 0) { bool FLUG = false; int Max = static_cast<int>(x / 2) + 1; for (int i =...
#include <iostream> int main(void) { std::ios::sync_with_stdio(false); int n, COUNT = 0; std::cin >> n; int x; for (int i = 0; i < n; ++i) { std::cin >> x; if (x == 2) { ++COUNT; } else if (x % 2 != 0) { bool FLUG = false; for (int i = 3; i * i <= x; i += 2) { if (x % i =...
replace
12
14
12
13
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; void PrimeNumSum(int &sum, unsigned int &num) { unsigned int divisor = num / 2 + 1; if (divisor == 2) { sum++; return; } while (divisor >= 2) { if (num % divisor == 0) { return; } divisor--; } sum++; } int main() { in...
#include <cmath> #include <iostream> using namespace std; void PrimeNumSum(int &sum, unsigned int &num) { unsigned int divisor = sqrt(num) + 1; if (divisor == 2) { sum++; return; } while (divisor >= 2) { if (num % divisor == 0) { return; } divisor--; } sum++; } int main() { ...
replace
6
7
6
7
TLE
p02257
C++
Runtime Error
#include <cmath> #include <iostream> #include <vector> bool is_prime(int a); int main() { int n; int cnt = 0; std::cin >> n; std::vector<int> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } for (int i = 0; i < n; i++) { bool flag = is_prime(a[i]); if (flag) cnt++; } std::co...
#include <cmath> #include <iostream> #include <vector> bool is_prime(int a); int main() { int n; int cnt = 0; std::cin >> n; std::vector<int> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } for (int i = 0; i < n; i++) { bool flag = is_prime(a[i]); if (flag) cnt++; } std::co...
replace
24
25
24
30
-8
p02257
C++
Runtime Error
#include <cmath> #include <iostream> #include <vector> using namespace std; void Makepn(vector<int> &v, int n) { int count = 1; int i, j; vector<bool> pn(n + 1, true); pn[0] = false; pn[1] = false; for (i = 2; i < sqrt(n); i++) { if (pn[i]) { for (j = 0; i * (j + 2) < n; j++) { pn[i * (j ...
#include <cmath> #include <iostream> #include <vector> using namespace std; void Makepn(vector<int> &v, int n) { int count = 0; int i, j; vector<bool> pn(n + 1, true); pn[0] = false; pn[1] = false; for (i = 2; i < sqrt(n); i++) { if (pn[i]) { for (j = 0; i * (j + 2) < n; j++) { pn[i * (j ...
replace
6
7
6
7
0
p02257
C++
Time Limit Exceeded
#include <cstdio> using namespace std; bool Prime(int x) { for (int i = 2; i < (x / 2 + 1); i++) { if (x % i == 0) { return false; } } return true; } int main() { int n; scanf("%d", &n); int N[n]; for (int i = 0; i < n; i++) { scanf(" %d", &N[i]); } int cnt; for (int i = 0; i < n; ...
#include <cstdio> using namespace std; bool Prime(int x) { for (int i = 2; i * i <= x; i++) { if (x % i == 0) { return false; } } return true; } int main() { int n; scanf("%d", &n); int N[n]; for (int i = 0; i < n; i++) { scanf(" %d", &N[i]); } int cnt; for (int i = 0; i < n; i++) ...
replace
3
4
3
4
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> #include <math.h> #include <stdio.h> #include <string.h> using namespace std; #define MAX 256 int f(int x) { if (x == 2) return 1; if (x % 2 == 0) return 0; for (int i = 3; i <= x / 2; i += 2) { if (x % i == 0) return 0; } return 1; } int main(void) { int a; scanf...
#include <iostream> #include <math.h> #include <stdio.h> #include <string.h> using namespace std; #define MAX 256 int f(int x) { if (x == 2) return 1; if (x % 2 == 0) return 0; for (int i = 3; i <= (int)sqrt(x); i += 2) { if (x % i == 0) return 0; } return 1; } int main(void) { int a; ...
replace
13
14
13
14
TLE
p02257
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define reps(i, f, n) for (int i = (f); i <= (n); ++i) #define outl(x) cout << (x) << '\n' #define FAST() cin.tie(0), ios::sync_with_stdio(false) template <class A, class B> inline bool chmax(A &a, B b) { return b > a ? a = ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define reps(i, f, n) for (int i = (f); i <= (n); ++i) #define outl(x) cout << (x) << '\n' #define FAST() cin.tie(0), ios::sync_with_stdio(false) template <class A, class B> inline bool chmax(A &a, B b) { return b > a ? a = ...
replace
17
18
17
18
TLE
p02257
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 2; j < a; j++) { if (a % j == 0) { cnt++; break; } } } cout << n - cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 0; i < n; i++) { int a; cin >> a; int t = sqrt(a); for (int j = 2; j <= t; j++) { if (a % j == 0) { cnt++; break; } } } cout << n - cnt << endl; return...
replace
12
13
12
14
TLE
p02257
C++
Runtime Error
#include <cmath> #include <iostream> using namespace std; int prs[5000]; int pri = 1; int isPrime(int a) { int flg; if (sqrt(a) > prs[pri]) { for (int i = prs[pri] + 2; i <= sqrt(a); i += 2) { flg = 1; for (int j = 0; j <= pri; j++) { if (sqrt(i) < prs[i]) break; if (i % ...
#include <cmath> #include <iostream> using namespace std; int prs[10000]; int pri = 1; int isPrime(int a) { int flg; if (sqrt(a) > prs[pri]) { for (int i = prs[pri] + 2; i <= sqrt(a); i += 2) { flg = 1; for (int j = 0; j <= pri; j++) { if (sqrt(i) < prs[i]) break; if (i %...
replace
4
5
4
5
0
p02257
C++
Time Limit Exceeded
#include <iostream> typedef long long ll; bool isPrime(ll a); int main() { using namespace std; ll A[10001]; int n, prime = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i]; if (isPrime(A[i])) { prime++; } } cout << prime << endl; return 0; } bool isPrime(ll a) { for (ll i = ...
#include <iostream> typedef long long ll; bool isPrime(ll a); int main() { using namespace std; ll A[10001]; int n, prime = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i]; if (isPrime(A[i])) { prime++; } } cout << prime << endl; return 0; } bool isPrime(ll a) { for (ll i = ...
replace
20
21
20
21
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { int n, m, i, count; cin >> n; count = 0; for (int j = 0; j < n; ++j) { cin >> m; if (m == 2) ++count; else if (m < 2 || m % 2 == 0) { continue; } else { i = 3; while (i <= sqrt(m)) { if (m % ...
#include <cmath> #include <iostream> using namespace std; int main() { int n, m, i, count; cin >> n; count = 0; for (int j = 0; j < n; ++j) { cin >> m; if (m == 2) ++count; else if (m < 2 || m % 2 == 0) { continue; } else { i = 3; while (i <= sqrt(m)) { if (m % ...
replace
19
20
19
20
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <...
#include <algorithm> #include <bitset> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <...
replace
32
33
32
34
TLE
p02257
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int maxn = 50001; int prime[maxn], cnt, res; bool isprime[maxn]; void maketable() { int base = (int)sqrt((double)maxn); isprime[0] = isprime[1] = 1; for (int i = 2; i < base; i++) { if (!isprime[i]) { prime[cnt++] = i; for (int j = i + i; j ...
#include <bits/stdc++.h> using namespace std; const int maxn = 50001; int prime[maxn], cnt, res; bool isprime[maxn]; void maketable() { int base = (int)sqrt((double)maxn); isprime[0] = isprime[1] = 1; for (int i = 2; i < maxn; i++) { // 此处i<maxn与以前的不同 if (!isprime[i]) { prime[cnt++] = i; for ...
replace
13
14
13
14
0
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; bool primenum(int x); int main() { int n; int i; int num[10000]; int ans = 0; cin >> n; for (i = 0; i < n; i++) { cin >> num[i]; } for (i = 0; i < n; i++) { if (primenum(num[i]) == true) ans++; } cout << ans << "\n"; } bool primenum(int ...
#include <iostream> using namespace std; bool primenum(int x); int main() { int n; int i; int num[10000]; int ans = 0; cin >> n; for (i = 0; i < n; i++) { cin >> num[i]; } for (i = 0; i < n; i++) { if (primenum(num[i]) == true) ans++; } cout << ans << "\n"; } bool primenum(int ...
insert
38
38
38
39
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n, a[11000], cnt = 0; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) { bool sosu = true; for (int j = 2; j < a[i]; ++j) { if (a[i] % j == 0) { sosu = false; break; } } if (...
#include <iostream> using namespace std; int main() { int n, a[11000], cnt = 0; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) { bool sosu = true; for (int j = 2; j * j <= a[i]; ++j) { if (a[i] % j == 0) { sosu = false; break; } } ...
replace
11
12
11
12
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int N; int x; int count = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> x; for (int j = 2; j < x / 2 + 1; j++) { if (x != 2) { if (x % j == 0) { count++; break; } } } } cout << N - count ...
#include <iostream> using namespace std; int main() { int N; int x; int count = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> x; for (int j = 2; j * j <= x; j++) { if (x % j == 0) { count++; break; } } } cout << N - count << endl; return 0; }
replace
10
16
10
14
TLE
p02257
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; #define MAX_N 1e6 int main(void) { vector<bool> eratos(MAX_N, true); eratos[0] = eratos[1] = false; for (int i = 2; i * i < MAX_N; i++) { if (eratos[i]) { for (int j = 2; i * j < MAX_N; j++) { eratos[i * j] = false; } } } ...
#include <iostream> #include <vector> using namespace std; #define MAX_N (1e8) + 1 int main(void) { vector<bool> eratos(MAX_N, true); eratos[0] = eratos[1] = false; for (int i = 2; i * i < MAX_N; i++) { if (eratos[i]) { for (int j = 2; i * j < MAX_N; j++) { eratos[i * j] = false; } }...
replace
4
5
4
5
0
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
replace
30
31
30
34
TLE
p02257
C++
Memory Limit Exceeded
#include <iostream> #include <vector> using namespace std; #define MAX_N (1e9) + 1 int main(void) { //????????????????????? vector<bool> eratos(MAX_N, true); eratos[0] = eratos[1] = false; for (int i = 2; i * i < MAX_N; i++) if (eratos[i]) for (int j = 2; i * j < MAX_N; j++) eratos[i * j] = ...
#include <iostream> #include <vector> using namespace std; #define MAX_N (1e8) + 1 int main(void) { //????????????????????? vector<bool> eratos(MAX_N, true); eratos[0] = eratos[1] = false; for (int i = 2; i * i < MAX_N; i++) if (eratos[i]) for (int j = 2; i * j < MAX_N; j++) eratos[i * j] = ...
replace
4
5
4
5
MLE