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
p03107
Python
Runtime Error
s = input() print(2 * min(s.count(0), s.count(1)))
s = input() print(2 * min(s.count("0"), s.count("1")))
replace
1
2
1
2
TypeError: must be str, not int
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03107/Python/s119508612.py", line 2, in <module> print(2 * min(s.count(0), s.count(1))) TypeError: must be str, not int
p03107
Python
Time Limit Exceeded
s = list(input()) n = len(s) pos = 0 cnt = 0 while pos != n - 1 and n != 0: if s[pos] != s[pos + 1]: del s[pos] del s[pos] pos = 0 n -= 2 cnt += 2 else: pos += 1 print(cnt)
s = input() a = s.count("0") b = s.count("1") print(min(a, b) * 2)
replace
0
16
0
4
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5005; const ll mod = 1e9 + 7; const ll INF = 1e9 + 7; char str[10005]; int main() { scanf("%s", str); int len = strlen(str); int l = 0, r = 0; int s = 0; for (int q = 0; q < len; q++) { if (str[q] == '1') { if (l...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5005; const ll mod = 1e9 + 7; const ll INF = 1e9 + 7; char str[200000]; int main() { scanf("%s", str); int len = strlen(str); int l = 0, r = 0; int s = 0; for (int q = 0; q < len; q++) { if (str[q] == '1') { if (...
replace
7
8
7
8
0
p03107
Python
Runtime Error
def solve(s): count = 0 i = 0 while True: if i >= len(s) - 1: break if s[i] != s[i + 1]: count += 1 s = s[0:i] + s[i + 2 :] i -= 1 continue i += 1 return count def main(): S = input() # a, b, k = [int(a) for a...
def solve(s): one = 0 zero = 0 for i in range(len(s)): if s[i] == "1": one += 1 elif s[i] == "0": zero += 1 return min(zero, one) def main(): S = input() # a, b, k = [int(a) for a in input().split()] print(solve(S) * 2) if __name__ == "__main__": ...
replace
1
14
1
9
0
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int count0 = 0, count1 = 0; for (int i = 0; i = s.size(); ++i) { if (s[i] == '0') ++count0; else ++count1; } int ans = 2 * min(count0, count1); cout << ans << endl; retu...
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int count0 = 0, count1 = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == '0') ++count0; else ++count1; } int ans = 2 * min(count0, count1); cout << ans << endl; retu...
replace
10
11
10
11
TLE
p03107
Python
Time Limit Exceeded
S = input() S_list = [int(S[i]) for i in range(len(S))] ans = 0 rm_list = [] for aaa in range(len(S) // 2): for i in range(len(S_list) - 1): if S_list[i] != S_list[i + 1] and i not in rm_list: rm_list.append(i) rm_list.append(i + 1) S_list = [S_list[i] for i in range(len(S_list))...
S = input() a = sum([int(S[i]) for i in range(len(S))]) b = len(S) - a print(2 * min(a, b))
replace
1
15
1
4
TLE
p03107
Python
Time Limit Exceeded
import re s = input() pattern = "(01)|(10)" count = 0 diff = 1 while diff: ssub = re.sub(pattern, "", s) diff = len(s) - len(ssub) count += diff s = ssub print(count)
import re s = input() zero = re.findall("0", s) one = re.findall("1", s) print(2 * min(len(zero), len(one)))
replace
3
15
3
6
TLE
p03107
Python
Time Limit Exceeded
#!/usr/bin/env python3 import sys def solve(S: str): nS = len(S) pS = "" while pS != S: pS = S S = S.replace("01", "") S = S.replace("10", "") print(nS - len(S)) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): ...
#!/usr/bin/env python3 import sys def solve(S: str): print(min(S.count("0"), S.count("1")) * 2) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() S = next(tokens) # type: str solve(S) if...
replace
5
12
5
6
TLE
p03107
Python
Time Limit Exceeded
S = input() subS = S cnt = 0 while True: flg = True if "01" in subS: flg = False subS = subS.replace("01", "", 1) cnt += 2 if "10" in subS: flg = False subS = subS.replace("10", "", 1) cnt += 2 if flg: break print(cnt)
S = input() zeroSum = 0 oneSum = 0 for _ in S: if _ == "0": zeroSum += 1 if _ == "1": oneSum += 1 t = max(zeroSum, oneSum) - min(zeroSum, oneSum) print(len(S) - t)
replace
1
16
1
12
TLE
p03107
Python
Time Limit Exceeded
#!/usr/bin/env python3 s = input() n = len(s) while True: ns = s.replace("01", "").replace("10", "") if ns == s: break s = ns print(n - len(s))
#!/usr/bin/env python3 s = input() n = len(s) c = 0 p = "" count = 0 for i in s: if i == p: count += 1 else: c = count - c count = 1 p = i c = count - c print(n - abs(c))
replace
3
9
3
15
TLE
p03107
Python
Time Limit Exceeded
import re S = input() raw = len(S) prev = len(S) while True: S = re.sub(r"(10)+", "", S) S = re.sub(r"(01)+", "", S) if prev > len(S): prev = len(S) else: break print(raw - len(S))
import re S = input() num_1 = S.count("1") num_0 = S.count("0") print(min(num_0, num_1) * 2)
replace
3
13
3
6
TLE
p03107
Python
Time Limit Exceeded
s = input() ans = 0 while "01" in s or "10" in s: s_next = s.replace("01", "") ans += len(s) - len(s_next) s = s_next s_next = s.replace("10", "") ans += len(s) - len(s_next) s = s_next print(ans)
s = input() ans = 0 s_0 = s.replace("0", "") n_0 = len(s) - len(s_0) s_1 = s.replace("1", "") n_1 = len(s) - len(s_1) print(2 * min(n_0, n_1))
replace
3
11
3
10
TLE
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <string> #include <vector> using namespace std; int main() { string str; cin >> str; int start = str.size(), end; bool f = true; while (f) { f = false; for (int i = 0; i < str.size() - 3; ++i) { if (str....
#include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <string> #include <vector> using namespace std; int main() { string str; cin >> str; int start = str.size(), end; bool f = true; for (int i = 0; i < str.size() - 3; ++i) { if (str.size() > 3) { if (str[i] != ...
replace
16
29
16
33
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; using M = map<int, int>; int main() { string s, t = ""; cin >> s; int b; int ans = 0; do { t = ""; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; using M = map<int, int>; int main() { string s, t = ""; cin >> s; int a = 0, b = 0; rep(i, s.size()) { ...
replace
11
28
11
19
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pq priority_queue #define mp make_pair #define cauto const auto & #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define clr(ar, val) memset(ar, val, sizeof(ar)) typedef lo...
#include <bits/stdc++.h> using namespace std; #define pq priority_queue #define mp make_pair #define cauto const auto & #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define clr(ar, val) memset(ar, val, sizeof(ar)) typedef lo...
replace
82
84
82
88
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) // #define int long ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) // #define int long ...
replace
48
54
48
63
TLE
p03107
C++
Runtime Error
/* Task: Author: John_05 State: Unknown Lang: C++ Solution: */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int INF = 2e9 + 10; #define fi first #define se second #define pb push_back #define mp make_pair int read() { int xx = 0, ww = 1; char ch = getchar()...
/* Task: Author: John_05 State: Unknown Lang: C++ Solution: */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int INF = 2e9 + 10; #define fi first #define se second #define pb push_back #define mp make_pair int read() { int xx = 0, ww = 1; char ch = getchar()...
replace
34
35
34
35
0
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #inc...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #inc...
replace
342
355
342
352
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long double PI = (acos(-1)); const long long MOD = 1000000007; struct Edge { long long to; long long cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; const long long INF = 1LL << 60; #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long double PI = (acos(-1)); const long long MOD = 1000000007; struct Edge { long long to; long long cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; const long long INF = 1LL << 60; #defin...
replace
236
266
236
242
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // #pragma GCC optimize("Ofast,no-stack-protector") // #pragma GCC target("mmx,avx,fma") // #pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // #pragma GCC optimize("Ofast,no-stack-protector") // #pragma GCC target("mmx,avx,fma") // #pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for...
replace
115
116
115
116
0
p03107
C++
Runtime Error
#include <algorithm> #include <functional> #include <iostream> #include <math.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; int ctoi(const char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': r...
#include <algorithm> #include <functional> #include <iostream> #include <math.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; int ctoi(const char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': r...
replace
54
55
54
55
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; char str[10005]; int main() { int a = 0, b = 0; scanf("%s", str); for (int i = 0; i < strlen(str); i++) { if (str[i] == '1') a++; else b++; } printf("%d\n", a > b ? 2 * b : 2 * a); return 0; }
#include <bits/stdc++.h> using namespace std; char str[100005]; int main() { int a = 0, b = 0; scanf("%s", str); for (int i = 0; i < strlen(str); i++) { if (str[i] == '1') a++; else b++; } printf("%d\n", a > b ? 2 * b : 2 * a); return 0; }
replace
2
3
2
3
0
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v....
#include <algorithm> #include <cmath> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v....
replace
25
40
25
28
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; while (!s.empty()) { int n = s.size(); vector<int> v; for (int i = 0; i < n - 1; i++) { if (s[i] != s[i + 1]) { v.emplace_back(i++); } } reverse(v.begin(), v.end()); for (auto...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a = count(s.begin(), s.end(), '0'), b = count(s.begin(), s.end(), '1'); cout << 2 * min(a, b) << endl; return 0; }
replace
6
23
6
8
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define RREP(i...
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define RREP(i...
replace
23
24
23
24
-11
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; vector<int> a; for (int i = 0; i < s.size(); i++) { a.push_back(s[i] - '0'); while (a.size() > 1 && abs(a[a.size() - 1] - a[a.size() - 2]) > 0) a.erase(a.begin() + a.size() - 1), a.erase(a.begin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; vector<int> a; for (int i = 0; i < s.size(); i++) { a.push_back(s[i] - '0'); while (a.size() > 1 && abs(a[a.size() - 1] - a[a.size() - 2]) > 0) a.erase(a.begin() + a.size() - 1), a.erase(a.begin...
replace
13
14
13
14
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> #define MAX 100005 using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif string str; cin >> str; int len ...
#include <bits/stdc++.h> #define MAX 100005 using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif string str; cin >> str; int len ...
replace
29
30
29
36
0
p03107
C++
Runtime Error
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC push_options #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define pb push_back #define __V vector #define all(x) x.begin(), x.end() #define oit ostream_iterator #define mod 998244353ll using namespace std; void doin() { cin.tie(); ...
// #pragma GCC target ("avx2") #pragma GCC optimize("Ofast") #pragma GCC push_options #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define pb push_back #define __V vector #define all(x) x.begin(), x.end() #define oit ostream_iterator #define mod 998244353ll using namespace std; void doin() { cin.tie(...
replace
0
1
0
1
0
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<long long> func(vector<long long> &vv) { long long temp; temp = vv[0]; bool flag = false; int fl = 0; for (long long j = 1; j < vv.size(); j++) { if (temp != vv[j]) { vv.erase(vv.begin() + j - 1); vv.erase...
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<long long> func(vector<long long> &vv) { long long temp; temp = vv[0]; bool flag = false; int fl = 0; for (long long j = 1; j < vv.size(); j++) { if (temp != vv[j]) { vv.erase(vv.begin() + j - 1); vv.erase...
insert
16
16
16
17
TLE
p03107
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <typeinfo> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; cin...
#include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <typeinfo> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; cin...
replace
25
26
25
28
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; map<char, int> c; for (int i = 0; i < s.size(); i++) c[s.at(i)]++; cout << min(c.at('0'), c.at('1')) * 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; map<char, int> c; for (int i = 0; i < s.size(); i++) c[s.at(i)]++; cout << min(c['0'], c['1']) * 2 << endl; }
replace
8
9
8
9
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; for (int i = 0; i < s.size() - 1; i++) { if (s.substr(i, 2) == "01" || s.substr(i, 2) == "10") { s.erase(s.begin() + i, s.begin() + i + 2); ans += 2; i -= 3; i = max(-1, i); } } cout...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; for (int i = 0; i < s.size() - 1; i++) { if (s.substr(i, 2) == "01" || s.substr(i, 2) == "10") { s.erase(s.begin() + i, s.begin() + i + 2); ans += 2; i -= 3; i = max(-1, i); if (s.size...
insert
14
14
14
17
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 1) > this->size() (which is 0)
p03107
C++
Time Limit Exceeded
// AtCoder ABC120 C - Unification #include <bits/stdc++.h> using namespace std; using ll = int64_t; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) std::string replaceStringAll(std::string str, const std::string &replace, const std::string &with) { if (...
// AtCoder ABC120 C - Unification #include <bits/stdc++.h> using namespace std; using ll = int64_t; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) std::string replaceStringAll(std::string str, const std::string &replace, const std::string &with) { if (...
replace
24
27
24
32
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define debug(a) cout << #a << ": " << a << endl; int main() { string S; cin >> S; int cnt = 0; while ((int)S.size() != 0) { int find01 = S.find("01"); int find10 = S.find("10"); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define debug(a) cout << #a << ": " << a << endl; int main() { string S; cin >> S; int cnt0 = count(S.begin(), S.end(), '0'); int cnt1 = count(S.begin(), S.end(), '1'); cout << min(cnt0...
replace
12
30
12
15
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { int sz = s.size(); while (s.size() > 1) { int flag = 0; for (int i = 0; i < s.size() - 1; i++) { if ((s[i] == '0' && s[i + 1] == '1') || (s[i] == '1' && s[i + 1] == '0')) { s....
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { int sz = s.size(); while (s.size() > 1) { int flag = 0; for (int i = 0; i < s.size() - 1; i++) { if ((s[i] == '0' && s[i + 1] == '1') || (s[i] == '1' && s[i + 1] == '0')) { s....
replace
15
16
15
20
TLE
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int ans = 0; while (s.size() > 0 && count(s.begin(), s.end(), s[0]) < s.size()) { for (int i = 0; i < s.size() - 1; ++i) { if ((s[i] == '0' && s[i + 1] == '1') || (s[i] == '1' ...
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int zero = count(s.begin(), s.end(), '0'); int one = count(s.begin(), s.end(), '1'); int ans = 2 * min(zero, one); cout << ans << endl; return 0; }
replace
10
21
10
13
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); int a = 0; int b = 0; for (int i = 0; i < n; i++) { if (s.at(i) == '0') a++; else b++; } int m = n; int r = 0; while (a > 0 && b > 0) { string t = s; int m = t.size(); ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); int a = 0; int b = 0; for (int i = 0; i < n; i++) { if (s.at(i) == '0') a++; else b++; } cout << min(a, b) * 2 << endl; }
replace
16
34
16
17
TLE
p03107
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main(void) { string S; cin >> S; int N = S.size(); int first = 0, second = 1; int ans = 0; while (second < N) { if (S[first] != S[second]) { ans += 2; S[first] = S[second] = 'x'; while (first >= 0 && S[first] == 'x') ...
#include <iostream> #include <string> using namespace std; int main(void) { string S; cin >> S; int sum[2] = {0, 0}; for (auto i : S) sum[i - '0']++; cout << (S.size() - (max(sum[0], sum[1]) - min(sum[0], sum[1]))) << endl; return 0; }
replace
8
28
8
12
TLE
p03107
C++
Runtime Error
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 100000 int main(void) { char input[N]; char stack[N]; scanf("%s", input); int eraseCnt = 0; stack[0] = input[0]; int sCnt, iCnt; for (sCnt = 0, iCnt = 1; input[iCnt] != '\0';) { // printf("%c %c\n",stack[sCnt],input [iCnt]); if...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 200000 int main(void) { char input[N]; char stack[N]; scanf("%s", input); int eraseCnt = 0; stack[0] = input[0]; int sCnt, iCnt; for (sCnt = 0, iCnt = 1; input[iCnt] != '\0';) { // printf("%c %c\n",stack[sCnt],input [iCnt]); if...
replace
3
4
3
4
0
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef long long LL; using namespace std; int main() { string s; cin >> s; int num0, num1; num0 = count(s.begin(), s.end(), '0'); num1 = count(s.begin(), s.end(), '1'); cout << min(num0, num1) * 2; while (1) ; return 0; }
#include <bits/stdc++.h> typedef long long LL; using namespace std; int main() { string s; cin >> s; int num0, num1; num0 = count(s.begin(), s.end(), '0'); num1 = count(s.begin(), s.end(), '1'); cout << min(num0, num1) * 2; return 0; }
delete
12
14
12
12
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int b, w; b = 0; w = 0; for (int i = 0;; i++) { if (s.at(i) == '1') { b++; } else { w++; } } int Ans = min(b, w) * 2; cout << Ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int b, w; b = 0; w = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) == '1') { b++; } else { w++; } } int Ans = min(b, w) * 2; cout << Ans << endl; }
replace
11
12
11
12
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 4) >= this->size() (which is 4)
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { string s; cin >> s; int cnt = 0; int i = 0; while (s.size() != 0 && s.size() != 1) { if ((s.at(i) - '0') + (s.at(i + 1) - '0') == 1) { s.erase(i, 2); i = -1; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { string s; cin >> s; vector<int> cnt(2, 0); rep(i, s.size()) { cnt[s.at(i) - '0']++; } cout << 2 * min(cnt[0], cnt[1]) << endl; return 0; }
replace
8
21
8
11
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { string S; cin >> S; int e = 0, ne = 0; do { ne = 0; int i = 0; while (i < int(S.size()) - 1) { if (S.at(i) != S.at(i + 1)) { S.erase(i, 2); e += 2; ne += 1; } i++; } ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { string S; cin >> S; int z = 0, o = 0; for (size_t i = 0; i < S.size(); i++) { if (S.at(i) == '0') { z++; } else o++; } cout << min(o, z) * 2; }
replace
6
21
6
14
TLE
p03107
C++
Runtime Error
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string.h> typedef long long ll; const int xmax = 1e5 + 7; const int INF = 1e9 + 7; using namespace std; int main() { char s[1000]; scanf("%s", s); int ans1 = 0, ans2 = 0; for (int i = 0; i < strlen(s); i++) { if (s[i] ==...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string.h> typedef long long ll; const int xmax = 1e5 + 7; const int INF = 1e9 + 7; using namespace std; int main() { char s[100007]; scanf("%s", s); int ans1 = 0, ans2 = 0; for (int i = 0; i < strlen(s); i++) { if (s[i] ...
replace
10
11
10
11
0
p03107
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using ui = unsigned int; const ll MOD = 1000000007; // 120 int main() { static char S[10010]...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using ui = unsigned int; const ll MOD = 1000000007; // 120 int main() { static char S[100010...
replace
19
20
19
20
0
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF LLONG_MAX #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; int m...
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF LLONG_MAX #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; int m...
replace
14
31
14
15
TLE
p03107
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; char s[10020]; int ans, tot1, tot2; int main() { cin >> s; for (int i = 0; i < strlen(s); i++) { if (s[i] == '0') tot1++; else tot2++; } ans = min(tot1, tot2) * 2; cou...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; char s[100200]; int ans, tot1, tot2; int main() { cin >> s; for (int i = 0; i < strlen(s); i++) { if (s[i] == '0') tot1++; else tot2++; } ans = min(tot1, tot2) * 2; co...
replace
8
9
8
9
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int zero, one; int main() { char ch[1000]; scanf("%s", &ch); int len = strlen(ch); for (int i = 0; i < len; i++) { if (ch[i] == '0') ++zero; else if (ch[i] == '1') ++one; } printf("%d\n", min(zero, one) * 2); }
#include <bits/stdc++.h> using namespace std; int zero, one; int main() { char ch[100009]; scanf("%s", &ch); int len = strlen(ch); for (int i = 0; i < len; i++) { if (ch[i] == '0') ++zero; else if (ch[i] == '1') ++one; } printf("%d\n", min(zero, one) * 2); }
replace
4
5
4
5
0
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string homu; cin >> homu; int n = homu.size(); while (1) { bool ok = false; string ns = ""; for (int i = 0; i < (int)homu.size(); ++i) { if (i + 1 < homu.size() && homu[i] != homu[i + 1]) { ++i; ok = true; } else...
#include <bits/stdc++.h> using namespace std; int main() { string homu; cin >> homu; int n = homu.size(); random_shuffle(homu.begin(), homu.end()); while (1) { bool ok = false; string ns = ""; for (int i = 0; i < (int)homu.size(); ++i) { if (i + 1 < homu.size() && homu[i] != homu[i + 1]) { ...
insert
7
7
7
8
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; bool f = true; while (f) { f = false; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) { s.erase(i - 1, 2); ans += 2; i -= 2; f = true; } } } cout ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; bool f = true; while (f) { f = false; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) { s.erase(i - 1, 2); ans += 2; i--; f = true; } } } cout << ...
replace
14
15
14
15
0
p03107
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main() { string s; int n = 0; cin >> s; for (int i = 0; i < s.size();) { if (s.substr(i, 2) == "01" || s.substr(i, 2) == "10") { n += 2; s.erase(i, 2); i = 0; } else { i++; } } cout << n << endl; return...
#include <iostream> #include <string> using namespace std; int main() { string s; int n = 0; cin >> s; for (int i = 0; i < s.size();) { if (s.substr(i, 2) == "01" || s.substr(i, 2) == "10") { n += 2; s.erase(i, 2); if (i != 0) i--; } else { i++; } } cout << n ...
replace
15
16
15
17
TLE
p03107
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; templat...
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; templat...
replace
29
53
29
30
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int start = 0; int compare = start + 1; int count = 0; priority_queue<int> bs; while (compare < S.size()) { if (S[start] != S[compare]) { count += 2; while (true) { if (start > bs.top()) { sta...
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int start = 0; int compare = start + 1; int count = 0; priority_queue<int> bs; while (compare < S.size()) { if (S[start] != S[compare]) { count += 2; while (true) { if (bs.size() == 0) { start...
insert
14
14
14
19
0
p03107
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n, red = 0, blue = 0; string s; cin >> n >> s; REP(i, n) { if ...
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n, red = 0, blue = 0; string s; cin >> s; n = s.size(); REP(i, n...
replace
14
15
14
16
0
p03107
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define fi first #define se second using namespace std; const int M = 1e6 + 10; int n, cnt, ans; bool a[M], st[M]; int main() { string s; cin >> n >> s; for (int i = 0; i < n; i++) a[i] = s[i] - '0'; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define fi first #define se second using namespace std; const int M = 1e6 + 10; int n, cnt, ans; bool a[M], st[M]; int main() { string s; cin >> s; n = s.length(); for (int i = 0; i < n; i++) a[i] = s[i] - '0'; for (int i = 0; i ...
replace
11
12
11
13
0
p03107
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace ...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace ...
replace
66
67
66
67
-11
p03107
C++
Runtime Error
#include <iostream> int A[] = {0, 0}; int main(void) { while (true) { char c = getchar(); if (c == EOF) break; A[c - '0']++; } printf("%d\n", (A[0] > A[1] ? A[1] : A[0]) << 1); return 0; }
#include <iostream> int A[] = {0, 0}; int main(void) { while (true) { char c = getchar(); if (c == '\n') break; A[c - '0']++; } printf("%d\n", (A[0] > A[1] ? A[1] : A[0]) << 1); return 0; }
replace
7
8
7
8
-11
p03107
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; bool flag = true; bool done = false; int count = 0; int len = s.size(); while (flag) { done = false; for (int i = 0; i < s.size(); ++i) { if ((s[i] == '0' && s[i + 1] == '1') or ...
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; bool flag = true; bool done = false; int count = 0; int len = s.size(); while (flag) { done = false; for (int i = 0; i < s.size(); ++i) { if ((s[i] == '0' && s[i + 1] == '1') or ...
insert
20
20
20
22
TLE
p03107
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef unsigned long long ull; typedef long long ll; const ll INF = 1e18; const int MOD = 1e9 + 7; const double pi = acos(-1); int main() { string s; cin >> s; ll n = s.size(); vector<int> vec; rep(i, n) vec.p...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef unsigned long long ull; typedef long long ll; const ll INF = 1e18; const int MOD = 1e9 + 7; const double pi = acos(-1); int main() { string s; cin >> s; ll n = s.size(); vector<int> vec; rep(i, n) vec.p...
replace
16
17
16
17
0
p03107
C++
Time Limit Exceeded
#pragma GCC optimize("Ofast") #pragma GCC target("avx2,tune=native") #include <bits/stdc++.h> #include <x86intrin.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; string backup = s; auto i = s.find("01", 0); while (i != -1) { s = s.substr(0, i) ...
#pragma GCC optimize("Ofast") #pragma GCC target("avx2,tune=native") #include <bits/stdc++.h> #include <x86intrin.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int cnt0 = 0, cnt1 = 0; for (int i = 0; i < s.length(); i++) (s[i] == '1') ? cnt1++ ...
replace
13
25
13
17
TLE
p03107
C++
Runtime Error
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int max(int a, int b) { return a >= b ? a : b; } int lmax(long int a, long int b) { return a >= b ? a : b; } int min(int a, int b) { return b >= a ? a : b; } int lmin(long int a, long int b) { return b >= a ? a : b; } int ...
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int max(int a, int b) { return a >= b ? a : b; } int lmax(long int a, long int b) { return a >= b ? a : b; } int min(int a, int b) { return b >= a ? a : b; } int lmin(long int a, long int b) { return b >= a ? a : b; } int ...
replace
50
51
50
51
0
p03108
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; static const int MAX_N = 100, MAX_M = 10e2; struct UnionFind { // MAX_N定義必要要素数 int Par[MAX_N]; // 親は"-子供(自分含め)"を所持 int N; UnionFind(int n) { N = n; for (int i = 0; i < N; i++) Par[i] = -1; } bool unite(int a, int b) { int par_a ...
#include <algorithm> #include <iostream> using namespace std; static const int MAX_N = 10e5, MAX_M = 10e5; struct UnionFind { // MAX_N定義必要要素数 int Par[MAX_N]; // 親は"-子供(自分含め)"を所持 int N; UnionFind(int n) { N = n; for (int i = 0; i < N; i++) Par[i] = -1; } bool unite(int a, int b) { int par_a...
replace
3
4
3
4
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define lper(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define mp make_pair #define pb push_...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define lper(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define mp make_pair #define pb push_...
replace
118
119
118
119
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define REV(v) reverse(v.begin(), v.end()); #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, start, stop) for (int i = start; i < stop; i++) #define FORR(i, start, stop) for (int i = start; i > stop; i--) #define SORT(v, n) sort(v, v +...
#include <bits/stdc++.h> #define REV(v) reverse(v.begin(), v.end()); #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, start, stop) for (int i = start; i < stop; i++) #define FORR(i, start, stop) for (int i = start; i > stop; i--) #define SORT(v, n) sort(v, v +...
replace
66
67
66
67
0
p03108
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> typedef long long ll; #define...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> typedef long long ll; #define...
replace
62
63
62
63
0
p03108
C++
Runtime Error
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <ioma...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <ioma...
replace
186
187
186
188
0
p03108
C++
Runtime Error
// Robs Code #include <bits/stdc++.h> #define speed \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll long long ...
// Robs Code #include <bits/stdc++.h> #define speed \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll long long ...
replace
19
20
19
20
0
p03108
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; class UnionFind { public: // 親の番号を格納。親なら-(その集合のサイズ) vector<int> Parent; UnionFind(int N) { Parent = vector<int>(N, -1); } // Aのグループを調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } // 自分のいるグルー...
#include <iostream> #include <vector> using namespace std; class UnionFind { public: // 親の番号を格納。親なら-(その集合のサイズ) vector<int> Parent; UnionFind(int N) { Parent = vector<int>(N, -1); } // Aのグループを調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } // 自分のいるグルー...
replace
50
51
50
51
-6
free(): invalid pointer
p03108
C++
Time Limit Exceeded
#include <cstdio> #include <iostream> using namespace std; #define LLInt long long int LLInt n, m; int par[100001]; LLInt t_size[100001]; int find(int x) { if (par[x] == x) return x; int res = find(par[x]); return res; } void unite(int x, int y) { int rootx = find(x), rooty = find(y); par[rooty] = ro...
#include <cstdio> #include <iostream> using namespace std; #define LLInt long long int LLInt n, m; int par[100001]; LLInt t_size[100001]; int find(int x) { if (par[x] == x) return x; par[x] = find(par[x]); return par[x]; } void unite(int x, int y) { int rootx = find(x), rooty = find(y); par[rooty] = ...
replace
14
16
14
16
TLE
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; class UnionFind { vector<int> par; int groupCount; public: // UnionFind uf(n)でn要素のUF木uf UnionFind(int n = 0) { init(n); } // n要素で初期化 void init(int n = 0) { par.resize(n); fill(par.begin(), par.end(), -1); groupCount = n; return; } // xが属す...
#include <bits/stdc++.h> using namespace std; class UnionFind { vector<int> par; int groupCount; public: // UnionFind uf(n)でn要素のUF木uf UnionFind(int n = 0) { init(n); } // n要素で初期化 void init(int n = 0) { par.resize(n); fill(par.begin(), par.end(), -1); groupCount = n; return; } // xが属す...
replace
61
62
61
62
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define INF (i64)(1e18) #define MOD (i64)(1e9 + 7) #define REP(i, n) for (i64 i = 0; i < (n); i++) #define RREP(i, n) for (i64 i = (n)-1; i >= 0; i--) #define RANGE(i, a, b) for (i64 i = (a); i < (b); i++) #define RRANGE(i, a, b) for (i64 i = (b)-...
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define INF (i64)(1e18) #define MOD (i64)(1e9 + 7) #define REP(i, n) for (i64 i = 0; i < (n); i++) #define RREP(i, n) for (i64 i = (n)-1; i >= 0; i--) #define RANGE(i, a, b) for (i64 i = (a); i < (b); i++) #define RRANGE(i, a, b) for (i64 i = (b)-...
replace
54
55
54
55
0
p03108
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; struct UnionFind { vector<long> par; UnionFind(long N) : par(N) { for (long i = 0; i < N; ++i) par[i] = i; } long root(long x) { if (par[x] == x) return x; else root(par[x]); } vo...
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; struct UnionFind { vector<long> par; UnionFind(long N) : par(N) { for (long i = 0; i < N; ++i) par[i] = i; } long root(long x) { if (par[x] == x) return x; else root(par[x]); } vo...
replace
64
65
64
69
TLE
p03108
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n;...
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n;...
replace
299
300
299
300
TLE
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; typedef long long ll; struct UnionFind { vector<ll> link; UnionFind(ll n) : link(n, -1) {} ll find(ll v) { if (link[v] < 0) return v; else return link[v] = fi...
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; typedef long long ll; struct UnionFind { vector<ll> link; UnionFind(ll n) : link(n, -1) {} ll find(ll v) { if (link[v] < 0) return v; else return link[v] = fi...
replace
38
40
38
43
0
p03108
C++
Runtime Error
// ABC 120 D; #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 10010; struct EDGE { int u, v; } e[maxn]; ll sz[maxn], p[maxn], ans[maxn]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); ...
// ABC 120 D; #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 100010; struct EDGE { int u, v; } e[maxn]; ll sz[maxn], p[maxn], ans[maxn]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar();...
replace
5
6
5
6
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; map<ll, ll> mp; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 UnionFind(ll N) : par(N) { // 最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i, mp[i]++; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (pa...
#include <bits/stdc++.h> using namespace std; typedef long long ll; map<ll, ll> mp; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 UnionFind(ll N) : par(N) { // 最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i, mp[i]++; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (pa...
insert
42
42
42
44
0
p03108
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << #x << ": " << x << endl int main() { ll n, m; cin >> n >> m; vector<int> a(m), b(m); ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << #x << ": " << x << endl int main() { ll n, m; cin >> n >> m; vector<int> a(m), b(m); ...
replace
43
44
43
44
TLE
p03108
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << #x << ": " << x << endl int main() { int n, m; cin >> n >> m; vector<i...
#include <algorithm> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << #x << ": " << x << endl int main() { int n, m; cin >> n >> m; vector<i...
delete
47
48
47
47
TLE
p03108
C++
Runtime Error
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < (int)(n); i++) #define repi(i, a, b) for (ll i = int(a); i < int(b); i++) #define all...
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < (int)(n); i++) #define repi(i, a, b) for (ll i = int(a); i < int(b); i++) #define all...
replace
48
49
48
49
0
p03108
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef unsigned char UINT8; typedef short SINT16; typedef unsigned short UINT16; typedef int SINT32; typedef unsigned int ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef unsigned char UINT8; typedef short SINT16; typedef unsigned short UINT16; typedef int SINT32; typedef unsigned int ...
replace
101
102
101
102
0
p03108
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; #define etm \ cerr << "Time elapse...
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; #define etm \ cerr << "Time elapse...
replace
363
364
363
364
0
p03108
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; const int maxN = 150010; const int MAXM = 310; const int MAXK = 17; const int MOD = 1000000007; const ll INF = 10...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; const int maxN = 150010; const int MAXM = 310; const int MAXK = 17; const int MOD = 1000000007; const ll INF = 10...
replace
23
24
23
24
TLE
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct UnionFind { UnionFind(size_t size) : v(size, -1) {} vector<int> v; int root(int x) { return (v[x] < 0 ? x : v[x] = root(v[x])); } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if ...
#include <bits/stdc++.h> using namespace std; struct UnionFind { UnionFind(size_t size) : v(size, -1) {} vector<int> v; int root(int x) { return (v[x] < 0 ? x : v[x] = root(v[x])); } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if ...
replace
33
34
33
34
0
p03108
C++
Time Limit Exceeded
#include <iostream> #include <math.h> #include <stdlib.h> #include <string.h> #define max(a, b) ((a > b) ? (a) : (b)) #define min(a, b) ((a < b) ? (a) : (b)) using namespace std; long N, M; long *a, *b; long *ans; class nodeClass { public: nodeClass() { next = NULL; num = 0; } nodeClass *next; int ...
#include <iostream> #include <math.h> #include <stdlib.h> #include <string.h> #define max(a, b) ((a > b) ? (a) : (b)) #define min(a, b) ((a < b) ? (a) : (b)) using namespace std; long N, M; long *a, *b; long *ans; class nodeClass { public: nodeClass() { next = NULL; num = 0; } nodeClass *next; int ...
insert
67
67
67
69
TLE
p03108
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; class Unionfind { public: vector<int> oya; Unionfind(int N) { oya = vector<int>(N, -1); } int root(int x) { if (oya[x] < 0) return x; return oya[x] = root(oya[x]); ...
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; class Unionfind { public: vector<int> oya; Unionfind(int N) { oya = vector<int>(N, -1); } int root(int x) { if (oya[x] < 0) return x; return oya[x] = root(oya[x]); ...
replace
48
49
48
49
-6
free(): invalid pointer
p03108
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <...
replace
23
27
23
27
0
p03108
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define repl(i, x, n) \ for (long long i = (long long)(x); i < (long long)(n); i++) #define rep(i, x, n) for (long i = long(x); i < long(n); i++) long id[100009]; map<long, long> q; vector<pair<long, long>> v; void ...
#include <bits/stdc++.h> using namespace std; #define repl(i, x, n) \ for (long long i = (long long)(x); i < (long long)(n); i++) #define rep(i, x, n) for (long i = long(x); i < long(n); i++) long id[100009]; map<long, long> q; vector<pair<long, long>> v; void ...
insert
52
52
52
54
TLE
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; class UnionFind { public: // 親の番号を格納、親だった場合は-(その集合のサイズ) vector<int> Parent; // 親初期化(N個の要素すべてに-1を代入) UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Pa...
#include <bits/stdc++.h> using namespace std; class UnionFind { public: // 親の番号を格納、親だった場合は-(その集合のサイズ) vector<int> Parent; // 親初期化(N個の要素すべてに-1を代入) UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Pa...
replace
54
55
54
55
-6
free(): invalid pointer
p03108
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010], father[100010]; long long n, m, ans[100010], sum[100010]; int find_father(int x) { while (father[x] != x) x = father[x]; return x; } int main() { int i, x, y; cin >> n >> m; for (i = 1; i <= n; i++) { father[i] = i; sum[i] = 1...
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010], father[100010]; long long n, m, ans[100010], sum[100010]; int find_father(int x) { while (father[x] != x) x = father[x]; return x; } int main() { int i, x, y; cin >> n >> m; for (i = 1; i <= n; i++) { father[i] = i; sum[i] = 1...
insert
22
22
22
24
TLE
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; struct UnionFind { vector<ll> rnk, par, num; UnionFind(ll N) : rnk(N), par(N), num(N) { init(); } void init() { for (ll i = 0; i < rnk.size(); i++) { rnk[i] = 0; par[i] = i; num[i] = 1; } } ll find(ll x) { if (p...
#include <bits/stdc++.h> using namespace std; using ll = long long; struct UnionFind { vector<ll> rnk, par, num; UnionFind(ll N) : rnk(N), par(N), num(N) { init(); } void init() { for (ll i = 0; i < rnk.size(); i++) { rnk[i] = 0; par[i] = i; num[i] = 1; } } ll find(ll x) { if (p...
replace
43
44
43
44
-6
free(): invalid pointer
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define fi first #define se second using namespace std; struct Unionfind { // tree number vector<int> par; // tree rank vector<int> treerank; // constructor Unionfind(int n = 1) { stree(n + 1); } // make and initialization void stree(int n = 1) { par.resize(n); treerank...
#include <bits/stdc++.h> #define fi first #define se second using namespace std; struct Unionfind { // tree number vector<int> par; // tree rank vector<int> treerank; // constructor Unionfind(int n = 1) { stree(n + 1); } // make and initialization void stree(int n = 1) { par.resize(n); treerank...
replace
37
48
37
43
-11
p03108
C++
Runtime Error
#include <bits/stdc++.h> // clang-format off #define FOR(i, n) for (int i=0; i<(int)n; ++i) #define RFOR(i, n) for (int i=n-1; i>=0; --i) #define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n'); #define OUTM(x) FOR(i,x.size()) {OUTV(x[i])} #define BLE cerr<<"BLE"<<endl; #define DEBUG(x) cerr<<"DEBUG: "<<#x<...
#include <bits/stdc++.h> // clang-format off #define FOR(i, n) for (int i=0; i<(int)n; ++i) #define RFOR(i, n) for (int i=n-1; i>=0; --i) #define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n'); #define OUTM(x) FOR(i,x.size()) {OUTV(x[i])} #define BLE cerr<<"BLE"<<endl; #define DEBUG(x) cerr<<"DEBUG: "<<#x<...
replace
67
68
67
68
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i--;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reve...
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i--;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reve...
replace
550
551
550
551
0
p03108
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> P1; typedef pair<P, P> P2; #define pu ...
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> P1; typedef pair<P, P> P2; #define pu ...
replace
88
89
88
89
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define MD 1000000007 typedef long long int ll; typedef pair<ll, ll> P; template <typename T> std::string tostr(const T &t) { std::ostringstream os; os << t; return os.str(); } int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // 親の場合parには,-(集合のサイズ)を格納 vector<ll> par...
#include <bits/stdc++.h> using namespace std; #define MD 1000000007 typedef long long int ll; typedef pair<ll, ll> P; template <typename T> std::string tostr(const T &t) { std::ostringstream os; os << t; return os.str(); } int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // 親の場合parには,-(集合のサイズ)を格納 vector<ll> par...
replace
32
33
32
35
0
p03108
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; class UnionFind { public: // 親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; // 作るときはParentの値を全て-1にする // こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか...
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; class UnionFind { public: // 親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; // 作るときはParentの値を全て-1にする // こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか...
insert
58
58
58
60
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++) using namespace std; typedef long long ll; class UnionFind { private: vector<ll> data; public: UnionFind(ll n) : data(n, -1) {} ll size(ll i) { return -data[find(i)]; } bool root(ll i) { return data[i] < 0; } bool same(ll ...
#include <bits/stdc++.h> #define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++) using namespace std; typedef long long ll; class UnionFind { private: vector<ll> data; public: UnionFind(ll n) : data(n, -1) {} ll size(ll i) { return -data[find(i)]; } bool root(ll i) { return data[i] < 0; } bool same(ll ...
replace
31
32
31
32
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FOR(i, begin, end) for (ll i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--) #define IREP(i, n) IFOR(i, n, 0) #define SORT(a) sort(a.begin(), a.end()) #define ISORT(a) sort(a.begin(), a.en...
#include <bits/stdc++.h> using namespace std; #define FOR(i, begin, end) for (ll i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--) #define IREP(i, n) IFOR(i, n, 0) #define SORT(a) sort(a.begin(), a.end()) #define ISORT(a) sort(a.begin(), a.en...
replace
98
99
98
103
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const vector<int> di = {-1, 0, 1, 0}; const vector<int> dj = {0, -1, 0, 1}; void chmin(int &a, int b) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const vector<int> di = {-1, 0, 1, 0}; const vector<int> dj = {0, -1, 0, 1}; void chmin(int &a, int b) { ...
replace
68
69
68
69
0
p03108
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, m; ll a[11111]; ll b[11111]; ll res[11111]; struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, m; ll a[111111]; ll b[111111]; ll res[111111]; struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(in...
replace
5
8
5
8
0