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
p02835
Python
Runtime Error
A1 = input() A2 = input() A3 = input() if A1 + A2 + A3 < 22: print("win") else: print("bust")
A1, A2, A3 = (int(x) for x in input().split()) if A1 + A2 + A3 < 22: print("win") else: print("bust")
replace
0
4
0
1
EOFError: EOF when reading a line
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02835/Python/s934239505.py", line 2, in <module> A2 = input() EOFError: EOF when reading a line
p02835
Python
Runtime Error
a, b, c = map(int, input().split()) print("win" if sum((a, b, c)) < 21 else "bust") a, b, c = map(int, input().split()) print("win" if sum((a, b, c)) < 22 else "bust")
a, b, c = map(int, input().split()) print("win" if sum((a, b, c)) < 22 else "bust")
delete
0
3
0
0
EOFError: EOF when reading a line
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02835/Python/s003175429.py", line 4, in <module> a, b, c = map(int, input().split()) EOFError: EOF when reading a line
p02835
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) memset(a, 0, sizeof(a)) #define fst first #define snd second #define mp make_pair #define pb push_back #define endl '\n' #define init(n) \ int n; \ cin >> n; \ int a[n]; \ rep(i, n) cin >> a[i]; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<long long int> vll; typedef vector<pii> vii; ll p = 1000000007; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); int x, y, z; cin >> x >> y >> z; if (x + y + z >= 22) cout << "bust"; else cout << "win"; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) memset(a, 0, sizeof(a)) #define fst first #define snd second #define mp make_pair #define pb push_back #define endl '\n' #define init(n) \ int n; \ cin >> n; \ int a[n]; \ rep(i, n) cin >> a[i]; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<long long int> vll; typedef vector<pii> vii; ll p = 1000000007; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); int x, y, z; cin >> x >> y >> z; if (x + y + z >= 22) cout << "bust"; else cout << "win"; return 0; }
replace
25
29
25
29
-6
terminate called after throwing an instance of 'std::__ios_failure' what(): basic_ios::clear: iostream error
p02835
Python
Runtime Error
array = map(int, input().split()) print(f'{ "bust" if sum(array) >= 22 else "win"}')
array = map(int, input().split()) if sum(array) >= 22: print("bust") else: print("win")
replace
1
2
1
5
0
p02835
C++
Runtime Error
#include <stdio.h> int main() { int a, b, c; scanf("%d%d%d", a, b, c); if (a + b + c < 22) printf("win\n"); else printf("bust\n"); }
#include <stdio.h> int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); if (a + b + c < 22) printf("win\n"); else printf("bust\n"); }
replace
3
4
3
4
-11
p02835
C++
Runtime Error
#include <bits/stdc++.h> #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define sz(a) int((a).size()) #define endl '\n' using namespace std; typedef vector<int> vi; typedef pair<int, int> ii; typedef long long ll; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int a, b, c; cin >> a >> b >> c; cout << (a + b + c >= 22 ? "bust" : "win") << endl; return 0; }
#include <bits/stdc++.h> #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define sz(a) int((a).size()) #define endl '\n' using namespace std; typedef vector<int> vi; typedef pair<int, int> ii; typedef long long ll; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif int a, b, c; cin >> a >> b >> c; cout << (a + b + c >= 22 ? "bust" : "win") << endl; return 0; }
replace
19
23
19
23
0
p02835
C++
Runtime Error
#include <stdio.h> int main() { int a, b, c; scanf("%d %d %d"); if (a + b + c <= 21) { printf("win"); } else { printf("bust"); } return 0; }
#include <stdio.h> int main() { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (a + b + c <= 21) { printf("win"); } else { printf("bust"); } return 0; }
replace
4
5
4
5
-11
p02835
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pi 3.14159265359 #define int long long #define pii pair<int, int> #define ld long double const int mod = 1e9 + 7; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif int a, b, c; cin >> a >> b >> c; if (a + b + c >= 22) { cout << "bust\n"; } else { cout << "win\n"; } }
#include <bits/stdc++.h> using namespace std; #define pi 3.14159265359 #define int long long #define pii pair<int, int> #define ld long double const int mod = 1e9 + 7; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b, c; cin >> a >> b >> c; if (a + b + c >= 22) { cout << "bust\n"; } else { cout << "win\n"; } }
delete
16
21
16
16
0
p02835
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a; cin >> a[0] >> a[1] >> a[2]; if (a[0] + a[1] + a[2] < 22) cout << "win" << endl; else cout << "bust" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int s = a + b + c; if (s <= 21) cout << "win" << endl; else cout << "bust" << endl; }
replace
4
7
4
8
-11
p02835
C++
Runtime Error
#include <stdio.h> int main() { int a, b, c; scanf("%d %d %d", a, b, c); if (a + b + c <= 21) { printf("win"); } else { printf("bust"); } return 0; }
#include <stdio.h> int main() { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (a + b + c <= 21) { printf("win"); } else { printf("bust"); } return 0; }
replace
3
4
3
4
-11
p02836
C++
Time Limit Exceeded
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define ff first #define ss second #define setbits(x) __builtin_popcount(x) typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef pair<db, db> pdd; typedef vector<int> vi; #define m1 make_pair #define in insert #define pb push_back #define IOS \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; inline ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } inline ll power(ll a, ll n, ll m) { if (n == 0) return 1; ll p = power(a, n / 2, m); p = (p * p) % m; if (n % 2) return (p * a) % m; else return p; } const ll MOD = 1000000007; const int N = int(2e5) + 999; #define int long long int int32_t main() { IOS; // pre(); int tc; // cin>>tc; tc = 1; while (tc--) { int ans = 0; string s; cin >> s; int i = 0, j = s.size() - 1; while (i <= j) { if (s[i] != s[j]) ans++; } cout << ans << endl; } return 0; }
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define ff first #define ss second #define setbits(x) __builtin_popcount(x) typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef pair<db, db> pdd; typedef vector<int> vi; #define m1 make_pair #define in insert #define pb push_back #define IOS \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; inline ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } inline ll power(ll a, ll n, ll m) { if (n == 0) return 1; ll p = power(a, n / 2, m); p = (p * p) % m; if (n % 2) return (p * a) % m; else return p; } const ll MOD = 1000000007; const int N = int(2e5) + 999; #define int long long int int32_t main() { IOS; // pre(); int tc; // cin>>tc; tc = 1; while (tc--) { int ans = 0; string s; cin >> s; int i = 0, j = s.size() - 1; while (i <= j) { if (s[i] != s[j]) ans++; i++, j--; } cout << ans << endl; } return 0; }
insert
66
66
66
67
TLE
p02836
C++
Runtime Error
#include <cstdio> #include <iostream> using namespace std; int main(void) { string S; int ans = 0; cin >> S; for (int i = 0; i <= S.length() / 2 - 1; i++) { if (S[i] != S[S.length() - 1 - i]) { // cout << S[i] << " " << S[S.length() - 1 - i] << endl; ans++; } } printf("%d", ans); return 0; }
#include <cstdio> #include <iostream> using namespace std; int main(void) { string S; int ans = 0; cin >> S; int l = S.length(); for (int i = 0; i <= l / 2 - 1; i++) { if (S[i] != S[l - 1 - i]) { ans++; } } printf("%d", ans); return 0; }
replace
8
11
8
11
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int(i) = 0; i < (n); i++) #define REP(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define INF LLONG_MAX - 100 #define inf 1012345678 #define MOD 1000000007 #define fcout cout << fixed << setprecision(15) #define int long long #define yorn(f) puts((f) ? "Yes" : "No") #define YORN(f) puts((f) ? "YES" : "NO") #define lower_bound lowb #define upper_bound upb typedef long long ll; typedef pair<int, int> P; typedef priority_queue<int> pque; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }; int lcm(int a, int b) { return a * b / gcd(a, b); }; int mod(int a, int b) { return (a + b - 1) / b; }; int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }; int cnt(string s, string t) { int res = 0; rep(i, s.size()) { if (s[i] != t[i]) res++; } return res; } signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); int ans = 0; if (n % 2 == 0) { string t = s.substr(n / 2, n / 2); reverse(all(t)); ans = cnt(s.substr(0, n / 2), t); } else { string t = s.substr(n / 2 + 2, n / 2); reverse(all(t)); ans = cnt(s.substr(0, n / 2), t); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int(i) = 0; i < (n); i++) #define REP(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define INF LLONG_MAX - 100 #define inf 1012345678 #define MOD 1000000007 #define fcout cout << fixed << setprecision(15) #define int long long #define yorn(f) puts((f) ? "Yes" : "No") #define YORN(f) puts((f) ? "YES" : "NO") #define lower_bound lowb #define upper_bound upb typedef long long ll; typedef pair<int, int> P; typedef priority_queue<int> pque; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }; int lcm(int a, int b) { return a * b / gcd(a, b); }; int mod(int a, int b) { return (a + b - 1) / b; }; int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }; int cnt(string s, string t) { int res = 0; rep(i, s.size()) { if (s[i] != t[i]) res++; } return res; } signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); int ans = 0; if (n % 2 == 0) { string t = s.substr(n / 2, n / 2); reverse(all(t)); ans = cnt(s.substr(0, n / 2), t); } else { string t = s.substr(n / 2 + 1, n / 2); reverse(all(t)); ans = cnt(s.substr(0, n / 2), t); } cout << ans << endl; return 0; }
replace
66
67
66
67
0
p02836
C++
Runtime Error
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); string str; cin >> str; int begin = 0; int end = str.length() - 1; int answer = 0; while (begin != end) { if (str[begin] != str[end]) answer++; begin++; end--; } cout << answer << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); string str; cin >> str; int begin = 0; int end = str.length() - 1; int answer = 0; while (begin <= end) { if (str[begin] != str[end]) answer++; begin++; end--; } cout << answer << endl; return 0; }
replace
21
22
21
22
-11
p02836
C++
Runtime Error
#include <bits/stdc++.h> #include <math.h> #include <string> #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define bet(min, max, n) if (!(min < n && n < max)) #define bet_omin(min, max, n) if (!(min <= n && n < max)) #define bet_omax(min, max, n) if (!(min < n && n <= max)) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long unsigned int ll; using namespace std; int main() { string S; cin >> S; int v = 0; rep(i, (S.length() / 2 - 1)) { if (S[i] != S[S.length() - 1 - i]) { v += 1; } } cout << v << endl; return 0; }
#include <bits/stdc++.h> #include <math.h> #include <string> #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define bet(min, max, n) if (!(min < n && n < max)) #define bet_omin(min, max, n) if (!(min <= n && n < max)) #define bet_omax(min, max, n) if (!(min < n && n <= max)) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long unsigned int ll; using namespace std; int main() { string S; cin >> S; int v = 0; rep(i, (S.length() / 2)) { if (S[i] != S[S.length() - 1 - i]) { v += 1; } } cout << v << endl; return 0; }
replace
20
21
20
21
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int ans = 0; if (S.size() % 2 == 0) { for (int i = 0; i < S.size() / 2; i++) { if (S.at(i) != S.at(S.size() - 1 - i)) { ans++; } } } if (S.size() % 2 == 1) { for (int i = 0; i < S.size() / 2 - 1; i++) { if (S.at(i) != S.at(S.size() - 1 - i)) { ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int ans = 0; for (int i = 0; i < S.size() / 2; i++) { if (S.at(i) != S.at(S.size() - 1 - i)) { ans++; } } cout << ans << endl; }
replace
6
18
6
9
0
p02836
C++
Runtime Error
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string moji; cin >> moji; int kotae = 0; for (int i = 0; i <= moji.size() / 2 - 1; i++) { if (moji[i] != moji[moji.size() - i - 1]) { kotae++; } } cout << kotae << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string moji; cin >> moji; int kotae = 0; if (moji.size() != 1) { for (int i = 0; i <= moji.size() / 2 - 1; i++) { if (moji[i] != moji[moji.size() - i - 1]) { kotae++; } } } cout << kotae << endl; return 0; }
replace
8
11
8
13
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string S; cin >> S; ll ans = 0; for (int i = 0; i <= S.size() / 2 - 1; i++) { if (S[i] != S[S.size() - i - 1]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { string S; cin >> S; ll ans = 0; for (int i = 0; i <= ll(S.size()) / 2 - 1; i++) { if (S[i] != S[S.size() - i - 1]) ans++; } cout << ans << endl; return 0; }
replace
9
10
9
10
0
p02836
C++
Runtime Error
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cout, endl, cin #include <limits> #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define mod 1000000007 #define fst first #define pb push_back // ABC146B first AC int main() { string s, s2; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; i < s.size(); i++) { // sの逆を作る s2[i] = s[i]; } // sの並びを戻す。 reverse(s.begin(), s.end()); // 差異のカウント(つまりハグ) int diff = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != s2[i]) { diff++; } } cout << diff / 2 << endl; }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cout, endl, cin #include <limits> #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define mod 1000000007 #define fst first #define pb push_back // ABC146B first AC int main() { string s, s2; cin >> s; reverse(s.begin(), s.end()); for (int i = 0; i < s.size(); i++) { // sの逆を作る s2[i] = s[i]; } // sの並びを戻す。 reverse(s.begin(), s.end()); // 差異のカウント(つまりハグ) int diff = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != s2[i]) { diff++; } } int ans = diff / 2; cout << ans << endl; }
replace
41
42
41
43
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s = ""; cin >> s; int ans = 0; for (int i = 0, j = s.size() - 1; i != j; i++, j--) if (s[i] != s[j]) ans++; cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s = ""; cin >> s; int ans = 0; for (int i = 0, j = (int)s.size() - 1; i < (int)s.size() / 2; i++, j--) if (s[i] != s[j]) ans++; cout << ans << '\n'; return 0; }
replace
7
8
7
8
-11
p02836
C++
Runtime Error
#include <bits/stdc++.h> // #include<tr1/unordered_map> #pragma GCC optimize("Ofast") #define ll long long #define pll pair<long long, long long> #define pii pair<int, int> #define mp make_pair #define pb push_back #define F first #define S second #define forn(i, n) for (int i = 0; i < int(n); i++) #define Forn(i, n) for (int i = 1; i <= int(n); i++) using namespace std; /*#include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/ int main() { cin.tie(0); ios_base::sync_with_stdio(false); string s; cin >> s; int ans = 0; for (int i = 0; i <= s.size() / 2 - 1; i++) if (s[i] != s[s.size() - i - 1]) ans++; cout << ans << endl; }
#include <bits/stdc++.h> // #include<tr1/unordered_map> #pragma GCC optimize("Ofast") #define ll long long #define pll pair<long long, long long> #define pii pair<int, int> #define mp make_pair #define pb push_back #define F first #define S second #define forn(i, n) for (int i = 0; i < int(n); i++) #define Forn(i, n) for (int i = 1; i <= int(n); i++) using namespace std; /*#include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/ int main() { cin.tie(0); ios_base::sync_with_stdio(false); string s; cin >> s; int ans = 0; for (int i = 0; i + 1 <= s.size() / 2; i++) if (s[i] != s[s.size() - i - 1]) ans++; cout << ans << endl; }
replace
27
28
27
28
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int ans, i, j; string s; int main() { cin >> s; i = 0; j = s.size() - 1; while (i != j) { if (s[i] != s[j]) ans++; i++; j--; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int ans, i, j; string s; int main() { cin >> s; i = 0; j = s.size() - 1; while (i <= j) { if (s[i] != s[j]) ans++; i++; j--; } cout << ans; return 0; }
replace
8
9
8
9
-11
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string S; cin >> S; int cnt = 0; for (int i = 0; i <= S.size() / 2 - 1; i++) { if (S[i] != S[S.size() - i - 1]) { cnt++; } } cout << cnt << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string S; cin >> S; int cnt = 0; for (int i = 0; i < S.size() / 2; i++) { if (S[i] != S[S.size() - i - 1]) { cnt++; } } cout << cnt << endl; }
replace
12
13
12
13
0
p02836
C++
Runtime Error
#include <iostream> using namespace std; int main() { string s; cin >> s; int count = 0; for (int i = 0; i < s.length() / 2 - 1; i++) { if (s[i] != s[s.length() - i]) { count++; } } cout << count << endl; return 0; }
#include <iostream> using namespace std; int main() { string s; cin >> s; int count = 0; for (int i = 0; i < s.length() / 2; i++) { if (s[i] != s[s.length() - 1 - i]) { count++; } } cout << count << endl; return 0; }
replace
8
10
8
10
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 100100100; using namespace std; int main() { string S; cin >> S; int len = S.length(); int res = 0; string sub1 = S.substr(0, len / 2); string sub2 = S.substr(len / 2 + len % 2); reverse(sub2.begin(), sub2.end()); for (int i = 0; i <= len / 2; i++) { if (sub1.back() != sub2.back()) res++; sub1.pop_back(); sub2.pop_back(); } cout << res << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 100100100; using namespace std; int main() { string S; cin >> S; int len = S.length(); int res = 0; string sub1 = S.substr(0, len / 2); string sub2 = S.substr(len / 2 + len % 2); reverse(sub2.begin(), sub2.end()); for (int i = 0; i < len / 2; i++) { if (sub1.back() != sub2.back()) res++; sub1.pop_back(); sub2.pop_back(); } cout << res << endl; }
replace
16
17
16
17
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> st; int prime[1100001]; void seive() { for (int i = 2; i * i <= 1100000; i++) { if (!prime[i]) { // cout << i << endl; for (int j = i * i; j <= 1100000; j += i) { prime[j] = 1; } } } for (int i = 2; i <= 200000; i++) { if (!prime[i]) st.push_back(i); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif string s; cin >> s; int x = s.size() / 2; int ans = 0; for (int i = 0; i < x; i++) { if (s[i] != s[s.size() - i - 1]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> st; int prime[1100001]; void seive() { for (int i = 2; i * i <= 1100000; i++) { if (!prime[i]) { // cout << i << endl; for (int j = i * i; j <= 1100000; j += i) { prime[j] = 1; } } } for (int i = 2; i <= 200000; i++) { if (!prime[i]) st.push_back(i); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int x = s.size() / 2; int ans = 0; for (int i = 0; i < x; i++) { if (s[i] != s[s.size() - i - 1]) ans++; } cout << ans << endl; return 0; }
delete
22
26
22
22
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; int ans = 0; int i = 0; while (i <= (s.size() - 1 - i)) { if (s.at(i) != s.at(s.size() - 1 - i)) { ans++; } i++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; int ans = 0; int i = 0; while (i < (s.size() - 1 - i)) { if (s.at(i) != s.at(s.size() - 1 - i)) { ans++; } i++; } cout << ans << endl; }
replace
9
10
9
10
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; using namespace std::chrono; // VARS #define int long long #define ld long double #define mod1 1000000007 #define mod2 998244353 #define pi 3.14159265358979323846 // #define hs 100006 #define inf 1e18 #define ninf -1 * (1e18) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define vc vector #define pii pair<int, int> #define msi map<string, int> #define mii map<int, int> #define psi pair<string, int> #define pis pair<int, string> #define endl "\n" // INPUT #define rep(i, a, b) for (int i = a; i < b; i++) #define repe(i, a, b) for (int i = a; i <= b; i++) #define bac(i, a, b) for (int i = a; i > b; i--) #define bace(i, a, b) for (int i = a; i >= b; i--) // FAST #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); // FUNCTIONS #define DECIMAL(n) std::cout << std::fixed << std::setprecision(n) #define SORT(v) sort(all(v)) #define RSORT(v) sort(all(v), greater<int>()) #define REVERSE(v) reverse(ALL(v)) #define GCD(m, n) __gcd(m, n) #define LCM(m, n) m *(n / GCD(m, n)) #define init(x, a) memset(x, a, sizeof(x)) #define trav(a, x) for (auto &a : x) #define display(x) \ trav(a, x) cout << a << " "; \ cout << endl #define pow(i, n) (int)pow((int)i, n) #define pow2(n) ((int)1 << n) void swp(int &a, int &b) { auto temp = a; a = b; b = temp; } int ans(string s) { int n = s.length(); int p = 0; for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) { p += 1; if (s[i] < s[n - i - 1]) s[n - i - 1] = s[i]; else s[i] = s[n - i - 1]; } } return p; } void solve() { string s; cin >> s; int t = ans(s); cout << t; return; } signed main() { ios #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; // cin>>q; while (q--) { solve(); } return 0; }
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; using namespace std::chrono; // VARS #define int long long #define ld long double #define mod1 1000000007 #define mod2 998244353 #define pi 3.14159265358979323846 // #define hs 100006 #define inf 1e18 #define ninf -1 * (1e18) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define vc vector #define pii pair<int, int> #define msi map<string, int> #define mii map<int, int> #define psi pair<string, int> #define pis pair<int, string> #define endl "\n" // INPUT #define rep(i, a, b) for (int i = a; i < b; i++) #define repe(i, a, b) for (int i = a; i <= b; i++) #define bac(i, a, b) for (int i = a; i > b; i--) #define bace(i, a, b) for (int i = a; i >= b; i--) // FAST #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); // FUNCTIONS #define DECIMAL(n) std::cout << std::fixed << std::setprecision(n) #define SORT(v) sort(all(v)) #define RSORT(v) sort(all(v), greater<int>()) #define REVERSE(v) reverse(ALL(v)) #define GCD(m, n) __gcd(m, n) #define LCM(m, n) m *(n / GCD(m, n)) #define init(x, a) memset(x, a, sizeof(x)) #define trav(a, x) for (auto &a : x) #define display(x) \ trav(a, x) cout << a << " "; \ cout << endl #define pow(i, n) (int)pow((int)i, n) #define pow2(n) ((int)1 << n) void swp(int &a, int &b) { auto temp = a; a = b; b = temp; } int ans(string s) { int n = s.length(); int p = 0; for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) { p += 1; if (s[i] < s[n - i - 1]) s[n - i - 1] = s[i]; else s[i] = s[n - i - 1]; } } return p; } void solve() { string s; cin >> s; int t = ans(s); cout << t; return; } signed main() { ios int q = 1; // cin>>q; while (q--) { solve(); } return 0; }
replace
89
95
89
90
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s, t; int a, ans; ans = 0; cin >> s; a = s.size(); s = t; reverse(t.begin(), t.end()); rep(i, a / 2) { if (s.at(i) != t.at(i)) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s, t; int a, ans; ans = 0; cin >> s; a = s.size(); t = s; reverse(t.begin(), t.end()); rep(i, a / 2) { if (s.at(i) != t.at(i)) ans++; } cout << ans << endl; }
replace
9
10
9
10
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 0) >= this->size() (which is 0)
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, x, n) for (int i = x; i < n; i++) #define WHITE 0 #define BLACK 1 typedef long long ll; typedef pair<ll, ll> pl; typedef pair<int, int> pi; string s; int k; int INFi = 1000000000; ll INFl = 1000000000000000; int main() { string s; cin >> s; int count = 0; for (int i = 0; i <= s.size() - 1 - i; i++) { if (s[i] != s[s.size() - 1 - i]) count++; } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, x, n) for (int i = x; i < n; i++) #define WHITE 0 #define BLACK 1 typedef long long ll; typedef pair<ll, ll> pl; typedef pair<int, int> pi; string s; int k; int INFi = 1000000000; ll INFl = 1000000000000000; int main() { string s; cin >> s; int count = 0; for (int i = 0; i < s.size() - 1 - i; i++) { if (s[i] != s[s.size() - 1 - i]) count++; } cout << count << endl; return 0; }
replace
27
28
27
28
0
p02836
Python
Runtime Error
S = list(input()) firstS = S[: len(S) // 2] secondS = list(reversed(S[len(S) // 2 + 1 :])) count = 0 for x in range(len(firstS)): if firstS[x] != secondS[x]: count += 1 print(count)
S = list(input()) firstS = S[: len(S) // 2] if len(S) % 2 == 0: secondS = list(reversed(S[len(S) // 2 :])) else: secondS = list(reversed(S[len(S) // 2 + 1 :])) count = 0 for x in range(len(firstS)): if firstS[x] != secondS[x]: count += 1 print(count)
replace
3
4
3
7
IndexError: list index out of range
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02836/Python/s200391316.py", line 9, in <module> if firstS[x] != secondS[x]: IndexError: list index out of range
p02836
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < int(n); i++) int main() { string S; cin >> S; int ans = 0; int a = S.size(); for (int i = 0; i < a / 2;) { if (S.at(i) != S.at(a - 1 - i)) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < int(n); i++) int main() { string S; cin >> S; int ans = 0; int a = S.size(); for (int i = 0; i < a / 2; i++) { if (S.at(i) != S.at(a - 1 - i)) { ans++; } } cout << ans << endl; }
replace
9
10
9
10
TLE
p02836
C++
Runtime Error
#include <iostream> #include <queue> #include <stack> #include <string> #include <vector> #include <math.h> #include <numeric> #include <stdio.h> #include <stdlib.h> using namespace std; string s; int main() { cin >> s; int ans = 0; for (int i = 0; i <= s.length() / 2 - 1; i++) { if (s[i] != s[s.length() - i - 1]) ans++; } // cout << s.length() << endl; cout << ans << endl; return 0; }
#include <iostream> #include <queue> #include <stack> #include <string> #include <vector> #include <math.h> #include <numeric> #include <stdio.h> #include <stdlib.h> using namespace std; string s; int main() { cin >> s; int ans = 0; if (s.length() == 1) { cout << 0 << endl; return 0; } for (int i = 0; i <= s.length() / 2 - 1; i++) { if (s[i] != s[s.length() - i - 1]) ans++; } // cout << s.length() << endl; cout << ans << endl; return 0; }
insert
16
16
16
20
0
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define pai 3.1415926535897932384 using namespace std; using ll = long long; using P = pair<int, int>; int main(int argc, const char *argv[]) { string S; cin >> S; int a = 0; int b = (int)S.length() - 1; int count = 0; while (a >= b) { if (S[a] != S[b]) { S[a] = S[b]; count++; } a++; b--; } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define pai 3.1415926535897932384 using namespace std; using ll = long long; using P = pair<int, int>; int main(int argc, const char *argv[]) { string S; cin >> S; int a = 0; int b = (int)S.length() - 1; int count = 0; while (a < b) { if (S[a] != S[b]) { S[a] = S[b]; count++; } a++; b--; } cout << count << endl; return 0; }
replace
26
27
26
27
0
p02836
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int count = 0; int i = 0; int j = str.size() - 1; while (i < j) { if (str[i] == str[j]) continue; else count++; i++; j--; } printf("%d\n", count); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int count = 0; int i = 0; int j = str.size() - 1; while (i < j) { if (str[i] == str[j]) ; else count++; i++; j--; } printf("%d\n", count); return 0; }
replace
10
11
10
11
TLE
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> #define roop(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long int; using ull = unsigned long long; constexpr ull mod = 1e9 + 7; constexpr int N = 13; ull dp[100010][N]; float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } int main() { string s; cin >> s; int i = 0, j = s.size() - 1, ans = 0; if (s.size() % 2 == 0) { while (true) { if (s[i] != s[j]) { ans++; } i++; j--; if (j < (s.size() / 2)) { break; } } } else { while (true) { if (s[i] != s[j]) { ans++; } i++; j--; if ((j < (s.size() / 2) + 1)) { break; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> #define roop(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long int; using ull = unsigned long long; constexpr ull mod = 1e9 + 7; constexpr int N = 13; ull dp[100010][N]; float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } int main() { string s; cin >> s; int i = 0, j = s.size() - 1, ans = 0; if (s.size() == 1) { cout << 0 << endl; return 0; } if (s.size() % 2 == 0) { while (true) { if (s[i] != s[j]) { ans++; } i++; j--; if (j < (s.size() / 2)) { break; } } } else { while (true) { if (s[i] != s[j]) { ans++; } i++; j--; if ((j < (s.size() / 2) + 1)) { break; } } } cout << ans << endl; return 0; }
insert
35
35
35
39
0
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <stack> #include <stdlib.h> #include <string> #include <vector> int main() { std::string s; std::cin >> s; int end = s.length() - 1; int ans = 0; for (size_t i = 0; i <= end; i++) { if (s[i] != s[end]) { ans++; } end--; } std::cout << ans << std::endl; return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <stack> #include <stdlib.h> #include <string> #include <vector> int main() { std::string s; std::cin >> s; int end = s.length() - 1; int ans = 0; for (int i = 0; i <= end; i++) { if (s[i] != s[end]) { ans++; } end--; } std::cout << ans << std::endl; return 0; }
replace
20
21
20
21
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; const long long INF = 1LL << 60; int main(void) { string S; cin >> S; int ans = 0; rep(i, S.length() / 2 - 1) if (S[i] != S[S.length() - i - 1]) ans++; cout << ans; return 0; }
#include <bits/stdc++.h> #define mod 1000000007 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; const long long INF = 1LL << 60; int main(void) { string S; cin >> S; int ans = 0; rep(i, S.length() / 2) if (S[i] != S[S.length() - i - 1]) ans++; cout << ans; return 0; }
replace
18
19
18
19
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int A = S.size() - 1; int count = 0; if (S.size() == 1) { cout << 0 << endl; } for (int i = 0; A >= S.size() / 2; i++) { if (S.at(i) != S.at(A)) { count++; } A--; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int A = S.size() - 1; int count = 0; if (S.size() == 1) { cout << 0 << endl; return 0; } for (int i = 0; A >= S.size() / 2; i++) { if (S.at(i) != S.at(A)) { count++; } A--; } cout << count << endl; }
insert
11
11
11
12
0
p02836
C++
Runtime Error
#include <stdio.h> int main() { char s[150]; int sleng = 0, dif = 0; scanf("%s", s); for (size_t i = 0; s[i] != '\0'; i++) { sleng++; } for (size_t i = 0; sleng - i - 1 >= i; i++) { if (s[i] != s[sleng - i - 1]) dif++; } printf("%d", dif); return 0; }
#include <stdio.h> int main() { char s[150]; int sleng = 0, dif = 0; scanf("%s", s); for (size_t i = 0; s[i] != '\0'; i++) { sleng++; } for (size_t i = 0; sleng - i - 1 >= i; i++) { if (sleng - i - 1 <= 0) break; if (s[i] != s[sleng - i - 1]) dif++; } printf("%d", dif); return 0; }
insert
10
10
10
12
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ms(s, n) memset(s, n, sizeof(s)) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORd(i, a, b) for (int i = (a); i >= (b); i--) #define FORall(it, a) \ for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) #define sz(a) int((a).size()) #define present(t, x) (t.find(x) != t.end()) #define all(a) (a).begin(), (a).end() #define uni(a) (a).erase(unique(all(a)), (a).end()) #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define sp system("pause") #define prec(n) fixed << setprecision(n) #define bit(n, i) (((n) >> (i)) & 1) #define bitcount(n) __builtin_popcountll(n) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef vector<int> vi; typedef vector<pi> vii; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const ll LINF = (ll)1e18; const ld PI = acos((ld)-1); const ld EPS = 1e-9; const int N = (int)1e5; void TimeExecution() { cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s)."; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); /* #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif */ string s; cin >> s; int res = 0; FOR(i, 0, s.size() / 2 - 1) { if (s[i] != s[s.size() - i - 1]) res++; } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; #define ms(s, n) memset(s, n, sizeof(s)) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORd(i, a, b) for (int i = (a); i >= (b); i--) #define FORall(it, a) \ for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) #define sz(a) int((a).size()) #define present(t, x) (t.find(x) != t.end()) #define all(a) (a).begin(), (a).end() #define uni(a) (a).erase(unique(all(a)), (a).end()) #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define sp system("pause") #define prec(n) fixed << setprecision(n) #define bit(n, i) (((n) >> (i)) & 1) #define bitcount(n) __builtin_popcountll(n) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef vector<int> vi; typedef vector<pi> vii; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const ll LINF = (ll)1e18; const ld PI = acos((ld)-1); const ld EPS = 1e-9; const int N = (int)1e5; void TimeExecution() { cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s)."; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); /* #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif */ string s; cin >> s; int res = 0; if (s.size() == 1) { cout << 0; return 0; } FOR(i, 0, s.size() / 2 - 1) { if (s[i] != s[s.size() - i - 1]) res++; } cout << res; return 0; }
insert
49
49
49
53
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define rgi register int #define pii pair<int, int> #define mkp make_pair #define fi first #define se second #define pb push_back #define filein(x) freopen(x, "r", stdin) #define fileout(x) freopen(x, "w", stdout) using namespace std; int n, ans; string s; signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> s; n = s.size(); rgi i = 0, j = n - 1; while (i != j) { if (s[i] != s[j]) ++ans; ++i, --j; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define rgi register int #define pii pair<int, int> #define mkp make_pair #define fi first #define se second #define pb push_back #define filein(x) freopen(x, "r", stdin) #define fileout(x) freopen(x, "w", stdout) using namespace std; int n, ans; string s; signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> s; n = s.size(); rgi i = 0, j = n - 1; while (i < j) { if (s[i] != s[j]) ++ans; ++i, --j; } cout << ans << endl; return 0; }
replace
19
20
19
20
-11
p02836
C++
Runtime Error
/* author: Salam_35 problem name: */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define sc(n) scanf("%d", &n) #define Max 100005 #define scan(n) scanf("%lld", &n) #define pi acos(-1.0) #define _fastio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ALL(x) x.begin(), x.end() #define sci(n) scanf("%d", &n); #define scl(n) scanf("%lld", &n); #define load(array, size) \ for (ll i = 0; i < size; i++) \ cin >> array[i]; #define load1(array, size) \ for (ll i = 1; i <= size; i++) \ cin >> array[i]; #define INF 1LL << 19 #define pll pair<ll, ll> #define mst(arr, value) memset(arr, value, sizeof(arr)); const ll MOD = 1e9 + 7; typedef vector<ll> vec; typedef pair<ll, ll> pii; typedef map<ll, ll> mpll; typedef set<ll> seet; vec primes; // int main() { string a; cin >> a; int ans = 0; for (int i = 0, j = a.size() - 1; i < a.size() / 2, j >= a.size() / 2; i++, j--) { if (a[i] != a[j]) ans++; } cout << ans << endl; return 0; }
/* author: Salam_35 problem name: */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define sc(n) scanf("%d", &n) #define Max 100005 #define scan(n) scanf("%lld", &n) #define pi acos(-1.0) #define _fastio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ALL(x) x.begin(), x.end() #define sci(n) scanf("%d", &n); #define scl(n) scanf("%lld", &n); #define load(array, size) \ for (ll i = 0; i < size; i++) \ cin >> array[i]; #define load1(array, size) \ for (ll i = 1; i <= size; i++) \ cin >> array[i]; #define INF 1LL << 19 #define pll pair<ll, ll> #define mst(arr, value) memset(arr, value, sizeof(arr)); const ll MOD = 1e9 + 7; typedef vector<ll> vec; typedef pair<ll, ll> pii; typedef map<ll, ll> mpll; typedef set<ll> seet; vec primes; // int main() { string a; cin >> a; int ans = 0; if (a.size() == 1) { cout << 0 << endl; return 0; } for (int i = 0, j = a.size() - 1; i < a.size() / 2, j >= a.size() / 2; i++, j--) { if (a[i] != a[j]) ans++; } cout << ans << endl; return 0; }
insert
44
44
44
48
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; int cnt = 0; for (int i = 0; i < s.length() - 1 - i; i++) if (s[i] != s[s.length() - 1 - i]) cnt++; cout << cnt << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int cnt = 0; getline(cin, s); for (int i = 0; i < s.length() - 1 - i; i++) if (s[i] != s[s.length() - 1 - i]) cnt++; cout << cnt << "\n"; return 0; }
insert
5
5
5
6
-11
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ cin >> aa; \ (p).push_back(aa); #define vecpl2(p) \ long long a b; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define MOD 1000000007 #define cey ce("Yes") #define cen ce("No") #define ceY ce("YES") #define ceN ce("NO") int main() { string S; cin >> S; int ans = 0; for (int i = 0; i <= S.size() - i - 1; i++) { if (S[i] != S[S.size() - i - 1]) { ans++; } } ce(ans) return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define fw(p) for (int w = 0; w < (p); w++) #define fx(p) for (int x = 0; x < (p); x++) #define fy(p) for (int y = 0; y < (p); y++) #define fz(p) for (int z = 0; z < (p); z++) #define fyg(p, g) for (int y = (g); y < (p); y++) #define fzg(p, g) for (int z = (g); z < (p); z++) #define ce(d) cout << d << endl; #define vecp(p) \ int aa; \ cin >> aa; \ (p).push_back(aa); #define vecpl(p) \ long long aa; \ cin >> aa; \ (p).push_back(aa); #define vecps(p) \ string aa; \ cin >> aa; \ (p).push_back(aa); #define vecp2(p) \ cin >> aa; \ (p).push_back(aa); #define vecpl2(p) \ long long a b; \ cin >> ab; \ (p).push_back(ab); #define vecps2(p) \ string ab; \ cin >> ab; \ (p).push_back(ab); #define sorts(c) sort((c).begin(), (c).end()); #define reverses(c) reverse((c).begin(), (c).end()); #define vec(b) vector<int>(b); #define vecl(b) vector<long long>(b); #define vecs(b) vector<string>(b); #define pb(b, a) (b).push_back((a)); #define doublece(a, b) cout << (a) << ' ' << (b) << endl; #define pairs(s) vector<pair<int, int>>(s); #define pairsp(s) \ int aa, bb; \ cin >> aa >> bb; \ (s).push_back(make_pair(aa, bb)); #define MOD 1000000007 #define cey ce("Yes") #define cen ce("No") #define ceY ce("YES") #define ceN ce("NO") int main() { string S; cin >> S; int ans = 0; for (int i = 0; i <= (int)S.size() - i - 1; i++) { if (S[i] != S[S.size() - i - 1]) { ans++; } } ce(ans) return 0; }
replace
57
58
57
58
0
p02836
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; using ll = long long; typedef pair<int, int> P; int main() { string s; cin >> s; int k = s.size(); int ans = 0; for (int i = 0; i < k / 2; k++) { if (s[i] != s[k - i - 1]) { ans++; } } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; using ll = long long; typedef pair<int, int> P; int main() { string s; cin >> s; int k = s.size(); int ans = 0; for (int i = 0; i < k / 2; i++) { if (s[i] != s[k - i - 1]) { ans++; } } cout << ans << endl; return 0; }
replace
13
14
13
14
TLE
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif #define REP(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) #define A first #define B second #define MOD 1000000007 typedef pair<int, int> ii; typedef vector<ii> vii; typedef long long ll; int mulmd(ll a, ll b) { ll ret = (a * b) % MOD; return (int)ret; } inline int power(ll x, ll y, int p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = mulmd(res, x); y = y >> 1; x = mulmd(x, x); } return (int)res; } int submd(ll a, ll b) { ll ret = a - b; if (ret < 0) { ret += MOD; } return (int)ret; } int addmd(ll a, ll b) { ll ret = (a + b) % MOD; return (int)ret; } int invPow(ll a) { return power(a, MOD - 2, MOD); } const int N = 1e5 + 5; int arr[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int cnt = 0; FOR(i, 0, s.size() / 2 - 1) { if (s[i] == s[s.size() - i - 1]) continue; else cnt++; } cout << cnt; } /** Check out for boundary cases, (n = 1 or n = 0) check for integer overflow **/
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif #define REP(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) #define A first #define B second #define MOD 1000000007 typedef pair<int, int> ii; typedef vector<ii> vii; typedef long long ll; int mulmd(ll a, ll b) { ll ret = (a * b) % MOD; return (int)ret; } inline int power(ll x, ll y, int p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = mulmd(res, x); y = y >> 1; x = mulmd(x, x); } return (int)res; } int submd(ll a, ll b) { ll ret = a - b; if (ret < 0) { ret += MOD; } return (int)ret; } int addmd(ll a, ll b) { ll ret = (a + b) % MOD; return (int)ret; } int invPow(ll a) { return power(a, MOD - 2, MOD); } const int N = 1e5 + 5; int arr[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int cnt = 0; int n = s.size(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) cnt++; } cout << cnt; } /** Check out for boundary cases, (n = 1 or n = 0) check for integer overflow **/
replace
100
104
100
103
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string S = 0; cin >> S; for (int i = 0, j = S.length() - 1; i < j; i++, j--) { if (S[i] != S[j]) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string S; cin >> S; for (int i = 0, j = S.length() - 1; i < j; i++, j--) { if (S[i] != S[j]) { ans++; } } cout << ans << endl; }
replace
4
5
4
5
-6
terminate called after throwing an instance of 'std::logic_error' what(): basic_string: construction from null is not valid
p02836
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main() { string a; getline(cin, a); int l = 0; for (int i = 0; i < a.length(); i++) { for (int j = a.length() - 1; j >= 0; j++) { if (a[i] != a[j]) { l++; } } } cout << l; }
#include <iostream> #include <string> using namespace std; int main() { string a; getline(cin, a); int l = 0, k = a.length(); for (int i = 0; i < k / 2; i++) { if (a[i] != a[k - i - 1]) { l++; } } cout << l; }
replace
6
12
6
10
TLE
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int a = 0; for (int i = 0; i < S.size() / 2 - 1; i++) { if (S.at(i) != S.at(S.size() - i - 1)) a++; } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int a = 0; for (int i = 0; i < S.size() / 2; i++) { if (S.at(i) != S.at(S.size() - i - 1)) a++; } cout << a << endl; }
replace
6
7
6
7
0
p02836
C++
Runtime Error
/* ∧,,∧ ( 'ω' )つ <WA,またお前か!!  (m9 \      \  \     ) ) \   // \ \   (_)   (_) */ #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rep(x, y) for (int x = 0; x < y; x++) #define MOD 1000000007 typedef long long LL; typedef long double LD; bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } ostringstream oss_global; string s_global = oss_global.str(); int main() { string s; cin >> s; int ans = 0; for (int i = 0; i <= s.length() / 2 - 1; i++) { char a, b; a = s[i]; b = s[s.length() - i - 1]; if (a - b) ans++; } cout << ans << endl; return 0; }
/* ∧,,∧ ( 'ω' )つ <WA,またお前か!!  (m9 \      \  \     ) ) \   // \ \   (_)   (_) */ #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rep(x, y) for (int x = 0; x < y; x++) #define MOD 1000000007 typedef long long LL; typedef long double LD; bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } ostringstream oss_global; string s_global = oss_global.str(); int main() { string s; cin >> s; if (s.length() == 1) { cout << "0" << endl; return 0; } int ans = 0; for (int i = 0; i <= s.length() / 2 - 1; i++) { char a, b; a = s[i]; b = s[s.length() - i - 1]; if (a - b) ans++; } cout << ans << endl; return 0; }
insert
35
35
35
40
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define rep2(i, n) for (int i = 0; i <= n; i++) #define repr(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define P pair<long long, long long> #define double long double #define INF 1e10 #define MOD 1e9 + 7 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } using Graph = vector<vector<int>>; signed main() { string a; cin >> a; int b = 0; if (a.size() % 2 == 0) { rep(i, a.size() / 2) { if (a[i] != a[a.size() - 1 - i]) b++; } cout << b; } else { rep(i, a.size() / 2 - 1) { if (a[i] != a[a.size() - 1 - i]) b++; } cout << b; } }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define rep2(i, n) for (int i = 0; i <= n; i++) #define repr(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define P pair<long long, long long> #define double long double #define INF 1e10 #define MOD 1e9 + 7 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } using Graph = vector<vector<int>>; signed main() { string a; cin >> a; int b = 0; if (a.size() % 2 == 0) { rep(i, a.size() / 2) { if (a[i] != a[a.size() - 1 - i]) b++; } cout << b; } else { rep(i, (a.size() - 1) / 2) { if (a[i] != a[a.size() - 1 - i]) b++; } cout << b; } }
replace
38
39
38
39
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { string s; cin >> s; int ans = 0; for (int i = 0; i <= s.size() - 1 - i; i++) { if (s[i] != s[s.size() - 1 - i]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { string s; cin >> s; int ans = 0; for (int i = 0; i < s.size(); i++) { int j = s.size() - 1 - i; if (s[i] != s[j] && i < j) ans++; } cout << ans << endl; return 0; }
replace
10
12
10
13
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { string s; cin >> s; int count = 0; rep(i, s.size() / 2) { if (s.at(i) != s.at(s.size() - i)) { count++; } } cout << count; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { string s; cin >> s; int count = 0; rep(i, s.size() / 2) { if (s.at(i) != s.at(s.size() - 1 - i)) { count++; } } cout << count; }
replace
9
10
9
10
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 8) >= this->size() (which is 8)
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; int a; cin >> s; a = s.size(); int count = 0; for (int i = 0; i < a; i++) { if (s.at(i) != s.at(a - i)) { count++; } } cout << count / 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int a; cin >> s; a = s.size(); int count = 0; for (int i = 0; i < a; i++) { if (s.at(i) != s.at(a - i - 1)) { count++; } } cout << count / 2 << 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 8) >= this->size() (which is 8)
p02836
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; int i = 0; int j = s.size() - 1; while (i <= j) { if (s[i] != s[j]) { cnt++; } } cout << cnt; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; int i = 0; int j = s.size() - 1; while (i <= j) { if (s[i] != s[j]) { cnt++; } i++; j--; } cout << cnt; }
insert
14
14
14
16
TLE
p02836
C++
Runtime Error
#include <cstring> #include <iostream> using namespace std; int lenght(char *str) { int a = strlen(str); return a; } int main() { char str[10]; cin >> str; int l = lenght(str); int m = (l + 1) / 2; int counter = 0; for (int i = 0; i < m; ++i) { if (str[i] == str[l - i - 1]) ++counter; } int x = m - counter; cout << x << endl; }
#include <cstring> #include <iostream> using namespace std; int lenght(char *str) { int a = strlen(str); return a; } int main() { char str[100]; cin >> str; int l = lenght(str); int m = (l + 1) / 2; int counter = 0; for (int i = 0; i < m; ++i) { if (str[i] == str[l - i - 1]) ++counter; } int x = m - counter; cout << x << endl; }
replace
10
11
10
11
0
p02836
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> typedef long long ll; #define mop 1000000007 using namespace std; int main() { string s; cin >> s; ll lenS = s.length(); ll ans = 0; // if(lenS%2 == 0){ ll tmp = 0; while (true) { if (s[tmp] != s[s.length() - 1 - tmp]) { ans++; } tmp++; if (tmp == lenS / 2) break; } cout << ans << endl; // // }else{ // ll tmp = 0; // while(true) { // if (s[tmp] != s[s.length() - 1 - tmp]) { // ans++; // } // tmp++; // if(tmp == lenS/2) break; // } // } }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> typedef long long ll; #define mop 1000000007 using namespace std; int main() { string s; cin >> s; ll lenS = s.length(); ll ans = 0; // if(lenS%2 == 0){ ll tmp = 0; while (true) { if (s.length() == 1) break; if (s[tmp] != s[s.length() - 1 - tmp]) { ans++; } tmp++; if (tmp == lenS / 2) break; } cout << ans << endl; // // }else{ // ll tmp = 0; // while(true) { // if (s[tmp] != s[s.length() - 1 - tmp]) { // ans++; // } // tmp++; // if(tmp == lenS/2) break; // } // } }
insert
32
32
32
34
0
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> using namespace std; int main() { string S; cin >> S; int ans = 0; for (int i = 0;; i++) { if (S.size() - 1 - i < i) break; if (S[i] != S[S.size() - 1 - i]) ans++; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> using namespace std; int main() { string S; cin >> S; int ans = 0; if (S.size() == 1) { cout << 0 << endl; return 0; } for (int i = 0;; i++) { if (S.size() - 1 - i < i) break; if (S[i] != S[S.size() - 1 - i]) ans++; } cout << ans << endl; return 0; }
insert
10
10
10
14
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define pb push_back #define f(i, n) for (i = 0; i < n; i++) #define F(i, a, b) for (i = a; a <= b; i++) #define arr(a, n) \ for (i = 0; i < n; i++) \ cin >> a[i]; #define fi first #define se second #define mp make_pair #define mod 1000000007 #define YES cout << "YES" << endl; #define Yes cout << "Yes" << endl; #define NO cout << "NO" << endl; #define No cout << "No" << endl; #define yes cout << "yes" << endl; #define no cout << "no" << endl; #define vi vector<ll> #define ed end() #define bg begin() #define sz size() #define ln length() #define s() sort(a, a + n); #define sr() sort(a, a + n, greater<ll>()); #define v() sort(v.begin(), v.end()); #define vr() sort(v.begin(), v.end(), greater<ll>()); #define mod 1000000007 #define fast() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) int main() { #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif fast(); ll n, c = 0; string s; cin >> s; n = s.length(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) c++; } cout << c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define pb push_back #define f(i, n) for (i = 0; i < n; i++) #define F(i, a, b) for (i = a; a <= b; i++) #define arr(a, n) \ for (i = 0; i < n; i++) \ cin >> a[i]; #define fi first #define se second #define mp make_pair #define mod 1000000007 #define YES cout << "YES" << endl; #define Yes cout << "Yes" << endl; #define NO cout << "NO" << endl; #define No cout << "No" << endl; #define yes cout << "yes" << endl; #define no cout << "no" << endl; #define vi vector<ll> #define ed end() #define bg begin() #define sz size() #define ln length() #define s() sort(a, a + n); #define sr() sort(a, a + n, greater<ll>()); #define v() sort(v.begin(), v.end()); #define vr() sort(v.begin(), v.end(), greater<ll>()); #define mod 1000000007 #define fast() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) int main() { /* #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif*/ fast(); ll n, c = 0; string s; cin >> s; n = s.length(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) c++; } cout << c << endl; return 0; }
replace
36
42
36
42
0
p02836
C++
Runtime Error
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string.h> #include <vector> typedef long long ll; constexpr long long INFLL = 1e18; using namespace std; int main() { string s; cin >> s; int count = 0; for (int i = 0; i <= s.size(); i++) { if (s.at(i) != s.at(s.size() - 1 - i)) { count++; } } cout << count << endl; return 0; }
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string.h> #include <vector> typedef long long ll; constexpr long long INFLL = 1e18; using namespace std; int main() { string s; cin >> s; int count = 0; for (int i = 0; i < s.size() / 2; i++) { if (s.at(i) != s.at(s.size() - 1 - i)) { count++; } } cout << count << endl; return 0; }
replace
21
22
21
22
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 8) >= this->size() (which is 8)
p02836
C++
Runtime Error
#include <bits/stdc++.h> #define MAXN 1000100 #define pii pair<int, int> #define pb push_back #define inf 1e18 #define fi first #define se second #define mt make_tuple typedef long long ll; using namespace std; string s; int ans; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> s; int n = s.size(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) ans++; } cout << ans; }
#include <bits/stdc++.h> #define MAXN 1000100 #define pii pair<int, int> #define pb push_back #define inf 1e18 #define fi first #define se second #define mt make_tuple typedef long long ll; using namespace std; string s; int ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> s; int n = s.size(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - i - 1]) ans++; } cout << ans; }
delete
16
19
16
16
0
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int count = 0; string S; cin >> S; for (int i = 0; 2 * i < S.length(); i++) { if (S.at(i) != S.at(S.length() - i)) { count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int count = 0; string S; cin >> S; for (int i = 0; i < S.length() / 2; i++) { if (S.at(i) != S.at(S.length() - 1 - i)) { count++; } } cout << count << endl; }
replace
8
10
8
10
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 8) >= this->size() (which is 8)
p02836
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = 0, r = s.size() - 1; int ans = 0; while (l < r) { ans += s[l] != s[r]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = 0, r = s.size() - 1; int ans = 0; while (l < r) { ans += s[l] != s[r]; l++; r--; } cout << ans << endl; }
insert
10
10
10
12
TLE
p02836
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int c = 0; string s; cin >> s; int i = 0, j = s.length() - 1; while (i <= j) { if (s[i] != s[j]) c++; } cout << c << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int c = 0; string s; cin >> s; int i = 0, j = s.length() - 1; while (i <= j) { if (s[i] != s[j]) c++; i++; j--; } cout << c << endl; return 0; }
insert
10
10
10
12
TLE
p02836
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; for (int i = 0; i <= s.size() / 2 - 1; i++) { if (s.at(i) != s.at(s.size() - 1 - i)) cnt++; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; if (s.size() == 1) { } else { for (int i = 0; i <= s.size() / 2 - 1; i++) { if (s.at(i) != s.at(s.size() - 1 - i)) cnt++; } } cout << cnt << endl; return 0; }
replace
8
11
8
14
0
p02836
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() / 2; i++) { for (int j = S.size() - 1; j > S.size() / 2; j++) { if (S[i] != S[j]) { ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int ans = 0; for (int i = 0; i < S.size() / 2; i++) { if (S[i] != S[S.size() - i - 1]) { ans++; } } cout << ans << endl; }
replace
8
12
8
10
-11
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; namespace { using lint = long long; using uli = unsigned long long; uli gcd(uli a, uli b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } uli lcm(uli a, uli b) { return a / gcd(a, b) * b; } const uli mod = 1000000007; const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; uli FactMod(uli n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; ans %= mod; } return ans; } uli _PowMod(uli x, uli y, uli _mod) { if (x <= 1) { return x; } if (y == 0) { return 1; } else if (y == 1) { return x % _mod; } else if (y % 2 == 0) { auto tmp = _PowMod(x, y / 2, _mod); return tmp * tmp % _mod; } else { auto tmp = _PowMod(x, y / 2, _mod); return (tmp * tmp % _mod) * x % _mod; } } uli PowMod(uli x, uli y) { return _PowMod(x, y, mod); } uli getModInv(uli N) { return PowMod(N, mod - 2); } lint nCrMod(lint start, lint n, lint r) { if (n < r || n <= 0 || r < 0) { return 0; } r = min(r, n - r); lint a = start; for (size_t i = n; i >= n - r + 1; i--) { a *= i; a %= mod; } a *= getModInv(FactMod(r)); a %= mod; return a; } lint nHrMod(lint start, lint n, lint r) { return nCrMod(start, n + r - 1, r); } struct uf { vector<lint> p; uf(lint n) : p(n) { for (size_t i = 0; i < n; i++) { p[i] = i; } } lint rt(lint n) { return p[n] == n ? n : p[n] = rt(p[n]); } void un(lint n, lint m) { p[rt(n)] = p[rt(m)]; } bool eq(lint n, lint m) { return rt(n) == rt(m); } }; bool lineCol(lint a1x, lint a1y, lint a2x, lint a2y, lint b1x, lint b1y, lint b2x, lint b2y) { auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x); auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x); auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x); auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x); return tc * td < 0 && ta * tb < 0; } lint powInt(lint a, lint b) { if (b == 0) { return 1; } if (b == 1) { return a; } lint tmp = powInt(a, b / 2); return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp); } lint _sMod(string n, lint mod) { lint k = (n[0] - '0') % mod; for (size_t i = 1; i < n.length(); i++) { k *= 10; k += (n[i] - '0'); k %= mod; } return k; } #define vec(name, n) vector<lint> name(n) #define vec_(name, n, init) vector<lint> name(n, init) #define vecs(name, n) vector<string> name(n) #define vect(t, name, n) vector<t> name(n) #define vec2(name, n, m) vector<vector<lint>> name(n, vector<lint>(m)) #define vec2_(name, n, m, init) \ vector<vector<lint>> name(n, vector<lint>(m, init)) #define rep(i, n) for (lint i = 0; i < n; i++) #define repi(i, n, z) for (lint i = z; i < n; i++) #define mmax(a, b) max((lint)a, (lint)b) #define mmin(a, b) min((lint)a, (lint)b) template <typename T> void vsort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void vsortr(vector<T> &v) { sort(v.rbegin(), v.rend()); } lint div2(lint p, lint q) { return (p + q - 1) / q; } struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} }; template <class It, class T> bool exist(It begin, It end, const T &val) { return find(begin, end, val) != end; } template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) { return find_if(begin, end, pred) != end; } lint n_dig(lint n) { lint ans = 0; while (n > 0) { n /= 10; ans++; } return ans; } template <class T, class T2> T2 ler(T val1, T val2, T2 l, T2 e, T2 r) { if (val1 < val2) return r; if (val1 > val2) return l; return e; } const lint alpn = 'z' - 'a' + 1; template <class T> T sgn(T val) { if (val == T(0)) return T(0); if (val < 0) return T(-1); if (val > 0) return T(1); } template <class T> bool between(T val, T l, T r) { return (val >= l) && (val <= r); } #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() template <class It> vector<lint> carr(It begin, It end) { vec(c, 0); c.push_back(1); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(0); before = *it; } c.back()++; } return c; } template <class T> struct nval { lint n; T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It> auto carr2(It begin, It end) { using T = nval<remove_reference_t<decltype(*begin)>>; vect(T, c, 0); c.push_back(T(1, *begin)); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(T(0, *it)); before = *it; } c.back().n++; } return c; } lint sumdig(lint n) { lint ans = 0; while (n > 0) { ans += n % 10; n /= 10; } return ans; } lint getdig(lint n, lint d) { return (n / powInt(10, d)) % 10; } template <typename It, typename T> void sort2(It begin, It end, T It::value_type::*p) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p](val_t a, val_t b) { return a.*p < b.*p; }); } template <typename It, typename T, typename T2> void sort3(It begin, It end, T It::value_type::*p, T2 It::value_type::*p2) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p, p2](val_t a, val_t b) { if (a.*p != b.*p) { return a.*p < b.*p; } else { return a.*p2 > b.*p2; } }); } auto parr(lint n) { vector<nval<lint>> d; lint n_ = n; for (lint i = 2; i * i <= n; i++) { if (n_ % i == 0) { d.push_back(nval<lint>(1, i)); n_ /= i; while (n_ % i == 0) { n_ /= i; d.back().n++; } } } if (n_ > 1) { d.push_back(nval<lint>(1, n_)); } return d; } long double dist_1(xy p, xy q) { return abs(p.x - q.x) + abs(p.y - q.y); } long double dist_2(xy p, xy q) { return sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)); } long double dist_inf(xy p, xy q) { return max(abs(p.x - q.x), abs(p.y - q.y)); } lint factr(lint n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; } return ans; } lint mod0(lint n, lint mod) { lint tmp = n % mod; if (tmp == 0) return mod; return tmp; } } // namespace int main() { string s; cin >> s; lint ans = 0; for (lint i = 0; i <= s.length() - i - 1; i++) { if (s[i] != s[s.length() - i - 1]) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; namespace { using lint = long long; using uli = unsigned long long; uli gcd(uli a, uli b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } uli lcm(uli a, uli b) { return a / gcd(a, b) * b; } const uli mod = 1000000007; const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; uli FactMod(uli n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; ans %= mod; } return ans; } uli _PowMod(uli x, uli y, uli _mod) { if (x <= 1) { return x; } if (y == 0) { return 1; } else if (y == 1) { return x % _mod; } else if (y % 2 == 0) { auto tmp = _PowMod(x, y / 2, _mod); return tmp * tmp % _mod; } else { auto tmp = _PowMod(x, y / 2, _mod); return (tmp * tmp % _mod) * x % _mod; } } uli PowMod(uli x, uli y) { return _PowMod(x, y, mod); } uli getModInv(uli N) { return PowMod(N, mod - 2); } lint nCrMod(lint start, lint n, lint r) { if (n < r || n <= 0 || r < 0) { return 0; } r = min(r, n - r); lint a = start; for (size_t i = n; i >= n - r + 1; i--) { a *= i; a %= mod; } a *= getModInv(FactMod(r)); a %= mod; return a; } lint nHrMod(lint start, lint n, lint r) { return nCrMod(start, n + r - 1, r); } struct uf { vector<lint> p; uf(lint n) : p(n) { for (size_t i = 0; i < n; i++) { p[i] = i; } } lint rt(lint n) { return p[n] == n ? n : p[n] = rt(p[n]); } void un(lint n, lint m) { p[rt(n)] = p[rt(m)]; } bool eq(lint n, lint m) { return rt(n) == rt(m); } }; bool lineCol(lint a1x, lint a1y, lint a2x, lint a2y, lint b1x, lint b1y, lint b2x, lint b2y) { auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x); auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x); auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x); auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x); return tc * td < 0 && ta * tb < 0; } lint powInt(lint a, lint b) { if (b == 0) { return 1; } if (b == 1) { return a; } lint tmp = powInt(a, b / 2); return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp); } lint _sMod(string n, lint mod) { lint k = (n[0] - '0') % mod; for (size_t i = 1; i < n.length(); i++) { k *= 10; k += (n[i] - '0'); k %= mod; } return k; } #define vec(name, n) vector<lint> name(n) #define vec_(name, n, init) vector<lint> name(n, init) #define vecs(name, n) vector<string> name(n) #define vect(t, name, n) vector<t> name(n) #define vec2(name, n, m) vector<vector<lint>> name(n, vector<lint>(m)) #define vec2_(name, n, m, init) \ vector<vector<lint>> name(n, vector<lint>(m, init)) #define rep(i, n) for (lint i = 0; i < n; i++) #define repi(i, n, z) for (lint i = z; i < n; i++) #define mmax(a, b) max((lint)a, (lint)b) #define mmin(a, b) min((lint)a, (lint)b) template <typename T> void vsort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void vsortr(vector<T> &v) { sort(v.rbegin(), v.rend()); } lint div2(lint p, lint q) { return (p + q - 1) / q; } struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} }; template <class It, class T> bool exist(It begin, It end, const T &val) { return find(begin, end, val) != end; } template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) { return find_if(begin, end, pred) != end; } lint n_dig(lint n) { lint ans = 0; while (n > 0) { n /= 10; ans++; } return ans; } template <class T, class T2> T2 ler(T val1, T val2, T2 l, T2 e, T2 r) { if (val1 < val2) return r; if (val1 > val2) return l; return e; } const lint alpn = 'z' - 'a' + 1; template <class T> T sgn(T val) { if (val == T(0)) return T(0); if (val < 0) return T(-1); if (val > 0) return T(1); } template <class T> bool between(T val, T l, T r) { return (val >= l) && (val <= r); } #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() template <class It> vector<lint> carr(It begin, It end) { vec(c, 0); c.push_back(1); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(0); before = *it; } c.back()++; } return c; } template <class T> struct nval { lint n; T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It> auto carr2(It begin, It end) { using T = nval<remove_reference_t<decltype(*begin)>>; vect(T, c, 0); c.push_back(T(1, *begin)); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(T(0, *it)); before = *it; } c.back().n++; } return c; } lint sumdig(lint n) { lint ans = 0; while (n > 0) { ans += n % 10; n /= 10; } return ans; } lint getdig(lint n, lint d) { return (n / powInt(10, d)) % 10; } template <typename It, typename T> void sort2(It begin, It end, T It::value_type::*p) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p](val_t a, val_t b) { return a.*p < b.*p; }); } template <typename It, typename T, typename T2> void sort3(It begin, It end, T It::value_type::*p, T2 It::value_type::*p2) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p, p2](val_t a, val_t b) { if (a.*p != b.*p) { return a.*p < b.*p; } else { return a.*p2 > b.*p2; } }); } auto parr(lint n) { vector<nval<lint>> d; lint n_ = n; for (lint i = 2; i * i <= n; i++) { if (n_ % i == 0) { d.push_back(nval<lint>(1, i)); n_ /= i; while (n_ % i == 0) { n_ /= i; d.back().n++; } } } if (n_ > 1) { d.push_back(nval<lint>(1, n_)); } return d; } long double dist_1(xy p, xy q) { return abs(p.x - q.x) + abs(p.y - q.y); } long double dist_2(xy p, xy q) { return sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)); } long double dist_inf(xy p, xy q) { return max(abs(p.x - q.x), abs(p.y - q.y)); } lint factr(lint n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; } return ans; } lint mod0(lint n, lint mod) { lint tmp = n % mod; if (tmp == 0) return mod; return tmp; } } // namespace int main() { string s; cin >> s; lint ans = 0; lint n = s.length(); for (lint i = 0; i <= n - i - 1; i++) { if (s[i] != s[n - i - 1]) { ans++; } } cout << ans << endl; return 0; }
replace
326
328
326
330
0
p02836
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; namespace { using lint = long long; using uli = unsigned long long; uli gcd(uli a, uli b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } uli lcm(uli a, uli b) { return a / gcd(a, b) * b; } const uli mod = 1000000007; const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; uli FactMod(uli n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; ans %= mod; } return ans; } uli _PowMod(uli x, uli y, uli _mod) { if (x <= 1) { return x; } if (y == 0) { return 1; } else if (y == 1) { return x % _mod; } else if (y % 2 == 0) { auto tmp = _PowMod(x, y / 2, _mod); return tmp * tmp % _mod; } else { auto tmp = _PowMod(x, y / 2, _mod); return (tmp * tmp % _mod) * x % _mod; } } uli PowMod(uli x, uli y) { return _PowMod(x, y, mod); } uli getModInv(uli N) { return PowMod(N, mod - 2); } lint nCrMod(lint start, lint n, lint r) { if (n < r || n <= 0 || r < 0) { return 0; } r = min(r, n - r); lint a = start; for (size_t i = n; i >= n - r + 1; i--) { a *= i; a %= mod; } a *= getModInv(FactMod(r)); a %= mod; return a; } lint nHrMod(lint start, lint n, lint r) { return nCrMod(start, n + r - 1, r); } struct uf { vector<lint> p; uf(lint n) : p(n) { for (size_t i = 0; i < n; i++) { p[i] = i; } } lint rt(lint n) { return p[n] == n ? n : p[n] = rt(p[n]); } void un(lint n, lint m) { p[rt(n)] = p[rt(m)]; } bool eq(lint n, lint m) { return rt(n) == rt(m); } }; bool lineCol(lint a1x, lint a1y, lint a2x, lint a2y, lint b1x, lint b1y, lint b2x, lint b2y) { auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x); auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x); auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x); auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x); return tc * td < 0 && ta * tb < 0; } lint powInt(lint a, lint b) { if (b == 0) { return 1; } if (b == 1) { return a; } lint tmp = powInt(a, b / 2); return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp); } lint _sMod(string n, lint mod) { lint k = (n[0] - '0') % mod; for (size_t i = 1; i < n.length(); i++) { k *= 10; k += (n[i] - '0'); k %= mod; } return k; } #define vec(name, n) vector<lint> name(n) #define vec_(name, n, init) vector<lint> name(n, init) #define vecs(name, n) vector<string> name(n) #define vect(t, name, n) vector<t> name(n) #define vec2(name, n, m) vector<vector<lint>> name(n, vector<lint>(m)) #define vec2_(name, n, m, init) \ vector<vector<lint>> name(n, vector<lint>(m, init)) #define rep(i, n) for (lint i = 0; i < n; i++) #define repi(i, n, z) for (lint i = z; i < n; i++) #define mmax(a, b) max((lint)a, (lint)b) #define mmin(a, b) min((lint)a, (lint)b) template <typename T> void vsort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void vsortr(vector<T> &v) { sort(v.rbegin(), v.rend()); } lint div2(lint p, lint q) { return (p + q - 1) / q; } struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} }; template <class It, class T> bool exist(It begin, It end, const T &val) { return find(begin, end, val) != end; } template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) { return find_if(begin, end, pred) != end; } lint n_dig(lint n) { lint ans = 0; while (n > 0) { n /= 10; ans++; } return ans; } template <class T, class T2> T2 ler(T val1, T val2, T2 l, T2 e, T2 r) { if (val1 < val2) return r; if (val1 > val2) return l; return e; } const lint alpn = 'z' - 'a' + 1; template <class T> T sgn(T val) { if (val == T(0)) return T(0); if (val < 0) return T(-1); if (val > 0) return T(1); } template <class T> bool between(T val, T l, T r) { return (val >= l) && (val <= r); } #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() template <class It> vector<lint> carr(It begin, It end) { vec(c, 0); c.push_back(1); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(0); before = *it; } c.back()++; } return c; } template <class T> struct nval { lint n; T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It> auto carr2(It begin, It end) { using T = nval<remove_reference_t<decltype(*begin)>>; vect(T, c, 0); c.push_back(T(1, *begin)); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(T(0, *it)); before = *it; } c.back().n++; } return c; } lint sumdig(lint n) { lint ans = 0; while (n > 0) { ans += n % 10; n /= 10; } return ans; } lint getdig(lint n, lint d) { return (n / powInt(10, d)) % 10; } template <typename It, typename T> void sort2(It begin, It end, T It::value_type::*p) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p](val_t a, val_t b) { return a.*p < b.*p; }); } template <typename It, typename T, typename T2> void sort3(It begin, It end, T It::value_type::*p, T2 It::value_type::*p2) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p, p2](val_t a, val_t b) { if (a.*p != b.*p) { return a.*p < b.*p; } else { return a.*p2 > b.*p2; } }); } auto parr(lint n) { vector<nval<lint>> d; lint n_ = n; for (lint i = 2; i * i <= n; i++) { if (n_ % i == 0) { d.push_back(nval<lint>(1, i)); n_ /= i; while (n_ % i == 0) { n_ /= i; d.back().n++; } } } if (n_ > 1) { d.push_back(nval<lint>(1, n_)); } return d; } long double dist_1(xy p, xy q) { return abs(p.x - q.x) + abs(p.y - q.y); } long double dist_2(xy p, xy q) { return sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)); } long double dist_inf(xy p, xy q) { return max(abs(p.x - q.x), abs(p.y - q.y)); } lint factr(lint n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; } return ans; } lint mod0(lint n, lint mod) { lint tmp = n % mod; if (tmp == 0) return mod; return tmp; } } // namespace int main() { string s; cin >> s; lint ans = 0; for (lint i = 0; i <= s.length() - i - 1; i++) { if (s[i] != s[s.length() - i - 1]) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; namespace { using lint = long long; using uli = unsigned long long; uli gcd(uli a, uli b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } uli lcm(uli a, uli b) { return a / gcd(a, b) * b; } const uli mod = 1000000007; const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; uli FactMod(uli n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; ans %= mod; } return ans; } uli _PowMod(uli x, uli y, uli _mod) { if (x <= 1) { return x; } if (y == 0) { return 1; } else if (y == 1) { return x % _mod; } else if (y % 2 == 0) { auto tmp = _PowMod(x, y / 2, _mod); return tmp * tmp % _mod; } else { auto tmp = _PowMod(x, y / 2, _mod); return (tmp * tmp % _mod) * x % _mod; } } uli PowMod(uli x, uli y) { return _PowMod(x, y, mod); } uli getModInv(uli N) { return PowMod(N, mod - 2); } lint nCrMod(lint start, lint n, lint r) { if (n < r || n <= 0 || r < 0) { return 0; } r = min(r, n - r); lint a = start; for (size_t i = n; i >= n - r + 1; i--) { a *= i; a %= mod; } a *= getModInv(FactMod(r)); a %= mod; return a; } lint nHrMod(lint start, lint n, lint r) { return nCrMod(start, n + r - 1, r); } struct uf { vector<lint> p; uf(lint n) : p(n) { for (size_t i = 0; i < n; i++) { p[i] = i; } } lint rt(lint n) { return p[n] == n ? n : p[n] = rt(p[n]); } void un(lint n, lint m) { p[rt(n)] = p[rt(m)]; } bool eq(lint n, lint m) { return rt(n) == rt(m); } }; bool lineCol(lint a1x, lint a1y, lint a2x, lint a2y, lint b1x, lint b1y, lint b2x, lint b2y) { auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x); auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x); auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x); auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x); return tc * td < 0 && ta * tb < 0; } lint powInt(lint a, lint b) { if (b == 0) { return 1; } if (b == 1) { return a; } lint tmp = powInt(a, b / 2); return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp); } lint _sMod(string n, lint mod) { lint k = (n[0] - '0') % mod; for (size_t i = 1; i < n.length(); i++) { k *= 10; k += (n[i] - '0'); k %= mod; } return k; } #define vec(name, n) vector<lint> name(n) #define vec_(name, n, init) vector<lint> name(n, init) #define vecs(name, n) vector<string> name(n) #define vect(t, name, n) vector<t> name(n) #define vec2(name, n, m) vector<vector<lint>> name(n, vector<lint>(m)) #define vec2_(name, n, m, init) \ vector<vector<lint>> name(n, vector<lint>(m, init)) #define rep(i, n) for (lint i = 0; i < n; i++) #define repi(i, n, z) for (lint i = z; i < n; i++) #define mmax(a, b) max((lint)a, (lint)b) #define mmin(a, b) min((lint)a, (lint)b) template <typename T> void vsort(vector<T> &v) { sort(v.begin(), v.end()); } template <typename T> void vsortr(vector<T> &v) { sort(v.rbegin(), v.rend()); } lint div2(lint p, lint q) { return (p + q - 1) / q; } struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} }; template <class It, class T> bool exist(It begin, It end, const T &val) { return find(begin, end, val) != end; } template <class It, class Pr> bool exist_if(It begin, It end, Pr pred) { return find_if(begin, end, pred) != end; } lint n_dig(lint n) { lint ans = 0; while (n > 0) { n /= 10; ans++; } return ans; } template <class T, class T2> T2 ler(T val1, T val2, T2 l, T2 e, T2 r) { if (val1 < val2) return r; if (val1 > val2) return l; return e; } const lint alpn = 'z' - 'a' + 1; template <class T> T sgn(T val) { if (val == T(0)) return T(0); if (val < 0) return T(-1); if (val > 0) return T(1); } template <class T> bool between(T val, T l, T r) { return (val >= l) && (val <= r); } #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() template <class It> vector<lint> carr(It begin, It end) { vec(c, 0); c.push_back(1); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(0); before = *it; } c.back()++; } return c; } template <class T> struct nval { lint n; T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It> auto carr2(It begin, It end) { using T = nval<remove_reference_t<decltype(*begin)>>; vect(T, c, 0); c.push_back(T(1, *begin)); auto before = *begin; for (auto it = begin + 1; it != end; it++) { if (before != *it) { c.push_back(T(0, *it)); before = *it; } c.back().n++; } return c; } lint sumdig(lint n) { lint ans = 0; while (n > 0) { ans += n % 10; n /= 10; } return ans; } lint getdig(lint n, lint d) { return (n / powInt(10, d)) % 10; } template <typename It, typename T> void sort2(It begin, It end, T It::value_type::*p) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p](val_t a, val_t b) { return a.*p < b.*p; }); } template <typename It, typename T, typename T2> void sort3(It begin, It end, T It::value_type::*p, T2 It::value_type::*p2) { using val_t = remove_reference_t<decltype(*begin)>; sort(begin, end, [p, p2](val_t a, val_t b) { if (a.*p != b.*p) { return a.*p < b.*p; } else { return a.*p2 > b.*p2; } }); } auto parr(lint n) { vector<nval<lint>> d; lint n_ = n; for (lint i = 2; i * i <= n; i++) { if (n_ % i == 0) { d.push_back(nval<lint>(1, i)); n_ /= i; while (n_ % i == 0) { n_ /= i; d.back().n++; } } } if (n_ > 1) { d.push_back(nval<lint>(1, n_)); } return d; } long double dist_1(xy p, xy q) { return abs(p.x - q.x) + abs(p.y - q.y); } long double dist_2(xy p, xy q) { return sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)); } long double dist_inf(xy p, xy q) { return max(abs(p.x - q.x), abs(p.y - q.y)); } lint factr(lint n) { if (n == 0) { return 1; } lint ans = 1; while (n > 1) { ans *= n; n--; } return ans; } lint mod0(lint n, lint mod) { lint tmp = n % mod; if (tmp == 0) return mod; return tmp; } } // namespace int main() { string s; cin >> s; lint ans = 0; for (lint i = 0; i <= (lint)s.length() - i - 1; i++) { if (s[i] != s[s.length() - i - 1]) { ans++; } } cout << ans << endl; return 0; }
replace
327
328
327
328
0
p02836
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; string s; int ans; int main() { cin >> s; for (int i = 0; i < s.size(); i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = 'a' + s[i] - 'A'; for (int i = 0; i <= s.size() / 2 - 1; i++) ans += (s[i] != s[s.size() - i - 1]); cout << ans; return 0; }
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; string s; int ans; int main() { cin >> s; if (s.size() == 1) { cout << "0"; return 0; } for (int i = 0; i < s.size(); i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = 'a' + s[i] - 'A'; for (int i = 0; i <= s.size() / 2 - 1; i++) ans += (s[i] != s[s.size() - i - 1]); cout << ans; return 0; }
insert
9
9
9
13
0
p02837
C++
Runtime Error
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define next asdnext #define prev asdprev #define dump(x) cout << #x << " = " << (x) << endl; // debug #define SZ(x) ((int)(x).size()) #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, a, b) for (ll i = (a); i <= (b); i++) #define RFOR(i, a, b) for (ll i = (a); i >= (b); i--) #define ps(s) cout << #s << endl; #define pv(v) cout << (v) << endl; #define pvd(v) cout << setprecision(16) << res << endl; #define ALL(a) (a).begin(), (a).end() #define RANGE(a, l, r) (a).begin() + (l), (a).begin() + (r) int main() { int n; cin >> n; vector<vector<pair<int, bool>>> info(n + 1); FOR(i, 1, n) { int a; cin >> a; FOR(j, 1, a) { int x; bool y; cin >> x >> y; info[i].push_back(make_pair(x, y)); } } int res = 0; for (int bit = 0; bit < (1 << (n)); bit++) { vector<bool> memo(n + 1, false); bool isok = true; FOR(digit, 1, n) { if (bit & (1 << (digit - 1))) { memo[digit] = true; } } FOR(digit, 1, n) { if (bit & (1 << (digit - 1))) { FOR(i, 0, info[digit].size() - 1) { if (memo[info[digit][i].first] != info[digit][i].second) { isok = false; } } } } if (!isok) { continue; } int cnt = 0; FOR(i, 1, n) { if (memo[i]) { cnt++; } } res = max(res, cnt); } pv(res) return (0); }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define next asdnext #define prev asdprev #define dump(x) cout << #x << " = " << (x) << endl; // debug #define SZ(x) ((int)(x).size()) #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, a, b) for (ll i = (a); i <= (b); i++) #define RFOR(i, a, b) for (ll i = (a); i >= (b); i--) #define ps(s) cout << #s << endl; #define pv(v) cout << (v) << endl; #define pvd(v) cout << setprecision(16) << res << endl; #define ALL(a) (a).begin(), (a).end() #define RANGE(a, l, r) (a).begin() + (l), (a).begin() + (r) int main() { int n; cin >> n; vector<vector<pair<int, bool>>> info(n + 1); FOR(i, 1, n) { int a; cin >> a; FOR(j, 1, a) { int x; bool y; cin >> x >> y; info[i].push_back(make_pair(x, y)); } } int res = 0; for (int bit = 0; bit < (1 << (n)); bit++) { vector<bool> memo(n + 1, false); bool isok = true; FOR(digit, 1, n) { if (bit & (1 << (digit - 1))) { memo[digit] = true; } } FOR(digit, 1, n) { if (bit & (1 << (digit - 1))) { FOR(i, 0, SZ(info[digit]) - 1) { if (memo[info[digit][i].first] != info[digit][i].second) { isok = false; } } } } if (!isok) { continue; } int cnt = 0; FOR(i, 1, n) { if (memo[i]) { cnt++; } } res = max(res, cnt); } pv(res) return (0); }
replace
52
53
52
53
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fastio \ cin.tie(NULL); \ cout.tie(NULL); \ ios_base::sync_with_stdio(0) typedef long long ll; // #define int ll #define swap(x, y) ((x) ^= (y) ^= (x) ^= (y)) typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vector<int>> matrix; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define all(c) c.begin(), c.end() #define mp make_pair #define pb push_back #define f first #define tcase \ int _; \ cin >> _; \ for (; _; --_) #define s second #define endl '\n' const int MAX = 1e6 + 1; const int INF = 0x3f3f3f3f; const double PI = acos(-1); const double DEG = 180 / PI; const int MOD = 1e9 + 7; int mod(int x, int m) { if (x >= 0) return x % m; if (-x < m) return m - (-x); return mod(x % m, m); } int gcd(int a, int b) { while (b) { a = mod(a, b); swap(a, b); } return a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int fexp(int base, int exp, int m) { int total = 1; while (exp > 0) { if (exp % 2 == 1) { total = mod(((mod(total, m)) * (mod(base, m))), m); exp--; } base = mod((mod(base, m) * mod(base, m)), m); exp /= 2; } return mod(total, m); } int n; void solve() { cin >> n; vi a(n + 1); matrix x(n + 1, vi(n + 1)); matrix y(n, vi(n)); for (int i = 1; i <= n; ++i) { cin >> a[i]; for (int j = 1; j <= a[i]; ++j) cin >> x[i][j] >> y[i][j]; } int ans = 0; for (int i = 1; i < (1 << n); ++i) { bool flag = 1; for (int j = 1; j <= n; ++j) { if (!(i & (1 << (j - 1)))) continue; for (int k = 1; k <= a[j]; ++k) if (((i >> (x[j][k] - 1)) & 1) ^ y[j][k]) flag = 0; } if (flag) ans = max(ans, __builtin_popcount(i)); } cout << ans << endl; } int32_t main() { fastio; solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define fastio \ cin.tie(NULL); \ cout.tie(NULL); \ ios_base::sync_with_stdio(0) typedef long long ll; // #define int ll #define swap(x, y) ((x) ^= (y) ^= (x) ^= (y)) typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vector<int>> matrix; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define all(c) c.begin(), c.end() #define mp make_pair #define pb push_back #define f first #define tcase \ int _; \ cin >> _; \ for (; _; --_) #define s second #define endl '\n' const int MAX = 1e6 + 1; const int INF = 0x3f3f3f3f; const double PI = acos(-1); const double DEG = 180 / PI; const int MOD = 1e9 + 7; int mod(int x, int m) { if (x >= 0) return x % m; if (-x < m) return m - (-x); return mod(x % m, m); } int gcd(int a, int b) { while (b) { a = mod(a, b); swap(a, b); } return a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int fexp(int base, int exp, int m) { int total = 1; while (exp > 0) { if (exp % 2 == 1) { total = mod(((mod(total, m)) * (mod(base, m))), m); exp--; } base = mod((mod(base, m) * mod(base, m)), m); exp /= 2; } return mod(total, m); } int n; void solve() { cin >> n; vi a(n + 1); matrix x(20, vi(20)); matrix y(20, vi(20)); for (int i = 1; i <= n; ++i) { cin >> a[i]; for (int j = 1; j <= a[i]; ++j) cin >> x[i][j] >> y[i][j]; } int ans = 0; for (int i = 1; i < (1 << n); ++i) { bool flag = 1; for (int j = 1; j <= n; ++j) { if (!(i & (1 << (j - 1)))) continue; for (int k = 1; k <= a[j]; ++k) if (((i >> (x[j][k] - 1)) & 1) ^ y[j][k]) flag = 0; } if (flag) ans = max(ans, __builtin_popcount(i)); } cout << ans << endl; } int32_t main() { fastio; solve(); return 0; }
replace
65
67
65
67
-11
p02837
C++
Runtime Error
#include <iostream> using namespace std; typedef long long ll; #define rep1(i, n) for (int i = 1; i <= (ll)(n); i++) #define rep0(i, n) for (int i = 0; i <= (ll)(n); i++) int main() { int n; cin >> n; int x[n][n]; int y[n][n]; int a[n + 1]; bool all_not_told = true; rep1(i, n) { cin >> a[i]; if (a[i] > 0) all_not_told = false; rep1(j, a[i]) cin >> x[i][j] >> y[i][j]; } if (all_not_told) { cout << n << endl; return 0; } if (n == 1) cout << 1 << endl; int max_honest_count = 0; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 1; bit < (1 << n); ++bit) { int honest_count = 0; bool contradiction = false; rep1(i, n) { if (bit & (1 << (i - 1))) { // i が bit に入るかどうか honest_count++; rep1(j, a[i]) { if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) { contradiction = true; break; } } } } if (!contradiction) max_honest_count = max(honest_count, max_honest_count); } cout << max_honest_count << endl; return 0; }
#include <iostream> using namespace std; typedef long long ll; #define rep1(i, n) for (int i = 1; i <= (ll)(n); i++) #define rep0(i, n) for (int i = 0; i <= (ll)(n); i++) int main() { int n; cin >> n; int x[20][20]; int y[20][20]; int a[20]; bool all_not_told = true; rep1(i, n) { cin >> a[i]; if (a[i] > 0) all_not_told = false; rep1(j, a[i]) cin >> x[i][j] >> y[i][j]; } if (all_not_told) { cout << n << endl; return 0; } if (n == 1) cout << 1 << endl; int max_honest_count = 0; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 1; bit < (1 << n); ++bit) { int honest_count = 0; bool contradiction = false; rep1(i, n) { if (bit & (1 << (i - 1))) { // i が bit に入るかどうか honest_count++; rep1(j, a[i]) { if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) { contradiction = true; break; } } } } if (!contradiction) max_honest_count = max(honest_count, max_honest_count); } cout << max_honest_count << endl; return 0; }
replace
10
13
10
13
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int N; int A[20]; int x[20][20]; int y[20][20]; int counter(int x) { if (x == 0) return 0; return counter(1 << x) + (x & 1); } void solve() { cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; for (int j = 1; j <= A[i]; j++) { cin >> x[i][j] >> y[i][j]; } } int ans = 0; for (int bits = 1; bits < (1 << N); bits++) { bool ok = true; for (int i = 1; i <= N; i++) { if (!(bits & (1 << (i - 1)))) continue; for (int j = 1; j <= A[i]; j++) { if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false; } } if (ok) ans = max(ans, counter(bits)); } cout << ans << endl; return; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int N; int A[20]; int x[20][20]; int y[20][20]; int counter(int x) { if (x == 0) return 0; return counter(x >> 1) + (x & 1); } void solve() { cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; for (int j = 1; j <= A[i]; j++) { cin >> x[i][j] >> y[i][j]; } } int ans = 0; for (int bits = 1; bits < (1 << N); bits++) { bool ok = true; for (int i = 1; i <= N; i++) { if (!(bits & (1 << (i - 1)))) continue; for (int j = 1; j <= A[i]; j++) { if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false; } } if (ok) ans = max(ans, counter(bits)); } cout << ans << endl; return; } int main() { solve(); return 0; }
replace
11
12
11
12
-11
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 22; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define ROF(i, a, b) for (int i = (a); i >= (b); i--) #define MEM(x, v) memset(x, v, sizeof(x)) template <typename T> inline void read(T &x) { x = 0; char ch = getchar(); bool f = false; while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); if (f) x = -x; } int n, a[maxn], x[maxn][maxn], y[maxn][maxn], sz[maxn], ans; int main() { read(n); FOR(i, 1, n) { read(a[i]); FOR(j, 1, a[i]) read(x[i][j]), read(y[i][j]); } FOR(i, 1, (1 << n) - 1) sz[i] = sz[i >> 1] + (i & 1); FOR(i, 0, (1 << n) - 1) { bool flag = true; FOR(j, 1, n) if ((i >> (j - 1)) & 1) { FOR(k, 1, a[j]) if (((i >> (x[j][k] - 1)) & 1) != y[j][k]) flag = false; } if (flag) ans = max(ans, sz[i]); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 22; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define ROF(i, a, b) for (int i = (a); i >= (b); i--) #define MEM(x, v) memset(x, v, sizeof(x)) template <typename T> inline void read(T &x) { x = 0; char ch = getchar(); bool f = false; while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); if (f) x = -x; } int n, a[maxn], x[maxn][maxn], y[maxn][maxn], sz[66666], ans; int main() { read(n); FOR(i, 1, n) { read(a[i]); FOR(j, 1, a[i]) read(x[i][j]), read(y[i][j]); } FOR(i, 1, (1 << n) - 1) sz[i] = sz[i >> 1] + (i & 1); FOR(i, 0, (1 << n) - 1) { bool flag = true; FOR(j, 1, n) if ((i >> (j - 1)) & 1) { FOR(k, 1, a[j]) if (((i >> (x[j][k] - 1)) & 1) != y[j][k]) flag = false; } if (flag) ans = max(ans, sz[i]); } printf("%d\n", ans); return 0; }
replace
18
19
18
19
0
p02837
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <vector> #define ll long long int #define ld long double #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define co(x) cout << x << endl #define cosp(x) cout << x << " " #define all(x) x.begin(), x.end() #define p pair<ll, ll> #define pb push_back #define mp make_pair #define PI 3.14159265359 using namespace std; int main() { int n; cin >> n; vector<vector<p>> vec(n); int a; int x, y; rep(i, n) { cin >> a; rep(j, a) { cin >> x >> y; x--; vec[i].pb(mp(x, y)); } } vector<bool> h(n); ll ans = 0; ll tmp = 0; ll m = 0; for (ll i = 0; i < (1ll << n); i++) { m = 0; tmp = 0; rep(j, n) h[i] = false; rep(j, n) { if (i & (1ll << j)) { h[j] = true; m++; } else { h[j] = false; } } rep(j, n) { if (i & (1ll << j)) { rep(k, vec[j].size()) { if ((h[vec[j][k].first] == true && vec[j][k].second == 0) || (h[vec[j][k].first] == false && vec[j][k].second == 1)) { m = -1; break; } } } if (m < 0) { break; } } ans = max(ans, m); } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <vector> #define ll long long int #define ld long double #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define co(x) cout << x << endl #define cosp(x) cout << x << " " #define all(x) x.begin(), x.end() #define p pair<ll, ll> #define pb push_back #define mp make_pair #define PI 3.14159265359 using namespace std; int main() { int n; cin >> n; vector<vector<p>> vec(n); int a; int x, y; rep(i, n) { cin >> a; rep(j, a) { cin >> x >> y; x--; vec[i].pb(mp(x, y)); } } vector<bool> h(n); ll ans = 0; ll tmp = 0; ll m = 0; for (ll i = 0; i < (1ll << n); i++) { m = 0; tmp = 0; rep(j, n) h[j] = false; rep(j, n) { if (i & (1ll << j)) { h[j] = true; m++; } else { h[j] = false; } } rep(j, n) { if (i & (1ll << j)) { rep(k, vec[j].size()) { if ((h[vec[j][k].first] == true && vec[j][k].second == 0) || (h[vec[j][k].first] == false && vec[j][k].second == 1)) { m = -1; break; } } } if (m < 0) { break; } } ans = max(ans, m); } cout << ans << endl; return 0; }
replace
44
45
44
45
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int main() { int n; scanf("%d", &n); vector<vector<P>> xy(n, vector<P>(0)); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); for (int j = 0; j < a; j++) { int x, y; scanf("%d %d", &x, &y); xy[i].push_back(make_pair(x - 1, y)); } } int ans = 0; for (int i = 0; i < (1 << n); i++) { vector<bool> hone(n), evil(n); for (int j = 0; j < n; j++) hone[i] = 0, evil[i] = 0; int tmp = 0; for (int j = 0; j < n; j++) { if ((i >> j) & 1) { tmp++; if (evil[j]) tmp = -1e9; else hone[j] = 1; for (P pr : xy[j]) { if (pr.second) { if (!evil[pr.first]) hone[pr.first] = 1; else tmp = -1e9; } else { if (!hone[pr.first]) evil[pr.first] = 1; else tmp = -1e9; } } } else { if (hone[j]) tmp = -1e9; else evil[j] = 1; } } ans = max(ans, tmp); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int main() { int n; scanf("%d", &n); vector<vector<P>> xy(n, vector<P>(0)); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); for (int j = 0; j < a; j++) { int x, y; scanf("%d %d", &x, &y); xy[i].push_back(make_pair(x - 1, y)); } } int ans = 0; for (int i = 0; i < (1 << n); i++) { vector<bool> hone(n), evil(n); for (int j = 0; j < n; j++) hone[j] = 0, evil[j] = 0; int tmp = 0; for (int j = 0; j < n; j++) { if ((i >> j) & 1) { tmp++; if (evil[j]) tmp = -1e9; else hone[j] = 1; for (P pr : xy[j]) { if (pr.second) { if (!evil[pr.first]) hone[pr.first] = 1; else tmp = -1e9; } else { if (!hone[pr.first]) evil[pr.first] = 1; else tmp = -1e9; } } } else { if (hone[j]) tmp = -1e9; else evil[j] = 1; } } ans = max(ans, tmp); } printf("%d\n", ans); return 0; }
replace
23
24
23
24
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // const long long int MOD = 1000000007; const int MOD = 1000000007; int main() { int N; cin >> N; vector<int> A(N); vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0)); for (int i = 0; i < N; i++) { cin >> A[i]; vector<int> empty(A[i]); x[i] = empty; y[i] = empty; for (int j = 0; j < A[i]; j++) { cin >> x[i][j] >> y[i][j]; x[i][j]--; } } int ans = 0; for (int tmp = 0; tmp < (1 << N); tmp++) { bitset<15> b(tmp); int ok_tmp = 1; for (int i = 0; i < N; i++) { if (b.test(i)) { for (int j = 0; j < A[j]; j++) { if (y[i][j] == 1 && !(b.test(x[i][j]))) { ok_tmp *= 0; break; } else if (y[i][j] == 0 && b.test(x[i][j])) { ok_tmp *= 0; break; } } } if (ok_tmp == 0) { break; } } if (ok_tmp) { int alt = b.count(); ans = max(ans, alt); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; // const long long int MOD = 1000000007; const int MOD = 1000000007; int main() { int N; cin >> N; vector<int> A(N); vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0)); for (int i = 0; i < N; i++) { cin >> A[i]; vector<int> empty(A[i]); x[i] = empty; y[i] = empty; for (int j = 0; j < A[i]; j++) { cin >> x[i][j] >> y[i][j]; x[i][j]--; } } int ans = 0; for (int tmp = 0; tmp < (1 << N); tmp++) { bitset<15> b(tmp); int ok_tmp = 1; for (int i = 0; i < N; i++) { if (b.test(i)) { for (int j = 0; j < A[i]; j++) { if (y[i][j] == 1 && !(b.test(x[i][j]))) { ok_tmp *= 0; break; } else if (y[i][j] == 0 && b.test(x[i][j])) { ok_tmp *= 0; break; } } } if (ok_tmp == 0) { break; } } if (ok_tmp) { int alt = b.count(); ans = max(ans, alt); } } cout << ans << endl; }
replace
28
29
28
29
0
p02837
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> // 2^N < 3*10^4なので、すべての状態をチェックしてもいけそう? int main() { size_t N = 0; std::cin >> N; std::vector<uint16_t> one_graph(N); // 1で接続 std::vector<uint16_t> zero_graph(N); // 0でつながる for (size_t i = 0; i < N; ++i) { size_t A; std::cin >> A; for (size_t j = 0; j < A; ++j) { int x, y; std::cin >> x >> y; if (y == 1) { one_graph[i] |= size_t(1) << (x - 1); } else if (y == 0) { zero_graph[i] |= size_t(1) << (x - 1); } } } size_t result = 0; for (uint16_t flags = 1; flags < (2 << N); ++flags) { [&] { size_t count = 0; for (size_t i = 0; i < N; ++i) { // 正直者の発言が状態と矛盾するかを調べる if (flags & (1 << i)) { const uint16_t one = one_graph[i]; const uint16_t zero = zero_graph[i]; if ((flags & one) != one || (~flags & zero) != zero) { return; } count++; } } result = std::max(result, count); }(); } std::cout << result; return 0; }
#include <algorithm> #include <iostream> #include <vector> // 2^N < 3*10^4なので、すべての状態をチェックしてもいけそう? int main() { size_t N = 0; std::cin >> N; std::vector<uint16_t> one_graph(N); // 1で接続 std::vector<uint16_t> zero_graph(N); // 0でつながる for (size_t i = 0; i < N; ++i) { size_t A; std::cin >> A; for (size_t j = 0; j < A; ++j) { int x, y; std::cin >> x >> y; if (y == 1) { one_graph[i] |= size_t(1) << (x - 1); } else if (y == 0) { zero_graph[i] |= size_t(1) << (x - 1); } } } size_t result = 0; for (uint16_t flags = 1; flags < (1 << N); ++flags) { [&] { size_t count = 0; for (size_t i = 0; i < N; ++i) { // 正直者の発言が状態と矛盾するかを調べる if (flags & (1 << i)) { const uint16_t one = one_graph[i]; const uint16_t zero = zero_graph[i]; if ((flags & one) != one || (~flags & zero) != zero) { return; } count++; } } result = std::max(result, count); }(); } std::cout << result; return 0; }
replace
26
27
26
27
TLE
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<vector<int>> x(N), y(N); for (int i = 0; i < N; i++) { cin >> A.at(i); for (int j = 0; j < A.at(j); j++) { int a, b; cin >> a >> b; x.at(i).push_back(a - 1); y.at(i).push_back(b); } } int ans = 0; for (int i = 0; i < (1 << N); i++) { vector<int> honest(N); bool flag = true; for (int j = 0; j < N; j++) { honest.at(j) = (i >> j) % 2; } for (int j = 0; j < N; j++) { if (honest.at(j) == 0) { continue; } for (int k = 0; k < x.at(j).size(); k++) { if (y.at(j).at(k) != honest.at(x.at(j).at(k))) { flag = false; break; } } if (!flag) { break; } } if (flag) { int aa = 0; for (int j = 0; j < N; j++) { aa += honest.at(j); } ans = max(ans, aa); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<vector<int>> x(N), y(N); for (int i = 0; i < N; i++) { cin >> A.at(i); for (int j = 0; j < A.at(i); j++) { int a, b; cin >> a >> b; x.at(i).push_back(a - 1); y.at(i).push_back(b); } } int ans = 0; for (int i = 0; i < (1 << N); i++) { vector<int> honest(N); bool flag = true; for (int j = 0; j < N; j++) { honest.at(j) = (i >> j) % 2; } for (int j = 0; j < N; j++) { if (honest.at(j) == 0) { continue; } for (int k = 0; k < x.at(j).size(); k++) { if (y.at(j).at(k) != honest.at(x.at(j).at(k))) { flag = false; break; } } if (!flag) { break; } } if (flag) { int aa = 0; for (int j = 0; j < N; j++) { aa += honest.at(j); } ans = max(ans, aa); } } cout << ans << endl; }
replace
10
11
10
11
0
p02837
C++
Runtime Error
#include <algorithm> #include <iostream> #include <limits> #include <math.h> #include <queue> #include <vector> using namespace std; typedef pair<int, int> P; int main() { int n; scanf("%d", &n); vector<vector<P>> xy; for (int i = 0; i < n; ++i) { int a; cin >> a; vector<P> tmp; for (int j = 0; j < a; ++j) { int x, y; cin >> x >> y; x--; tmp.push_back(P(x, y)); } xy.push_back(tmp); } int ans = 0; for (int i = 0; i < 1 << n; ++i) { bool is_valid = true; for (int j = 0; j < n; ++j) { if (i >> j & 1) { for (int k = 0; k < n; ++k) { if (j == k) continue; for (int x = 0; x < xy[k].size(); ++x) { if ((i >> xy[j][x].first & 1) != xy[j][x].second) is_valid = false; } } } } if (is_valid) { int cnt = 0; for (int j = 0; j < n; ++j) { if (i >> j & 1) cnt++; } ans = max(cnt, ans); } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <limits> #include <math.h> #include <queue> #include <vector> using namespace std; typedef pair<int, int> P; int main() { int n; scanf("%d", &n); vector<vector<P>> xy; for (int i = 0; i < n; ++i) { int a; cin >> a; vector<P> tmp; for (int j = 0; j < a; ++j) { int x, y; cin >> x >> y; x--; tmp.push_back(P(x, y)); } xy.push_back(tmp); } int ans = 0; for (int i = 0; i < 1 << n; ++i) { bool is_valid = true; for (int j = 0; j < n; ++j) { if (i >> j & 1) { for (int x = 0; x < xy[j].size(); ++x) { if ((i >> xy[j][x].first & 1) != xy[j][x].second) is_valid = false; } } } if (is_valid) { int cnt = 0; for (int j = 0; j < n; ++j) { if (i >> j & 1) cnt++; } ans = max(cnt, ans); } } cout << ans << endl; return 0; }
replace
33
40
33
36
0
p02837
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define debug(s) cout << s << endl #define debug1(s, t) cout << s << " " << t << endl #define printvec(vec) \ for (auto &&item : vec) \ cout << item << " "; \ cout << endl using namespace std; using i64 = long long; // 仮定が矛盾しないか判定 bool ishonest(int person, vector<int> const &honest_list, vector<map<int, int>> const &evidence) { if (honest_list[person] == 0) return true; bool judge = true; for (auto &&mp : evidence[person]) { if (honest_list[mp.first] != mp.second) judge = false; } return judge; } int recurse(int person, vector<int> &honest_list, vector<map<int, int>> const &evidence) { if (person == evidence.size() - 1) { bool judge = true; int counter = 0; for (int i = 1; i <= evidence.size(); i++) { judge &= ishonest(i, honest_list, evidence); if (!judge) return 0; if (honest_list[i] == 1) counter++; } return counter; } honest_list[person + 1] = 1; int honest = recurse(person + 1, honest_list, evidence); honest_list[person + 1] = 0; int unkind = recurse(person + 1, honest_list, evidence); return max(honest, unkind); } int main() { int n; cin >> n; vector<map<int, int>> evidence(n + 1); for (int i = 1; i <= n; i++) { int a; cin >> a; for (int j = 1; j <= a; j++) // a-times { int x, y; cin >> x >> y; evidence[i][x] = y; } } int ans; // 仮定 vector<int> honest_list(n + 1, -1); honest_list[1] = 1; int honest = recurse(1, honest_list, evidence); honest_list[1] = 0; int unkind = recurse(1, honest_list, evidence); ans = max(honest, unkind); cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define debug(s) cout << s << endl #define debug1(s, t) cout << s << " " << t << endl #define printvec(vec) \ for (auto &&item : vec) \ cout << item << " "; \ cout << endl using namespace std; using i64 = long long; // 仮定が矛盾しないか判定 bool ishonest(int person, vector<int> const &honest_list, vector<map<int, int>> const &evidence) { if (honest_list[person] == 0) return true; bool judge = true; for (auto &&mp : evidence[person]) { if (honest_list[mp.first] != mp.second) judge = false; } return judge; } int recurse(int person, vector<int> &honest_list, vector<map<int, int>> const &evidence) { if (person == evidence.size() - 1) { bool judge = true; int counter = 0; for (int i = 1; i <= evidence.size() - 1; i++) { judge &= ishonest(i, honest_list, evidence); if (!judge) return 0; if (honest_list[i] == 1) counter++; } return counter; } honest_list[person + 1] = 1; int honest = recurse(person + 1, honest_list, evidence); honest_list[person + 1] = 0; int unkind = recurse(person + 1, honest_list, evidence); return max(honest, unkind); } int main() { int n; cin >> n; vector<map<int, int>> evidence(n + 1); for (int i = 1; i <= n; i++) { int a; cin >> a; for (int j = 1; j <= a; j++) // a-times { int x, y; cin >> x >> y; evidence[i][x] = y; } } int ans; // 仮定 vector<int> honest_list(n + 1, -1); honest_list[1] = 1; int honest = recurse(1, honest_list, evidence); honest_list[1] = 0; int unkind = recurse(1, honest_list, evidence); ans = max(honest, unkind); cout << ans << endl; return 0; }
replace
37
38
37
38
TLE
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int countOnbit(int x) { if (x == 0) return 0; return countOnbit(x >> 1) + (x & 1); } int main() { int N; cin >> N; vector<int> A(N + 1); vector<vector<int>> x(N + 1); // 指定した番号 vector<vector<int>> y(N + 1); // 正直者であるか否か for (int i = 1; i <= N; i++) { cin >> A.at(i); for (int j = 1; j <= A.at(i); j++) { int a, b; cin >> a >> b; x[i].push_back(a); y[i].push_back(b); } } // 考え方メモ // 正直者か不親切な人かのパターンをビットで全て表す // ある人kが正直者でかつ証言に矛盾がない時、のビットの1を数える // ある人kが正直者である -> 右から(k - 1)番目のビットが1である // 矛盾がない時 -> 指定した番号のビット桁の数字が、パターンと等しい時 int maxCount = 0; for (int bits = 1; bits < (1 << N); bits++) { bool isOk = true; for (int i = 1; i <= N; i++) { // 人 if (bits & (1 << (i - 1))) { // ある人kが正直者である for (int j = 1; j <= A.at(i); j++) { // 証言 if (y.at(i).at(j) == 1) { if (!((bits >> (x.at(i).at(j) - 1)) & 1)) isOk = false; } else { if ((bits >> (x.at(i).at(j) - 1)) & 1) isOk = false; } } } } if (isOk) maxCount = max(maxCount, countOnbit(bits)); } cout << maxCount << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int countOnbit(int x) { if (x == 0) return 0; return countOnbit(x >> 1) + (x & 1); } int main() { int N; cin >> N; vector<int> A(N + 1); vector<vector<int>> x(N + 1); // 指定した番号 vector<vector<int>> y(N + 1); // 正直者であるか否か for (int i = 1; i <= N; i++) { cin >> A.at(i); for (int j = 1; j <= A.at(i); j++) { int a, b; cin >> a >> b; x[i].push_back(a); y[i].push_back(b); } } // 考え方メモ // 正直者か不親切な人かのパターンをビットで全て表す // ある人kが正直者でかつ証言に矛盾がない時、のビットの1を数える // ある人kが正直者である -> 右から(k - 1)番目のビットが1である // 矛盾がない時 -> 指定した番号のビット桁の数字が、パターンと等しい時 int maxCount = 0; for (int bits = 1; bits < (1 << N); bits++) { bool isOk = true; for (int i = 1; i <= N; i++) { // 人 if (bits & (1 << (i - 1))) { // ある人kが正直者である for (int j = 0; j < A.at(i); j++) { // 証言 if (y.at(i).at(j) == 1) { if (!((bits >> (x.at(i).at(j) - 1)) & 1)) isOk = false; } else { if ((bits >> (x.at(i).at(j) - 1)) & 1) isOk = false; } } } } if (isOk) maxCount = max(maxCount, countOnbit(bits)); } cout << maxCount << endl; return 0; }
replace
37
40
37
40
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, A, X, Ans = 0; cin >> N; vector<vector<int>> V(N, vector<int>(N, -1)); rep(i, N) { cin >> A; rep(j, A) { cin >> X; cin >> V.at(i).at(X - 1); } } rep(i, (1 << N)) { bitset<3> bs(i); bool B = 1; rep(j, N) { if (bs.test(j)) { rep(k, N) { if (V.at(j).at(k) != -1 && V.at(j).at(k) != bs[k]) { B = 0; break; } } } } if (B == 1) Ans = max(Ans, (int)bs.count()); } cout << Ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, A, X, Ans = 0; cin >> N; vector<vector<int>> V(N, vector<int>(N, -1)); rep(i, N) { cin >> A; rep(j, A) { cin >> X; cin >> V.at(i).at(X - 1); } } rep(i, (1 << N)) { bitset<15> bs(i); bool B = 1; rep(j, N) { if (bs.test(j)) { rep(k, N) { if (V.at(j).at(k) != -1 && V.at(j).at(k) != bs[k]) { B = 0; break; } } } } if (B == 1) Ans = max(Ans, (int)bs.count()); } cout << Ans << endl; }
replace
16
17
16
17
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i, n) \ ; \ for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define f(i, a, b) for (int i = a; i < b; i++) #define pri(a) printf("%.14lf\n", a); #define MOD 1000000007 bool is_int_lround(double x) { return std::lround(x) == x; } ll keta(ll x) { int n = 0; while (x > 0) { x /= 10; n++; } return n; } ll conbi(int n, int m) { cin >> n >> m; vector<ll> a(100); a[0] = 1; for (int i = 0; i < 14; i++) { a[i + 1] = a[i] * (i + 1); } return a[n] / (a[m] * a[n - m]); } int main() { int n; cin >> n; vvi x(n); vvi y(n); rep(i, n) { int a; cin >> a; rep(j, a) { int X, Y; cin >> X >> Y; x[i].push_back(X); y[i].push_back(Y); } } int ans = 0; for (int tmp = 0; tmp < (1 << n); tmp++) { bitset<15> s(tmp); bool ok = true; rep(i, n) { rep(j, x[i].size()) { if (s.test(i)) { if (s.test(x[i][j]) != y[i][j]) { ok = false; } } } } if (ok) { int kari = s.count(); ans = max(ans, kari); } } cout << ans << endl; }
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i, n) \ ; \ for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define f(i, a, b) for (int i = a; i < b; i++) #define pri(a) printf("%.14lf\n", a); #define MOD 1000000007 bool is_int_lround(double x) { return std::lround(x) == x; } ll keta(ll x) { int n = 0; while (x > 0) { x /= 10; n++; } return n; } ll conbi(int n, int m) { cin >> n >> m; vector<ll> a(100); a[0] = 1; for (int i = 0; i < 14; i++) { a[i + 1] = a[i] * (i + 1); } return a[n] / (a[m] * a[n - m]); } int main() { int n; cin >> n; vvi x(n); vvi y(n); rep(i, n) { int a; cin >> a; rep(j, a) { int X, Y; cin >> X >> Y; X--; x[i].push_back(X); y[i].push_back(Y); } } int ans = 0; for (int tmp = 0; tmp < (1 << n); tmp++) { bitset<15> s(tmp); bool ok = true; rep(i, n) { rep(j, x[i].size()) { if (s.test(i)) { if (s.test(x[i][j]) != y[i][j]) { ok = false; } } } } if (ok) { int kari = s.count(); ans = max(ans, kari); } } cout << ans << endl; }
insert
59
59
59
60
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; // 最大値、mod const int MOD = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; // 出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(10) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) // 最大公約数 unsigned gcd(unsigned a, unsigned b) { if (a < b) return gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // 累乗(MODをとる) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0}; struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { // 最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { // xとyの木を併合 int rx = root(x); // xの根をrx int ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す int rx = root(x); int ry = root(y); return rx == ry; } }; int main() { int N; cin >> N; vector<int> a(N); int x[N - 1][N - 1]; int y[N - 1][N - 1]; REP(i, N) { cin >> a.at(i); REP(j, a.at(i)) { cin >> x[i][j] >> y[i][j]; x[i][j]--; } } int ans = 0; REP(bits, (1 << N)) { bool flag = true; REP(i, N) { if (!(bits & (1 << i))) continue; REP(j, a[i]) if (((bits >> x[i][j]) & 1) ^ y[i][j]) flag = false; } if (flag) chmax(ans, __builtin_popcount(bits)); } print(ans); return 0; }
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; // 最大値、mod const int MOD = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; // 出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(10) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) // 最大公約数 unsigned gcd(unsigned a, unsigned b) { if (a < b) return gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // 累乗(MODをとる) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0}; struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { // 最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { // xとyの木を併合 int rx = root(x); // xの根をrx int ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す int rx = root(x); int ry = root(y); return rx == ry; } }; int main() { int N; cin >> N; vector<int> a(20); int x[20][20]; int y[20][20]; REP(i, N) { cin >> a.at(i); REP(j, a.at(i)) { cin >> x[i][j] >> y[i][j]; x[i][j]--; } } int ans = 0; REP(bits, (1 << N)) { bool flag = true; REP(i, N) { if (!(bits & (1 << i))) continue; REP(j, a[i]) if (((bits >> x[i][j]) & 1) ^ y[i][j]) flag = false; } if (flag) chmax(ans, __builtin_popcount(bits)); } print(ans); return 0; }
replace
136
139
136
139
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define int int64_t #define double long double #define rep(i, N) for (int i = 0; i < N; i++) #define repr(i, N) for (int i = N - 1; i >= 0; --i) #define all(v) v.begin(), v.end() using namespace std; // using pr = pair<int, int>; using tup = tuple<int, int, int>; using vec = vector<int>; using vvec = vector<vec>; // プロトタイプ宣言 // グローバル変数 const int INF = 105; const int MAX_N = 15; vec a(MAX_N); vvec x(MAX_N, vec(MAX_N, INF)); vvec y(MAX_N, vec(MAX_N, INF)); // const int MAX_M = ; // vvec dp(MAX_N, vec(MAX_M)); // 関数: /* 使用せず。 */ bool logical(vec a, vec b) { bool frag = true; rep(i, MAX_N) { if (a[i] != INF && b[i] != INF) { if (a[i] != b[i]) frag = false; break; } } return frag; } /* 二進表記の1の数をカウント */ int count(int bits) { if (bits == 0) return 0; return count(bits >> 1) + (bits & 1); } /* メイン・プログラム */ signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; for (int j = 1; j <= a[i]; j++) { int xx, yy; cin >> xx >> yy; x[i][j] = xx; y[i][j] = yy; } } // bit全探索:0以上2^n未満の整数jが「1以上N以下の整数kについて、人kが正直者であることと、jを2進数表記した際にk // − 1桁目が1であることが同値」という状態を表すことと定義。 int ans = 0; int prm = 1 << n; // prm = n_P_2 for (int bt = 1; bt < prm; bt++) { bool frag = true; for (int i = 1; i <= n; i++) { if (!(bt & (1 << (i - 1)))) continue; // btのi-1桁目が0ならそのまま。 for (int j = 1; j <= a[i]; j++) { int bbt = (bt >> (x[i][j] - 1)) & 1; if (bbt ^ y[i][j]) frag = false; //^: XOR } } if (frag) ans = max(ans, count(bt)); } cout << ans << endl; return 0; } // std::string str; // str = std::to_string(int i); // bitset<3> s(N); // int ans = (char)grid - '0'; // int id = lower_bound(all(arr), x) - arr.begin(); // cout << fixed << setprecision(10) << tld << endl; // vector<int> sub(itr,itr+d); //イテレーターで部分数列(i=0...d)を指定 /*struct data { char *name; int age; int height; double weight; };*/ /*string ans = w; string &ref = ans; rep(i, N) { ref[i] = arr[i]; }*/ /*map<int,int> mp; for(auto p : mp) { ct += p.second*(p.second-1); } map<int,int>::iterator itr; for(itr = mp.begin(); itr != mp.end(); itr++) { ans += itr->second * (itr->second-1); }*/
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define int int64_t #define double long double #define rep(i, N) for (int i = 0; i < N; i++) #define repr(i, N) for (int i = N - 1; i >= 0; --i) #define all(v) v.begin(), v.end() using namespace std; // using pr = pair<int, int>; using tup = tuple<int, int, int>; using vec = vector<int>; using vvec = vector<vec>; // プロトタイプ宣言 // グローバル変数 const int INF = 105; const int MAX_N = 20; vec a(MAX_N); vvec x(MAX_N, vec(MAX_N, INF)); vvec y(MAX_N, vec(MAX_N, INF)); // const int MAX_M = ; // vvec dp(MAX_N, vec(MAX_M)); // 関数: /* 使用せず。 */ bool logical(vec a, vec b) { bool frag = true; rep(i, MAX_N) { if (a[i] != INF && b[i] != INF) { if (a[i] != b[i]) frag = false; break; } } return frag; } /* 二進表記の1の数をカウント */ int count(int bits) { if (bits == 0) return 0; return count(bits >> 1) + (bits & 1); } /* メイン・プログラム */ signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; for (int j = 1; j <= a[i]; j++) { int xx, yy; cin >> xx >> yy; x[i][j] = xx; y[i][j] = yy; } } // bit全探索:0以上2^n未満の整数jが「1以上N以下の整数kについて、人kが正直者であることと、jを2進数表記した際にk // − 1桁目が1であることが同値」という状態を表すことと定義。 int ans = 0; int prm = 1 << n; // prm = n_P_2 for (int bt = 1; bt < prm; bt++) { bool frag = true; for (int i = 1; i <= n; i++) { if (!(bt & (1 << (i - 1)))) continue; // btのi-1桁目が0ならそのまま。 for (int j = 1; j <= a[i]; j++) { int bbt = (bt >> (x[i][j] - 1)) & 1; if (bbt ^ y[i][j]) frag = false; //^: XOR } } if (frag) ans = max(ans, count(bt)); } cout << ans << endl; return 0; } // std::string str; // str = std::to_string(int i); // bitset<3> s(N); // int ans = (char)grid - '0'; // int id = lower_bound(all(arr), x) - arr.begin(); // cout << fixed << setprecision(10) << tld << endl; // vector<int> sub(itr,itr+d); //イテレーターで部分数列(i=0...d)を指定 /*struct data { char *name; int age; int height; double weight; };*/ /*string ans = w; string &ref = ans; rep(i, N) { ref[i] = arr[i]; }*/ /*map<int,int> mp; for(auto p : mp) { ct += p.second*(p.second-1); } map<int,int>::iterator itr; for(itr = mp.begin(); itr != mp.end(); itr++) { ans += itr->second * (itr->second-1); }*/
replace
17
18
17
18
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using pp = pair<int, int>; int main() { int N, doubt = 0, M = 0; cin >> N; vector<vector<pp>> V(N, vector<pp>(0)); int A, p, q; for (int i = 0; i < N; i++) { cin >> A; for (int j = 0; j < A; j++) { cin >> p >> q; V[i].push_back(pp(p, q)); } } for (int b = 0; b < (1 << N); b++) { bitset<12> s(b); vector<int> W(N); doubt = 0; for (int i = 0; i < N; i++) { W[i] = s.test(i); // cout << W[i] << endl; } for (int i = 0; i < N; i++) { if (s.test(i)) { for (int j = 0; j < (int)V[i].size(); j++) { int x = V[i][j].first, y = V[i][j].second; if (W[x - 1] != y) { doubt = 1; break; } } if (doubt == 1) { break; } } } if (doubt == 0) { int rr = 0; for (int i = 0; i < N; i++) { rr += s.test(i); } M = max(M, rr); // cout << M << endl; } } cout << M << endl; }
#include <bits/stdc++.h> using namespace std; using pp = pair<int, int>; int main() { int N, doubt = 0, M = 0; cin >> N; vector<vector<pp>> V(N, vector<pp>(0)); int A, p, q; for (int i = 0; i < N; i++) { cin >> A; for (int j = 0; j < A; j++) { cin >> p >> q; V[i].push_back(pp(p, q)); } } for (int b = 0; b < (1 << N); b++) { bitset<15> s(b); vector<int> W(N); doubt = 0; for (int i = 0; i < N; i++) { W[i] = s.test(i); // cout << W[i] << endl; } for (int i = 0; i < N; i++) { if (s.test(i)) { for (int j = 0; j < (int)V[i].size(); j++) { int x = V[i][j].first, y = V[i][j].second; if (W[x - 1] != y) { doubt = 1; break; } } if (doubt == 1) { break; } } } if (doubt == 0) { int rr = 0; for (int i = 0; i < N; i++) { rr += s.test(i); } M = max(M, rr); // cout << M << endl; } } cout << M << endl; }
replace
20
21
20
21
0
p02837
Python
Runtime Error
n = int(input()) testimony_dict = {} for i in range(n): a = int(input()) testimony_dict[i + 1] = [] for j in range(a): xy = input().split(" ") testimony_dict[i + 1].append(xy) max_valid_bin = "" for i in range(2**n - 1, 0, -1): is_valid = True bin_i = format(i, f"0{n}b") for j in range(1, len(bin_i) + 1): if bin_i[j - 1] == "1": for xy_list in testimony_dict[j]: if bin_i[int(xy_list[0]) - 1] != xy_list[1]: is_valid = False if is_valid: max_valid_bin = bin_i break print(len([i for i in max_valid_bin if i == "1"]))
n = int(input()) testimony_dict = {} for i in range(n): a = int(input()) testimony_dict[i + 1] = [] for j in range(a): xy = input().split(" ") testimony_dict[i + 1].append(xy) max_valid_bin = "" for i in range(2**n - 1, 0, -1): is_valid = True bin_i = format(i, "0{}b".format(n)) for j in range(1, len(bin_i) + 1): if bin_i[j - 1] == "1": for xy_list in testimony_dict[j]: if bin_i[int(xy_list[0]) - 1] != xy_list[1]: is_valid = False if is_valid: max_valid_bin = bin_i break print(len([i for i in max_valid_bin if i == "1"]))
replace
13
14
13
14
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<vector<int>>> ta(n, vector<vector<int>>(n, vector<int>(1, 66))); for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < a; j++) { int x, y; cin >> x >> y; x--; ta[i][x][0] = y; } } vector<int> seen(n); int ans = 0; for (int i = 0; i < (1 << n); i++) { bitset<3> s(i); int d = 0; int cu = 0; for (int j = 0; j < n; j++) { if (s.test(j)) seen[j] = 1; else seen[j] = 0; } for (int h = 0; h < n; h++) { if (seen[h]) { for (int g = 0; g < n; g++) { if (ta[h][g][0] == 1) { if (seen[g] != 1) { cu = 1; break; } } else if (ta[h][g][0] == 0) { if (seen[g] != 0) { cu = 1; break; } } } } if (cu) break; } if (cu) continue; for (int u = 0; u < n; u++) { if (seen[u]) d++; } ans = max(ans, d); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<vector<int>>> ta(n, vector<vector<int>>(n, vector<int>(1, 66))); for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < a; j++) { int x, y; cin >> x >> y; x--; ta[i][x][0] = y; } } vector<int> seen(n); int ans = 0; for (int i = 0; i < (1 << n); i++) { bitset<15> s(i); int d = 0; int cu = 0; for (int j = 0; j < n; j++) { if (s.test(j)) seen[j] = 1; else seen[j] = 0; } for (int h = 0; h < n; h++) { if (seen[h]) { for (int g = 0; g < n; g++) { if (ta[h][g][0] == 1) { if (seen[g] != 1) { cu = 1; break; } } else if (ta[h][g][0] == 0) { if (seen[g] != 0) { cu = 1; break; } } } } if (cu) break; } if (cu) continue; for (int u = 0; u < n; u++) { if (seen[u]) d++; } ans = max(ans, d); } cout << ans << endl; }
replace
21
22
21
22
0
p02837
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<vector<int>> x(n + 1); vector<vector<int>> y(n + 1); vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; x[i].resize(a[i]); y[i].resize(a[i]); for (int j = 1; j <= a[i]; j++) { cin >> x[i][j] >> y[i][j]; } } int ans = 0; for (int mask = 1; mask < (1 << n); mask++) { bool ok = true; int cnt = 0; for (int i = 1; i <= n; i++) { if (!(mask & (1 << (i - 1)))) // if (!(mask >> (i - 1) & 1)) { continue; } cnt++; for (int j = 1; j <= a[i]; j++) { // x[i][j]-1番目の人が正直ならビットは1なはず if (((mask >> (x[i][j] - 1)) & 1) ^ y[i][j]) { ok = false; } } } if (ok) { ans = max(ans, cnt); } } cout << ans << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<vector<int>> x(n + 1); vector<vector<int>> y(n + 1); vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; x[i].resize(a[i] + 1); y[i].resize(a[i] + 1); for (int j = 1; j <= a[i]; j++) { cin >> x[i][j] >> y[i][j]; } } int ans = 0; for (int mask = 1; mask < (1 << n); mask++) { bool ok = true; int cnt = 0; for (int i = 1; i <= n; i++) { if (!(mask & (1 << (i - 1)))) // if (!(mask >> (i - 1) & 1)) { continue; } cnt++; for (int j = 1; j <= a[i]; j++) { // x[i][j]-1番目の人が正直ならビットは1なはず if (((mask >> (x[i][j] - 1)) & 1) ^ y[i][j]) { ok = false; } } } if (ok) { ans = max(ans, cnt); } } cout << ans << endl; return 0; }
replace
16
18
16
18
0
p02837
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<vector<pair<int, int>>> a(n); for (int i = 0; i < n; ++i) { int k; scanf("%d", &k); a[i].resize(k); for (int j = 0; j < k; ++j) { scanf("%d %d", &a[i][j].first, &a[i][j].second); --a[i][j].first; } } int ans = 0; for (int mask = 0; mask < (1 << n); ++mask) { bool ok = true; for (int i = 0; i < n; ++i) { if ((mask >> i) & 1) { for (int j = 0; j < int(a[i].size()); ++i) { ok &= (((mask >> a[i][j].first) & 1) == a[i][j].second); } } } if (ok) ans = max(ans, __builtin_popcount(mask)); } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<vector<pair<int, int>>> a(n); for (int i = 0; i < n; ++i) { int k; scanf("%d", &k); a[i].resize(k); for (int j = 0; j < k; ++j) { scanf("%d %d", &a[i][j].first, &a[i][j].second); --a[i][j].first; } } int ans = 0; for (int mask = 0; mask < (1 << n); ++mask) { bool ok = true; for (int i = 0; i < n; ++i) { if ((mask >> i) & 1) { for (int j = 0; j < int(a[i].size()); ++j) { ok &= (((mask >> a[i][j].first) & 1) == a[i][j].second); } } } if (ok) ans = max(ans, __builtin_popcount(mask)); } printf("%d\n", ans); }
replace
21
22
21
22
-11
p02837
C++
Runtime Error
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() #ifdef DEBUG #define line() cerr << "[" << __LINE__ << "] "; #define dump(i) cerr << #i ": " << i << " "; #define dumpl(i) cerr << #i ": " << i << endl; #else #define line(i) #define dump(i) #define dumpl(i) #endif using namespace std; int n; int ok(vector<vector<int>> &v, int m) { int d[n]; int ret = 0; rep(i, m) { d[i] = (m >> i) & 1; if (d[i] == 1) ret++; } rep(i, n) { rep(j, n) { if (v[i][j] == -1) continue; if (d[i] == 1 && d[j] != v[i][j]) { return 0; } } } return ret; } int main(int argc, char const *argv[]) { cin >> n; vector<vector<int>> v(n, vector<int>(n, -1)); rep(i, n) { int m; cin >> m; rep(j, m) { int x, y; cin >> x >> y; x--; v[i][x] = y; } } cerr << "ok" << pow(2, n) << endl; int ans = 0; rep(i, pow(2, n)) { cerr << "*" << i << endl; ans = max(ans, ok(v, i)); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ll long long #define lld long double #define ALL(x) x.begin(), x.end() #ifdef DEBUG #define line() cerr << "[" << __LINE__ << "] "; #define dump(i) cerr << #i ": " << i << " "; #define dumpl(i) cerr << #i ": " << i << endl; #else #define line(i) #define dump(i) #define dumpl(i) #endif using namespace std; int n; int ok(vector<vector<int>> &v, int m) { int d[n]; int ret = 0; rep(i, n) { d[i] = (m >> i) & 1; if (d[i] == 1) ret++; } rep(i, n) { rep(j, n) { if (v[i][j] == -1) continue; if (d[i] == 1 && d[j] != v[i][j]) { return 0; } } } return ret; } int main(int argc, char const *argv[]) { cin >> n; vector<vector<int>> v(n, vector<int>(n, -1)); rep(i, n) { int m; cin >> m; rep(j, m) { int x, y; cin >> x >> y; x--; v[i][x] = y; } } cerr << "ok" << pow(2, n) << endl; int ans = 0; rep(i, pow(2, n)) { cerr << "*" << i << endl; ans = max(ans, ok(v, i)); } cout << ans << endl; return 0; }
replace
25
26
25
26
0
ok8 *0 *1 *2 *3 *4 *5 *6 *7
p02838
C++
Time Limit Exceeded
#include <cstdio> long a[300010], s[64][300010][2]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%ld", a + i); for (int j = 0; j < 61; ++j) { int k = (a[i] >> j) & 1; if (k == 0) { s[j][i + 1][0] = s[j][i][0] + 1; s[j][i + 1][1] = s[j][i][1]; } else { s[j][i + 1][0] = s[j][i][0]; s[j][i + 1][1] = s[j][i][1] + 1; } } } const long mod = 1e9 + 7; long res = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < 61; ++j) { int x = (a[i] >> j) & 1; long t = s[j][n][!x] - s[j][i][!x]; t *= (1L << j) % mod; while (t >= mod) t -= mod; res += t; if (res >= mod) res -= mod; } } printf("%ld\n", res); }
#include <cstdio> long a[300010], s[64][300010][2]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%ld", a + i); for (int j = 0; j < 61; ++j) { int k = (a[i] >> j) & 1; if (k == 0) { s[j][i + 1][0] = s[j][i][0] + 1; s[j][i + 1][1] = s[j][i][1]; } else { s[j][i + 1][0] = s[j][i][0]; s[j][i + 1][1] = s[j][i][1] + 1; } } } const long mod = 1e9 + 7; long res = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < 61; ++j) { int x = (a[i] >> j) & 1; long t = s[j][n][!x] - s[j][i][!x]; (t *= (1L << j) % mod) %= mod; res += t; if (res >= mod) res -= mod; } } printf("%ld\n", res); }
replace
26
29
26
27
TLE
p02838
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pb push_back #define f first #define s second #define MOD 1000000007 using namespace std; uint64_t A[100001]; ll modexp(int i, ll p) { if (p == 0) return 1; ll ans = modexp(i, p / 2); ans = (ans * ans) % MOD; if (p % 2) ans = (i * ans) % MOD; return ans; } void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i]; } ll ans = 0; for (int bit = 0; bit < 60; bit++) { ll x = 0; for (int i = 0; i < n; i++) { if ((A[i] & (1ULL << bit))) { x++; } } // cout<<bit<<" : "<<x<<" sex\n"; x = (x * (n - x)) % MOD; ans += (modexp(2, bit) * x) % MOD; ans = ans % MOD; } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); int t = 1; // cin>>t; for (int i = 1; i <= t; i++) { solve(); cout << "\n"; } return 0; }
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pb push_back #define f first #define s second #define MOD 1000000007 using namespace std; uint64_t A[300001]; ll modexp(int i, ll p) { if (p == 0) return 1; ll ans = modexp(i, p / 2); ans = (ans * ans) % MOD; if (p % 2) ans = (i * ans) % MOD; return ans; } void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i]; } ll ans = 0; for (int bit = 0; bit < 60; bit++) { ll x = 0; for (int i = 0; i < n; i++) { if ((A[i] & (1ULL << bit))) { x++; } } // cout<<bit<<" : "<<x<<" sex\n"; x = (x * (n - x)) % MOD; ans += (modexp(2, bit) * x) % MOD; ans = ans % MOD; } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); int t = 1; // cin>>t; for (int i = 1; i <= t; i++) { solve(); cout << "\n"; } return 0; }
replace
10
11
10
11
0
p02838
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()) typedef long long ll; typedef pair<int, int> P; int main() { const int INF = pow(10, 9) + 7; int n; cin >> n; vector<ll> A(n); rep(i, n) { cin >> A[i]; } ll ans = 0; rep(i, n - 1) { for (int j = i + 1; j < n; j++) { ans += A[i] ^ A[j]; ans %= INF; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()) typedef long long ll; typedef pair<int, int> P; int main() { const int INF = pow(10, 9) + 7; int n; cin >> n; vector<ll> A(n); rep(i, n) { cin >> A[i]; } ll ans = 0; rep(i, 60) { ll x = 0; rep(j, n) if (A[j] >> i & 1) x++; ll now = x * (n - x); rep(j, i) now = now * 2 % INF; ans += now; ans %= INF; } cout << ans << endl; }
replace
16
21
16
23
TLE
p02838
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) #define rep_r(i, s, n) for (ll i = n - 1; i > s; i--) #define rep_re(i, s, n) for (ll i = n - 1; i >= s; i--) ll MOD = 1e9 + 7; ll a[100000] = {}; ll Pow(ll n, ll p) { if (p == 0) return 1; if (p == 1) return n; ll t = Pow(n, p / 2); if (p & 1) return (t * t % MOD) * n % MOD; else return t * t % MOD; } int main() { ll n; cin >> n; rep(i, 0, n) cin >> a[i]; ll ans = 0; rep(i, 0, 60) { ll mask = 1ll << i; ll z = 0, o = 0; rep(i, 0, n) { ll v = mask & a[i]; if (v == 0) { z++; } else { o++; } } ll p = z * o % MOD; ans = (ans + (Pow(2, i) * p) % MOD) % MOD; } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) #define rep_r(i, s, n) for (ll i = n - 1; i > s; i--) #define rep_re(i, s, n) for (ll i = n - 1; i >= s; i--) ll MOD = 1e9 + 7; ll a[300001] = {}; ll Pow(ll n, ll p) { if (p == 0) return 1; if (p == 1) return n; ll t = Pow(n, p / 2); if (p & 1) return (t * t % MOD) * n % MOD; else return t * t % MOD; } int main() { ll n; cin >> n; rep(i, 0, n) cin >> a[i]; ll ans = 0; rep(i, 0, 60) { ll mask = 1ll << i; ll z = 0, o = 0; rep(i, 0, n) { ll v = mask & a[i]; if (v == 0) { z++; } else { o++; } } ll p = z * o % MOD; ans = (ans + (Pow(2, i) * p) % MOD) % MOD; } cout << ans << endl; return 0; }
replace
19
20
19
20
0
p02838
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; const ll MOD = 1000000007; ll N, cnt[100000][63], A[100000], sum[63]; int main(void) { cin >> N; rep(i, N) { cin >> A[i]; ll x = A[i]; ll m = 0; while (x > 0) { if (x & 1 == 1) cnt[i][m]++; x = x >> 1; m++; } rep(j, 63) sum[j] += cnt[i][j]; // rep(j,3)cout << sum[j]; // cout << endl; } ll ans = 0; rep(i, N) { ll p = 1; rep(j, 63) { sum[j] -= cnt[i][j]; if (cnt[i][j] == 0) ans = (ans + (sum[j] * p) % MOD) % MOD; else ans = (ans + ((N - 1 - i - sum[j]) * p) % MOD) % MOD; p = (2 * p) % MOD; } } ans = ans % MOD; cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; const ll MOD = 1000000007; ll N, cnt[300000][63], A[300000], sum[63]; int main(void) { cin >> N; rep(i, N) { cin >> A[i]; ll x = A[i]; ll m = 0; while (x > 0) { if (x & 1 == 1) cnt[i][m]++; x = x >> 1; m++; } rep(j, 63) sum[j] += cnt[i][j]; // rep(j,3)cout << sum[j]; // cout << endl; } ll ans = 0; rep(i, N) { ll p = 1; rep(j, 63) { sum[j] -= cnt[i][j]; if (cnt[i][j] == 0) ans = (ans + (sum[j] * p) % MOD) % MOD; else ans = (ans + ((N - 1 - i - sum[j]) * p) % MOD) % MOD; p = (2 * p) % MOD; } } ans = ans % MOD; cout << ans << endl; }
replace
6
7
6
7
0
p02838
C++
Time Limit Exceeded
#define rep(i, n) for (ll i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; ll p = 1e9 + 7; cin >> n; vector<ll> cnt(61, 0); rep(i, n) { ll a; cin >> a; ll j = 0; while (a >= 1) { if (a % 2 == 1) cnt[j]++; a /= 2; j++; } } ll ans = 0; rep(i, 61) { ll base = cnt[i] * (n - cnt[i]); // printf("%lld, %lld\n", i, cnt[i]); rep(j, base) { ans += ((1LL << i) % p); ans = ans % p; } } cout << ans << endl; return 0; }
#define rep(i, n) for (ll i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; ll p = 1e9 + 7; cin >> n; vector<ll> cnt(61, 0); rep(i, n) { ll a; cin >> a; ll j = 0; while (a >= 1) { if (a % 2 == 1) cnt[j]++; a /= 2; j++; } } ll ans = 0; rep(i, 61) { ll base = cnt[i] * (n - cnt[i]); // printf("%lld, %lld\n", i, cnt[i]); ll tmp = base; rep(j, i) tmp = ((tmp << 1) % p); ans = (ans + tmp) % p; } cout << ans << endl; return 0; }
replace
26
30
26
29
TLE
p02838
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { int N; cin >> N; ll A[N]; rep(i, N) cin >> A[i]; mint ans = 0; rep(i, N - 1) for (int j = i + 1; j < N; j++) { ans += A[i] ^ A[j]; } cout << ans.x << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { int N; cin >> N; ll A[N]; rep(i, N) cin >> A[i]; mint ans = 0; rep(k, 60) { mint n1 = 0; rep(i, N) { if ((A[i] >> k) & 1) n1 += 1; } ans += n1 * (mint(N) - n1) * mint(2).pow(k); } cout << ans.x << endl; return 0; }
replace
72
73
72
80
TLE