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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
#define _GLIBCXX_DEBUG
int main() {
ll n;
cin >> n;
vector<ll> num(10010, 0);
ll ans = 0;
rep(i, n) {
ll a;
cin >> a;
num[a]++;
ans += a;
}
ll q;
cin >> q;
rep(i, q) {
ll b, c;
cin >> b >> c;
ll v = num[b];
num[b] = 0;
num[c] += v;
ans -= v * b;
ans += v * c;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
#define _GLIBCXX_DEBUG
int main() {
ll n;
cin >> n;
vector<ll> num(100010, 0);
ll ans = 0;
rep(i, n) {
ll a;
cin >> a;
num[a]++;
ans += a;
}
ll q;
cin >> q;
rep(i, q) {
ll b, c;
cin >> b >> c;
ll v = num[b];
num[b] = 0;
num[c] += v;
ans -= v * b;
ans += v * c;
cout << ans << endl;
}
} | replace | 18 | 19 | 18 | 19 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, sum, num[20], q, b;
int main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a, sum += a, num[a]++;
cin >> q;
for (int i = 0; i < q; i++) {
cin >> a >> b;
sum += (b - a) * num[a];
num[b] += num[a];
num[a] = 0;
cout << sum << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll n, a, sum, num[N], q, b;
int main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a, sum += a, num[a]++;
cin >> q;
for (int i = 0; i < q; i++) {
cin >> a >> b;
sum += (b - a) * num[a];
num[b] += num[a];
num[a] = 0;
cout << sum << endl;
}
return 0;
}
| replace | 3 | 5 | 3 | 5 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
int main(void) {
int n;
cin >> n;
vector<int> v(10000 + 1);
ll sum = 0;
REP(i, n) {
int a;
cin >> a;
v[a]++;
sum += a;
}
int q;
cin >> q;
REP(i, q) {
int b, c;
cin >> b >> c;
sum += ((c - b) * v[b]);
v[c] += v[b];
v[b] = 0;
cout << sum << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
int main(void) {
int n;
cin >> n;
vector<int> v(100000 + 1);
ll sum = 0;
REP(i, n) {
int a;
cin >> a;
v[a]++;
sum += a;
}
int q;
cin >> q;
REP(i, q) {
int b, c;
cin >> b >> c;
sum += ((c - b) * v[b]);
v[c] += v[b];
v[b] = 0;
cout << sum << endl;
}
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int64_t> a(10001, 0);
int64_t sum = 0;
for (int i = 0; i < n;
i++) { // 1~10000の各数を数列がそれぞれいくつ含むかを調べるための配列
int x;
cin >> x;
a.at(x)++;
sum += x; // 数列の和
}
int q;
cin >> q;
vector<int64_t> answer(q, 0);
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
sum += (c - b) * a.at(b); // 数列の和を更新
answer.at(i) = sum;
a.at(c) += a.at(b);
a.at(b) = 0;
}
for (int64_t ans : answer) {
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int64_t> a(100001, 0);
int64_t sum = 0;
for (int i = 0; i < n;
i++) { // 1~10000の各数を数列がそれぞれいくつ含むかを調べるための配列
int x;
cin >> x;
a.at(x)++;
sum += x; // 数列の和
}
int q;
cin >> q;
vector<int64_t> answer(q, 0);
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
sum += (c - b) * a.at(b); // 数列の和を更新
answer.at(i) = sum;
a.at(c) += a.at(b);
a.at(b) = 0;
}
for (int64_t ans : answer) {
cout << ans << endl;
}
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02630 | C++ | Runtime Error | // SMOKE SHISHA PLAY FIFA //
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
ll modu(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b & 1)
ans = (ans * a) % mod;
b /= 2;
a = (a * a) % mod;
}
return ans;
}
int main() {
fastio ll n, sum = 0;
cin >> n;
ll dp[50000] = {0};
ll a[n];
lp(i, 0, n - 1) {
cin >> a[i];
sum += a[i];
dp[a[i]]++;
}
ll q;
cin >> q;
lp(i, 0, q - 1) {
ll x, y;
cin >> x >> y;
if (dp[x]) {
sum += dp[x] * (y - x);
dp[y] += dp[x];
dp[x] = 0;
}
cout << sum << endl;
}
return 0;
}
| // SMOKE SHISHA PLAY FIFA //
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
ll modu(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b & 1)
ans = (ans * a) % mod;
b /= 2;
a = (a * a) % mod;
}
return ans;
}
int main() {
fastio ll n, sum = 0;
cin >> n;
ll dp[100005] = {0};
ll a[n];
lp(i, 0, n - 1) {
cin >> a[i];
sum += a[i];
dp[a[i]]++;
}
ll q;
cin >> q;
lp(i, 0, q - 1) {
ll x, y;
cin >> x >> y;
if (dp[x]) {
sum += dp[x] * (y - x);
dp[y] += dp[x];
dp[x] = 0;
}
cout << sum << endl;
}
return 0;
}
| replace | 38 | 39 | 38 | 39 | 0 | |
p02630 | C++ | Runtime Error | #include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll N;
cin >> N;
vector<ll> vc(100000, 0);
ll total = 0;
for (ll i = 0; i < N; i++) {
ll A;
cin >> A;
vc.at(A) += 1;
total += A;
}
int Q;
cin >> Q;
for (int i = 1; i <= Q; i++) {
ll B, C;
cin >> B >> C;
ll tmp_b = vc.at(B);
total -= tmp_b * B;
vc.at(B) = 0;
total += C * tmp_b;
vc.at(C) += tmp_b;
cout << total << endl;
}
return 0;
} | #include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll N;
cin >> N;
vector<ll> vc(100001, 0);
ll total = 0;
for (ll i = 0; i < N; i++) {
ll A;
cin >> A;
vc.at(A) += 1;
total += A;
}
int Q;
cin >> Q;
for (int i = 1; i <= Q; i++) {
ll B, C;
cin >> B >> C;
ll tmp_b = vc.at(B);
total -= tmp_b * B;
vc.at(B) = 0;
total += C * tmp_b;
vc.at(C) += tmp_b;
cout << total << endl;
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | Python | Runtime Error | import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
alist = list(map(int, input().split()))
Q = int(input())
sumA = sum(alist)
adict = Counter(alist)
for _ in range(Q):
b, c = map(int, input().split())
bnum = adict.pop(b)
if c in adict:
adict[c] += bnum
else:
adict[c] = bnum
sumA -= bnum * (b - c)
print(sumA)
| import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
alist = list(map(int, input().split()))
Q = int(input())
sumA = sum(alist)
adict = Counter(alist)
for _ in range(Q):
b, c = map(int, input().split())
if b not in adict:
print(sumA)
continue
bnum = adict.pop(b)
if c in adict:
adict[c] += bnum
else:
adict[c] = bnum
sumA -= bnum * (b - c)
print(sumA)
| insert | 17 | 17 | 17 | 21 | 0 | |
p02630 | Python | Runtime Error | N = int(input())
A = list(map(int, input().split()))
ans = 0
n = [0] * 10005
for i in range(N):
n[A[i]] += 1
ans += A[i]
Q = int(input())
for i in range(Q):
b, c = map(int, input().split())
ans += c * n[b] - b * n[b]
print(ans)
n[c] += n[b]
n[b] = 0
| N = int(input())
A = list(map(int, input().split()))
ans = 0
n = [0] * 100005
for i in range(N):
n[A[i]] += 1
ans += A[i]
Q = int(input())
for i in range(Q):
b, c = map(int, input().split())
ans += c * n[b] - b * n[b]
print(ans)
n[c] += n[b]
n[b] = 0
| replace | 4 | 5 | 4 | 5 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> A(n);
vector<long long> f(n, 0);
long long sum = 0;
for (int i = 0; i < n; i++) {
cin >> A[i];
sum += A[i];
f[A[i]]++;
}
int Q;
cin >> Q;
while (Q--) {
int b, c;
cin >> b >> c;
int diff = c - b;
sum += diff * f[b];
f[c] += f[b];
f[b] = 0;
cout << sum << "\n";
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> A(n);
vector<long long> f(1e5 + 1, 0);
long long sum = 0;
for (int i = 0; i < n; i++) {
cin >> A[i];
sum += A[i];
f[A[i]]++;
}
int Q;
cin >> Q;
while (Q--) {
int b, c;
cin >> b >> c;
int diff = c - b;
sum += diff * f[b];
f[c] += f[b];
f[b] = 0;
cout << sum << "\n";
}
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02630 | Python | Runtime Error | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
b, c = map(int, input().split())
B.append(b)
C.append(c)
counter = Counter(A)
ans = 0
for num, count in counter.items():
ans += num * count
for i in range(Q):
if B[i] in counter:
ans += counter[B[i]] * C[i] - counter[B[i]] * B[i]
counter[C[i]] = counter[C[i]] + counter.pop([B[i]])
print(ans)
| from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
b, c = map(int, input().split())
B.append(b)
C.append(c)
counter = Counter(A)
ans = 0
for num, count in counter.items():
ans += num * count
for i in range(Q):
if B[i] in counter:
ans += counter[B[i]] * C[i] - counter[B[i]] * B[i]
counter[C[i]] = counter[C[i]] + counter.pop(B[i])
print(ans)
| replace | 20 | 21 | 20 | 21 | TypeError: unhashable type: 'list' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02630/Python/s734232725.py", line 21, in <module>
counter[C[i]] = counter[C[i]] + counter.pop([B[i]])
TypeError: unhashable type: 'list'
|
p02630 | Python | Runtime Error | n = int(input())
a = list(map(int, input().split()))
mx = max(a)
table = [0] * (mx + 1)
for i in a:
table[i] += 1
q = int(input())
total = sum(a)
for i in range(q):
(
b,
c,
) = map(int, input().split())
total -= table[c] * c + table[b] * b
table[c] += table[b]
table[b] = 0
total += table[c] * c
print(total)
| n = int(input())
a = list(map(int, input().split()))
mx = 10**5
table = [0] * (mx + 1)
for i in a:
table[i] += 1
q = int(input())
total = sum(a)
for i in range(q):
(
b,
c,
) = map(int, input().split())
total -= table[c] * c + table[b] * b
table[c] += table[b]
table[b] = 0
total += table[c] * c
print(total)
| replace | 3 | 4 | 3 | 4 | 0 | |
p02630 | Python | Runtime Error | from collections import defaultdict
N = int(input())
_A = [*map(int, input().split())]
Q = int(input())
val = [[*map(int, line.split())] for line in open(0)]
A = defaultdict(int)
for _a in _A:
A[_a] += 1
ans = sum(_A)
for v in val:
if v[0] in A.keys():
num = A[v[0]]
A[v[0]] = 0
A[v[1]] += num
ans += (v[1] - v[0]) * num
print(ans)
| from collections import defaultdict
N, _A, Q, *val = [[*map(int, line.split())] for line in open(0)]
N = N[0]
Q = Q[0]
A = defaultdict(int)
for _a in _A:
A[_a] += 1
ans = sum(_A)
for v in val:
if v[0] in A.keys():
num = A[v[0]]
A[v[0]] = 0
A[v[1]] += num
ans += (v[1] - v[0]) * num
print(ans)
| replace | 2 | 6 | 2 | 5 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#define ll long long
using namespace std;
#define MAX 10005
int main() {
vector<int> l(MAX);
int n;
ll ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
l[a]++;
ans += a;
}
ll q;
cin >> q;
for (ll i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
ans += (ll)(c - b) * (ll)l[b];
l[c] += l[b];
l[b] = 0;
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#define ll long long
using namespace std;
#define MAX 100005
int main() {
vector<int> l(MAX);
int n;
ll ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
l[a]++;
ans += a;
}
ll q;
cin >> q;
for (ll i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
ans += (ll)(c - b) * (ll)l[b];
l[c] += l[b];
l[b] = 0;
cout << ans << endl;
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | Python | Time Limit Exceeded | N = int(input())
A = list(map(int, input().split()))
Q = int(input())
for i in range(Q):
B, C = map(int, input().split())
for i in range(N):
if A[i] == B:
A[i] = C
print(sum(A))
| from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
s = s - b * cnt[b]
s = s + c * cnt[b]
cnt[c] += cnt[b]
cnt[b] = 0
print(s)
| replace | 0 | 9 | 0 | 17 | TLE | |
p02630 | Python | Runtime Error | N = int(input())
A = list(map(int, input().split(" ")))
Q = int(input())
BC = [list(map(int, list(input().split(" ")))) for i in range(Q)]
count = [0] * 10**5 + 5
for i in range(N):
count[A[i]] += 1
s = sum(A)
for i in range(Q):
s = s - BC[i][0] * count[BC[i][0]] + BC[i][1] * count[BC[i][0]]
count[BC[i][1]] += count[BC[i][0]]
count[BC[i][0]] = 0
print(s)
| N = int(input())
A = list(map(int, input().split(" ")))
Q = int(input())
BC = [list(map(int, list(input().split(" ")))) for i in range(Q)]
count = [0] * (10**5 + 5)
for i in range(N):
count[A[i]] += 1
s = sum(A)
for i in range(Q):
s = s - BC[i][0] * count[BC[i][0]] + BC[i][1] * count[BC[i][0]]
count[BC[i][1]] += count[BC[i][0]]
count[BC[i][0]] = 0
print(s)
| replace | 5 | 6 | 5 | 6 | TypeError: can only concatenate list (not "int") to list | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02630/Python/s562064312.py", line 6, in <module>
count = [0] * 10**5 + 5
TypeError: can only concatenate list (not "int") to list
|
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long a[7001];
int main() {
long long n;
cin >> n;
long long s = 0;
for (int i = 1; i <= n; i++) {
long long o;
cin >> o;
a[o]++;
s += o;
}
int m;
cin >> m;
for (int i = 1; i <= m; i++) {
long long x, y;
cin >> x >> y;
s += (y - x) * a[x];
a[y] += a[x];
a[x] = 0;
cout << s << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
long long n;
cin >> n;
long long s = 0;
for (int i = 1; i <= n; i++) {
long long o;
cin >> o;
a[o]++;
s += o;
}
int m;
cin >> m;
for (int i = 1; i <= m; i++) {
long long x, y;
cin >> x >> y;
s += (y - x) * a[x];
a[y] += a[x];
a[x] = 0;
cout << s << endl;
}
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02630 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define ALLR(x) x.rbegin(), x.rend()
using namespace std;
int N, Q, p[100010], b[100010], c[10010];
ll sum;
int main() {
scanf("%d", &N);
rep(i, 0, N) {
int tmp;
scanf("%d", &tmp);
p[tmp]++;
sum += tmp;
}
scanf("%d", &Q);
rep(i, 0, Q) scanf("%d%d", &b[i], &c[i]);
rep(i, 0, Q) {
int _b = b[i], _c = c[i];
sum -= p[_b] * _b;
sum += p[_b] * _c;
p[_c] += p[_b];
p[_b] = 0;
printf("%lld\n", sum);
}
return 0;
}
| #include <cstdio>
#include <iostream>
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define ALLR(x) x.rbegin(), x.rend()
using namespace std;
int N, Q, p[100010], b[100010], c[100010];
ll sum;
int main() {
scanf("%d", &N);
rep(i, 0, N) {
int tmp;
scanf("%d", &tmp);
p[tmp]++;
sum += tmp;
}
scanf("%d", &Q);
rep(i, 0, Q) scanf("%d%d", &b[i], &c[i]);
rep(i, 0, Q) {
int _b = b[i], _c = c[i];
sum -= p[_b] * _b;
sum += p[_b] * _c;
p[_c] += p[_b];
p[_b] = 0;
printf("%lld\n", sum);
}
return 0;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p02630 | C++ | Time Limit Exceeded | #include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
long long int sum = 0;
unordered_map<int, int> m;
for (int i = 0; i < n; i++) {
cin >> a[i];
m[a[i]]++;
sum = sum + a[i];
}
int q;
cin >> q;
while (q--) {
int search, val;
cin >> search >> val;
while (m[search]--) {
sum = sum - search;
sum = sum + val;
m[val]++;
}
cout << sum << "\n";
}
} | #include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
long long int sum = 0;
unordered_map<int, int> m;
for (int i = 0; i < n; i++) {
cin >> a[i];
m[a[i]]++;
sum = sum + a[i];
}
int q;
cin >> q;
while (q--) {
int search, val;
cin >> search >> val;
sum = sum - (search * m[search]);
sum = sum + (val * m[search]);
m[val] = m[val] + m[search];
m[search] = 0;
cout << sum << "\n";
}
} | replace | 21 | 26 | 21 | 25 | TLE | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
typedef pair<ll, ll> Pair;
int main() {
ll N, Q;
ll sum = 0;
cin >> N;
vector<ll> A(N);
vector<ll> cnt(N + 1);
for (ll i = 0; i < N; ++i) {
cin >> A[i];
sum += A[i];
++cnt[A[i]];
}
cin >> Q;
vector<ll> B(Q);
vector<ll> C(Q);
vector<ll> S(Q, 0);
for (ll i = 0; i < Q; ++i) {
cin >> B[i] >> C[i];
sum += (C[i] - B[i]) * cnt[B[i]];
cnt[C[i]] += cnt[B[i]];
cnt[B[i]] = 0;
S[i] = sum;
}
for (ll i = 0; i < Q; ++i) {
cout << S[i] << endl;
}
return 0;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
typedef pair<ll, ll> Pair;
int main() {
ll N, Q;
ll sum = 0;
cin >> N;
vector<ll> A(N);
vector<ll> cnt(100001, 0);
for (ll i = 0; i < N; ++i) {
cin >> A[i];
sum += A[i];
++cnt[A[i]];
}
cin >> Q;
vector<ll> B(Q);
vector<ll> C(Q);
vector<ll> S(Q, 0);
for (ll i = 0; i < Q; ++i) {
cin >> B[i] >> C[i];
sum += (C[i] - B[i]) * cnt[B[i]];
cnt[C[i]] += cnt[B[i]];
cnt[B[i]] = 0;
S[i] = sum;
}
for (ll i = 0; i < Q; ++i) {
cout << S[i] << endl;
}
return 0;
}
| replace | 23 | 24 | 23 | 24 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int main() {
int N;
long long s = 0;
cin >> N;
vector<int> A(N);
vector<int> ap(10 * 10 * 10 * 10 * 10);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
s += A.at(i);
ap.at(A.at(i))++;
}
int Q;
cin >> Q;
vector<int> b(Q), c(Q);
for (int i = 0; i < Q; i++) {
cin >> b.at(i) >> c.at(i);
}
for (int i = 0; i < Q; i++) {
s += (long long)ap.at(b.at(i)) * ((long long)c.at(i) - (long long)b.at(i));
ap.at(c.at(i)) += ap.at(b.at(i));
ap.at(b.at(i)) = 0;
cout << s << endl;
}
}
| #include <algorithm>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int main() {
int N;
long long s = 0;
cin >> N;
vector<int> A(N);
vector<int> ap(10 * 10 * 10 * 10 * 10 + 1);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
s += A.at(i);
ap.at(A.at(i))++;
}
int Q;
cin >> Q;
vector<int> b(Q), c(Q);
for (int i = 0; i < Q; i++) {
cin >> b.at(i) >> c.at(i);
}
for (int i = 0; i < Q; i++) {
s += (long long)ap.at(b.at(i)) * ((long long)c.at(i) - (long long)b.at(i));
ap.at(c.at(i)) += ap.at(b.at(i));
ap.at(b.at(i)) = 0;
cout << s << endl;
}
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <string>
using namespace std;
typedef unsigned long long int lli;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli n;
cin >> n;
vector<lli> v(n + 1);
vector<lli> frequency(n + 1);
lli sum = 0;
for (int i = 1; i <= n; i++) {
cin >> v[i];
frequency[v[i]]++;
sum += v[i];
}
lli q;
cin >> q;
while (q--) {
lli b, c;
cin >> b >> c;
sum += -frequency[b] * b + frequency[b] * c;
cout << sum << endl;
frequency[c] += frequency[b];
frequency[b] = 0;
}
}
| #include <bits/stdc++.h>
#include <string>
using namespace std;
typedef unsigned long long int lli;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli n;
cin >> n;
vector<lli> v(n + 1);
vector<lli> frequency(1000001);
lli sum = 0;
for (int i = 1; i <= n; i++) {
cin >> v[i];
frequency[v[i]]++;
sum += v[i];
}
lli q;
cin >> q;
while (q--) {
lli b, c;
cin >> b >> c;
sum += -frequency[b] * b + frequency[b] * c;
cout << sum << endl;
frequency[c] += frequency[b];
frequency[b] = 0;
}
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02630 | Python | Runtime Error | N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())
b_to_c = [[int(_) for _ in input().split()] for i in range(Q)]
sum = 0
memo = [0] * (10**5)
for i in A:
memo[i] += 1
sum += i
for bc in b_to_c:
b = bc[0]
c = bc[1]
sum -= b * memo[b]
sum += c * memo[b]
memo[c] += memo[b]
memo[b] = 0
print(sum)
| N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())
b_to_c = [[int(_) for _ in input().split()] for i in range(Q)]
sum = 0
memo = [0] * (10**5 + 1)
for i in A:
memo[i] += 1
sum += i
for bc in b_to_c:
b = bc[0]
c = bc[1]
sum -= b * memo[b]
sum += c * memo[b]
memo[c] += memo[b]
memo[b] = 0
print(sum)
| replace | 6 | 7 | 6 | 7 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>
int main() {
int n, q;
cin >> n;
vint a(n);
REP(i, n) cin >> a[i];
cin >> q;
vector<vector<int>> b(q, vector<int>(2));
REP(i, q) { cin >> b[i][0] >> b[i][1]; }
sort(a.begin(), a.end());
vector<long long> h(a[a.size() - 1], 0);
long long s = 0;
REP(i, n) {
h[a[i] - 1]++;
s += a[i];
}
REP(i, q) {
s += (b[i][1] - b[i][0]) * h[b[i][0] - 1];
h[b[i][1] - 1] += h[b[i][0] - 1];
h[b[i][0] - 1] = 0;
cout << s << endl;
}
return 0;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>
int main() {
int n, q;
cin >> n;
vint a(n);
REP(i, n) cin >> a[i];
cin >> q;
vector<vector<int>> b(q, vector<int>(2));
REP(i, q) { cin >> b[i][0] >> b[i][1]; }
sort(a.begin(), a.end());
vector<long long> h((int)(1e5), 0);
long long s = 0;
REP(i, n) {
h[a[i] - 1]++;
s += a[i];
}
REP(i, q) {
s += (b[i][1] - b[i][0]) * h[b[i][0] - 1];
h[b[i][1] - 1] += h[b[i][0] - 1];
h[b[i][0] - 1] = 0;
cout << s << endl;
}
return 0;
} | replace | 26 | 27 | 26 | 27 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<int> vec(10001, 0);
int main() {
cout << fixed << setprecision(10);
int N;
cin >> N;
vector<int> A(N);
ll sum = 0;
rep(i, N) {
cin >> A[i];
sum += A[i];
vec[A[i]]++;
}
int Q;
cin >> Q;
vector<int> B(Q), C(Q);
rep(i, Q) cin >> B[i] >> C[i];
rep(i, Q) {
if (C[i] >= B[i]) {
sum += vec[B[i]] * (C[i] - B[i]);
} else {
sum -= vec[B[i]] * (B[i] - C[i]);
}
if (B[i] != C[i]) {
vec[C[i]] += vec[B[i]];
vec[B[i]] = 0;
}
cout << sum << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<int> vec(100001, 0);
int main() {
cout << fixed << setprecision(10);
int N;
cin >> N;
vector<int> A(N);
ll sum = 0;
rep(i, N) {
cin >> A[i];
sum += A[i];
vec[A[i]]++;
}
int Q;
cin >> Q;
vector<int> B(Q), C(Q);
rep(i, Q) cin >> B[i] >> C[i];
rep(i, Q) {
if (C[i] >= B[i]) {
sum += vec[B[i]] * (C[i] - B[i]);
} else {
sum -= vec[B[i]] * (B[i] - C[i]);
}
if (B[i] != C[i]) {
vec[C[i]] += vec[B[i]];
vec[B[i]] = 0;
}
cout << sum << endl;
}
return 0;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
int64_t s = 0;
vector<vector<int>> v(100000, vector<int>(0));
for (int i = 0; i < n; i++) {
cin >> a.at(i);
s += a.at(i);
v.at(a.at(i)).push_back(i);
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
if (b != c) {
int z = v.at(b).size();
for (int j = 0; j < z; j++) {
v.at(c).push_back(v.at(b).at(j));
}
for (int j = 0; j < z; j++) {
v.at(b).pop_back();
}
s += (c - b) * z;
cout << s << endl;
}
else
cout << s << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
int64_t s = 0;
vector<vector<int>> v(100001, vector<int>(0));
for (int i = 0; i < n; i++) {
cin >> a.at(i);
s += a.at(i);
v.at(a.at(i)).push_back(i);
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
if (b != c) {
int z = v.at(b).size();
for (int j = 0; j < z; j++) {
v.at(c).push_back(v.at(b).at(j));
}
for (int j = 0; j < z; j++) {
v.at(b).pop_back();
}
s += (c - b) * z;
cout << s << endl;
}
else
cout << s << endl;
}
} | replace | 10 | 11 | 10 | 11 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
int main() {
int n;
cin >> n;
long sum = 0;
vector<int> a(100000);
rep(i, n) {
int tmp;
cin >> tmp;
a.at(tmp)++;
sum += tmp;
}
int q;
cin >> q;
rep(i, q) {
int b, c;
cin >> b >> c;
int cnt = a.at(b);
sum = sum + cnt * (c - b);
cout << sum << endl;
a.at(c) += a.at(b);
a.at(b) = 0;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
int main() {
int n;
cin >> n;
long sum = 0;
vector<int> a(100001);
rep(i, n) {
int tmp;
cin >> tmp;
a.at(tmp)++;
sum += tmp;
}
int q;
cin >> q;
rep(i, q) {
int b, c;
cin >> b >> c;
int cnt = a.at(b);
sum = sum + cnt * (c - b);
cout << sum << endl;
a.at(c) += a.at(b);
a.at(b) = 0;
}
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
ll N;
cin >> N;
vector<ll> A(N);
rep(i, N) cin >> A.at(i);
ll Q;
cin >> Q;
vector<ll> B(Q), C(Q);
rep(i, Q) { cin >> B.at(i) >> C.at(i); }
int MAX = 100000;
vector<long> S(Q);
vector<int> count(MAX, 0);
rep(i, N) { count.at(A.at(i))++; }
long sum = 0;
rep(i, N) { sum += A.at(i); }
rep(i, Q) {
int num = count.at(B.at(i));
int diff = C.at(i) - B.at(i);
count.at(B.at(i)) = 0;
count.at(C.at(i)) += num;
sum += diff * num;
S.at(i) = sum;
}
rep(i, Q) { cout << S.at(i) << endl; }
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
ll N;
cin >> N;
vector<ll> A(N);
rep(i, N) cin >> A.at(i);
ll Q;
cin >> Q;
vector<ll> B(Q), C(Q);
rep(i, Q) { cin >> B.at(i) >> C.at(i); }
int MAX = 100001;
vector<ll> S(Q);
vector<int> count(MAX, 0);
rep(i, N) { count.at(A.at(i))++; }
long sum = 0;
rep(i, N) { sum += A.at(i); }
rep(i, Q) {
int num = count.at(B.at(i));
int diff = C.at(i) - B.at(i);
count.at(B.at(i)) = 0;
count.at(C.at(i)) += num;
sum += diff * num;
S.at(i) = sum;
}
rep(i, Q) { cout << S.at(i) << endl; }
} | replace | 14 | 16 | 14 | 16 | 0 | |
p02630 | C++ | Runtime Error | #include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> cnt(n + 1, 0);
long long ans = 0;
rep(i, n) {
cin >> a[i];
ans += a[i];
cnt[a[i]]++;
}
int q;
cin >> q;
vector<int> b(q);
vector<int> c(q);
rep(i, q) cin >> b[i] >> c[i];
rep(i, q) {
int d = c[i] - b[i];
ans += d * cnt[b[i]];
cout << ans << endl;
cnt[c[i]] += cnt[b[i]];
cnt[b[i]] = 0;
}
return 0;
}
| #include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> cnt(100001, 0);
long long ans = 0;
rep(i, n) {
cin >> a[i];
ans += a[i];
cnt[a[i]]++;
}
int q;
cin >> q;
vector<int> b(q);
vector<int> c(q);
rep(i, q) cin >> b[i] >> c[i];
rep(i, q) {
int d = c[i] - b[i];
ans += d * cnt[b[i]];
cout << ans << endl;
cnt[c[i]] += cnt[b[i]];
cnt[b[i]] = 0;
}
return 0;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
vector<ll> m(10001, 0);
ll n;
cin >> n;
ll ans = 0;
REP(i, n) {
ll a;
cin >> a;
m[a] += 1;
ans += a;
}
ll q;
cin >> q;
REP(i, q) {
ll b, c;
cin >> b >> c;
ans += (c - b) * m[b];
m[c] += m[b];
m[b] = 0;
cout << ans << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
vector<ll> m(100001, 0);
ll n;
cin >> n;
ll ans = 0;
REP(i, n) {
ll a;
cin >> a;
m[a] += 1;
ans += a;
}
ll q;
cin >> q;
REP(i, q) {
ll b, c;
cin >> b >> c;
ans += (c - b) * m[b];
m[c] += m[b];
m[b] = 0;
cout << ans << endl;
}
}
| replace | 28 | 29 | 28 | 29 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// 約数列挙(√N)
vector<int64_t> divisor(int64_t n) {
vector<int64_t> ret;
for (int64_t i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
// 素因数分解(√N)
map<int64_t, int> prime_factor(int64_t n) {
map<int64_t, int> ret;
for (int64_t i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
// 素数テーブル(NloglogN)
vector<bool> prime_table(int n) {
vector<bool> prime(n + 1, true);
if (n >= 0)
prime[0] = false;
if (n >= 1)
prime[1] = false;
for (int i = 2; i * i <= n; i++) {
if (!prime[i])
continue;
for (int j = i + i; j <= n; j += i) {
prime[j] = false;
}
}
return prime;
}
// 二項係数(K)
template <typename T> T binomial(int64_t N, int64_t K) {
if (K < 0 || N < K)
return 0;
T ret = 1;
for (T i = 1; i <= K; ++i) {
ret *= N--;
ret /= i;
}
return ret;
}
// 二項係数テーブル(N^2)
template <typename T> vector<vector<T>> binomial_table(int N) {
vector<vector<T>> mat(N + 1, vector<T>(N + 1));
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i)
mat[i][j] = 1;
else
mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
}
}
return mat;
}
int main() {
int n;
ll sum = 0;
cin >> n;
vector<int> a(100000);
rep(i, n) {
int k;
cin >> k;
sum += k;
a.at(k)++;
}
int q;
cin >> q;
rep(i, q) {
int b, c;
cin >> b >> c;
sum += (c - b) * a.at(b);
a.at(c) += a.at(b);
a.at(b) = 0;
cout << sum << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// 約数列挙(√N)
vector<int64_t> divisor(int64_t n) {
vector<int64_t> ret;
for (int64_t i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
// 素因数分解(√N)
map<int64_t, int> prime_factor(int64_t n) {
map<int64_t, int> ret;
for (int64_t i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
// 素数テーブル(NloglogN)
vector<bool> prime_table(int n) {
vector<bool> prime(n + 1, true);
if (n >= 0)
prime[0] = false;
if (n >= 1)
prime[1] = false;
for (int i = 2; i * i <= n; i++) {
if (!prime[i])
continue;
for (int j = i + i; j <= n; j += i) {
prime[j] = false;
}
}
return prime;
}
// 二項係数(K)
template <typename T> T binomial(int64_t N, int64_t K) {
if (K < 0 || N < K)
return 0;
T ret = 1;
for (T i = 1; i <= K; ++i) {
ret *= N--;
ret /= i;
}
return ret;
}
// 二項係数テーブル(N^2)
template <typename T> vector<vector<T>> binomial_table(int N) {
vector<vector<T>> mat(N + 1, vector<T>(N + 1));
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i)
mat[i][j] = 1;
else
mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
}
}
return mat;
}
int main() {
int n;
ll sum = 0;
cin >> n;
vector<int> a(100001);
rep(i, n) {
int k;
cin >> k;
sum += k;
a.at(k)++;
}
int q;
cin >> q;
rep(i, q) {
int b, c;
cin >> b >> c;
sum += (c - b) * a.at(b);
a.at(c) += a.at(b);
a.at(b) = 0;
cout << sum << endl;
}
} | replace | 78 | 79 | 78 | 79 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
vector<string> split(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty()) {
elems.push_back(item);
}
item.clear();
} else {
item += ch;
}
}
if (!item.empty()) {
elems.push_back(item);
}
return elems;
}
string to_str_with_zero(int i, int w) {
ostringstream sout;
sout << std::setfill('0') << std::setw(w) << i;
string s = sout.str();
return s;
}
int letter_to_int(char c) { return tolower(c) - 'a'; }
bool array_equal(vector<int> a1, vector<int> a2) {
if (a1.size() != a2.size()) {
return false;
}
for (int i = 0; i < a1.size(); i++) {
if (a1.at(i) != a2.at(i)) {
return false;
}
}
return true;
}
int gcd(int a, int b) {
if (a == b) {
return a;
} else if (a > b) {
return gcd(a - b, b);
} else {
return gcd(a, b - a);
}
}
int main() {
std::cout << std::setprecision(9);
int n;
cin >> n;
vector<int> a_count(100000);
long sum = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
a_count.at(a)++;
sum += a;
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
sum += a_count.at(b) * (c - b);
a_count.at(c) += a_count.at(b);
a_count.at(b) = 0;
cout << sum << endl;
}
} | #include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
vector<string> split(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty()) {
elems.push_back(item);
}
item.clear();
} else {
item += ch;
}
}
if (!item.empty()) {
elems.push_back(item);
}
return elems;
}
string to_str_with_zero(int i, int w) {
ostringstream sout;
sout << std::setfill('0') << std::setw(w) << i;
string s = sout.str();
return s;
}
int letter_to_int(char c) { return tolower(c) - 'a'; }
bool array_equal(vector<int> a1, vector<int> a2) {
if (a1.size() != a2.size()) {
return false;
}
for (int i = 0; i < a1.size(); i++) {
if (a1.at(i) != a2.at(i)) {
return false;
}
}
return true;
}
int gcd(int a, int b) {
if (a == b) {
return a;
} else if (a > b) {
return gcd(a - b, b);
} else {
return gcd(a, b - a);
}
}
int main() {
std::cout << std::setprecision(9);
int n;
cin >> n;
vector<int> a_count(100001);
long sum = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
a_count.at(a)++;
sum += a;
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
sum += a_count.at(b) * (c - b);
a_count.at(c) += a_count.at(b);
a_count.at(b) = 0;
cout << sum << endl;
}
} | replace | 61 | 62 | 61 | 62 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
int main() {
ll N;
cin >> N;
ll A;
vector<ll> vec;
vec.reserve(10001);
for (auto i = 0; i < 10001; i++) {
vec.push_back(0);
}
ll ret = 0;
for (auto i = 0; i < N; i++) {
cin >> A;
vec[A]++;
ret += A;
}
ll Q, B, C;
cin >> Q;
for (auto i = 0; i < Q; i++) {
cin >> B >> C;
ret += (C - B) * vec[B];
vec[C] += vec[B];
vec[B] = 0;
cout << ret << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
int main() {
ll N;
cin >> N;
ll A;
vector<ll> vec;
ll limit = pow(10, 6);
vec.reserve(limit);
for (auto i = 0; i < limit; i++) {
vec.push_back(0);
}
ll ret = 0;
for (auto i = 0; i < N; i++) {
cin >> A;
vec[A]++;
ret += A;
}
ll Q, B, C;
cin >> Q;
for (auto i = 0; i < Q; i++) {
cin >> B >> C;
ret += (C - B) * vec[B];
vec[C] += vec[B];
vec[B] = 0;
cout << ret << endl;
}
return 0;
} | replace | 17 | 19 | 17 | 20 | 0 | |
p02630 | C++ | Runtime Error | /* author : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020
*/
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
void solve(int cnum) {
int64_t n;
cin >> n;
vector<int64_t> arr(n);
vector<int64_t> freq(n);
int64_t sum = 0;
for (int i = 0; i < n; ++i) {
cin >> arr[i];
sum += arr[i];
freq[arr[i]]++;
}
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
int64_t a, b;
cin >> a >> b;
int64_t num = freq[a];
int64_t torem = a * num;
freq[a] = 0;
sum -= torem;
torem = b * num;
sum += torem;
freq[b] += num;
cout << sum << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
int t;
int count = 1;
for (t = 1; t--; solve(count))
;
return 0;
} | /* author : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020
*/
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
void solve(int cnum) {
int64_t n;
cin >> n;
vector<int64_t> arr(n);
vector<int64_t> freq(100005);
int64_t sum = 0;
for (int i = 0; i < n; ++i) {
cin >> arr[i];
sum += arr[i];
freq[arr[i]]++;
}
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
int64_t a, b;
cin >> a >> b;
int64_t num = freq[a];
int64_t torem = a * num;
freq[a] = 0;
sum -= torem;
torem = b * num;
sum += torem;
freq[b] += num;
cout << sum << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
int t;
int count = 1;
for (t = 1; t--; solve(count))
;
return 0;
} | replace | 27 | 28 | 27 | 28 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;
// typedef long long LL;
#define For(a, b, c) for (int a = b; a <= c; a++)
#define For_(a, b, c) for (int a = b; a >= c; a--)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define debug(x) cout << #x << " " << x << " "
int read() {
int r = 0, f = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
r = (r << 1) + (r << 3) + c - '0';
c = getchar();
}
return r * f;
}
#define MAXN 10005
int cnt[MAXN], n, q;
long long ans;
int main() {
n = read();
For(i, 1, n) {
int x = read();
ans += x;
cnt[x]++;
}
q = read();
For(i, 1, q) {
int b = read(), c = read();
ans -= 1ll * cnt[b] * b;
ans += 1ll * cnt[b] * c;
printf("%lld\n", ans);
cnt[c] += cnt[b];
cnt[b] = 0;
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;
// typedef long long LL;
#define For(a, b, c) for (int a = b; a <= c; a++)
#define For_(a, b, c) for (int a = b; a >= c; a--)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define debug(x) cout << #x << " " << x << " "
int read() {
int r = 0, f = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
r = (r << 1) + (r << 3) + c - '0';
c = getchar();
}
return r * f;
}
#define MAXN 100005
int cnt[MAXN], n, q;
long long ans;
int main() {
n = read();
For(i, 1, n) {
int x = read();
ans += x;
cnt[x]++;
}
q = read();
For(i, 1, q) {
int b = read(), c = read();
ans -= 1ll * cnt[b] * b;
ans += 1ll * cnt[b] * c;
printf("%lld\n", ans);
cnt[c] += cnt[b];
cnt[b] = 0;
}
return 0;
}
| replace | 32 | 33 | 32 | 33 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
const int MAX = 10005;
int counter[MAX];
int main() {
int n;
cin >> n;
ll a[n];
ll fsum = 0;
for (int i = 0; i < MAX; ++i) {
counter[i] = 0;
}
for (int i = 0; i < n; ++i) {
cin >> a[i];
counter[a[i]]++;
fsum += a[i];
}
int q;
cin >> q;
int b[q], c[q];
for (int i = 0; i < q; ++i) {
cin >> b[i] >> c[i];
}
for (int i = 0; i < q; ++i) {
ll cur = counter[b[i]];
counter[b[i]] = 0;
counter[c[i]] += cur;
fsum += (ll)((c[i] - b[i]) * cur);
cout << fsum << endl;
}
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
const int MAX = 100005;
int counter[MAX];
int main() {
int n;
cin >> n;
ll a[n];
ll fsum = 0;
for (int i = 0; i < MAX; ++i) {
counter[i] = 0;
}
for (int i = 0; i < n; ++i) {
cin >> a[i];
counter[a[i]]++;
fsum += a[i];
}
int q;
cin >> q;
int b[q], c[q];
for (int i = 0; i < q; ++i) {
cin >> b[i] >> c[i];
}
for (int i = 0; i < q; ++i) {
ll cur = counter[b[i]];
counter[b[i]] = 0;
counter[c[i]] += cur;
fsum += (ll)((c[i] - b[i]) * cur);
cout << fsum << endl;
}
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02630 | C++ | Runtime Error | #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CFOR(i, str) for (int i = 0; (str)[i] != '\0'; (i)++)
#define FOR(i, s, r) for (ll i = (s); i < (r); i++)
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define CNT(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define n_l '\n'
#define P cout <<
// dbg(var)
#define dbg(...) \
cerr << "[" << #__VA_ARGS__ << "]: " << to_string(__VA_ARGS__) << n_l;
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; }
template <typename T> int SIZE(const T &t) { return t.size(); }
string to_string(const string s, int x1 = 0, int x2 = 1e9) {
return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"';
}
string to_string(const char *s) { return to_string((string)s); }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char c) { return string({c}); }
template <size_t N>
string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) {
string t = "";
for (int __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1);
__iii__ <= __jjj__; ++__iii__) {
t += b[__iii__] + '0';
}
return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A(&v), int x1 = 0, int x2 = 1e9, C... coords);
int l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B> string to_string(const pair<A, B> &p) {
l_v_l_v_l++;
string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
l_v_l_v_l--;
return res;
}
template <typename A, typename... C>
string to_string(const A(&v), int x1, int x2, C... coords) {
int rnk = rank<A>::value;
string tab(t_a_b_s, ' ');
string res = "";
bool first = true;
if (l_v_l_v_l == 0)
res += n_l;
res += tab + "[";
x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
auto l = begin(v);
advance(l, x1);
auto r = l;
advance(r, (x2 - x1) + (x2 < SIZE(v)));
for (auto e = l; e != r; e = next(e)) {
if (!first) {
res += ", ";
}
first = false;
l_v_l_v_l++;
if (e != l) {
if (rnk > 1) {
res += n_l;
t_a_b_s = l_v_l_v_l;
};
} else {
t_a_b_s = 0;
}
res += to_string(*e, coords...);
l_v_l_v_l--;
}
res += "]";
if (l_v_l_v_l == 0)
res += n_l;
return res;
}
void dbgm() { ; }
template <typename Heads, typename... Tails> void dbgm(Heads H, Tails... T) {
cerr << to_string(H) << " | ";
dbgm(T...);
}
// dbgm(var1, var2, var3, ...)
#define dbgm(...) \
cerr << "[" << #__VA_ARGS__ << "]: "; \
dbgm(__VA_ARGS__); \
cerr << endl
#define rot(s, k) \
rotate(s.begin(), s.begin() + s.size() - (k % s.size()), \
s.end()); //+ve = right, -ve = left
ll binpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
bool isPrime(ll n) {
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
int total(int n) { return int((-1 + sqrt(1 + 8 * n)) / 2); }
const int N = 1e5 + 1;
ll f[5], n, q;
ll sum;
void solve() {
int num;
cin >> n;
FOR(i, 0, n) {
cin >> num;
sum += num;
f[num]++;
}
cin >> q;
FOR(j, 0, q) {
int i, r;
cin >> i >> r;
sum += (r - i) * f[i];
f[r] += f[i];
f[i] = 0;
cout << sum << n_l;
// dbg(f);
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
clock_t start = clock();
// int t;
// cin>>t;
// while(t--)
solve();
// // Google KS
// for(int i = 1; i < t+1; i++) {
//
// cout<<"Case #"<<i<<": "<<solve()<<"\n";
// }
clock_t stop = clock();
double elapsed = (double)10 * (stop - start) / CLOCKS_PER_SEC;
cerr << setprecision(5) << fixed;
cerr << "\nProcess finished in: " << elapsed << "ms\n";
return 0;
} | #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CFOR(i, str) for (int i = 0; (str)[i] != '\0'; (i)++)
#define FOR(i, s, r) for (ll i = (s); i < (r); i++)
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define CNT(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define n_l '\n'
#define P cout <<
// dbg(var)
#define dbg(...) \
cerr << "[" << #__VA_ARGS__ << "]: " << to_string(__VA_ARGS__) << n_l;
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; }
template <typename T> int SIZE(const T &t) { return t.size(); }
string to_string(const string s, int x1 = 0, int x2 = 1e9) {
return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"';
}
string to_string(const char *s) { return to_string((string)s); }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char c) { return string({c}); }
template <size_t N>
string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) {
string t = "";
for (int __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1);
__iii__ <= __jjj__; ++__iii__) {
t += b[__iii__] + '0';
}
return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A(&v), int x1 = 0, int x2 = 1e9, C... coords);
int l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B> string to_string(const pair<A, B> &p) {
l_v_l_v_l++;
string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
l_v_l_v_l--;
return res;
}
template <typename A, typename... C>
string to_string(const A(&v), int x1, int x2, C... coords) {
int rnk = rank<A>::value;
string tab(t_a_b_s, ' ');
string res = "";
bool first = true;
if (l_v_l_v_l == 0)
res += n_l;
res += tab + "[";
x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
auto l = begin(v);
advance(l, x1);
auto r = l;
advance(r, (x2 - x1) + (x2 < SIZE(v)));
for (auto e = l; e != r; e = next(e)) {
if (!first) {
res += ", ";
}
first = false;
l_v_l_v_l++;
if (e != l) {
if (rnk > 1) {
res += n_l;
t_a_b_s = l_v_l_v_l;
};
} else {
t_a_b_s = 0;
}
res += to_string(*e, coords...);
l_v_l_v_l--;
}
res += "]";
if (l_v_l_v_l == 0)
res += n_l;
return res;
}
void dbgm() { ; }
template <typename Heads, typename... Tails> void dbgm(Heads H, Tails... T) {
cerr << to_string(H) << " | ";
dbgm(T...);
}
// dbgm(var1, var2, var3, ...)
#define dbgm(...) \
cerr << "[" << #__VA_ARGS__ << "]: "; \
dbgm(__VA_ARGS__); \
cerr << endl
#define rot(s, k) \
rotate(s.begin(), s.begin() + s.size() - (k % s.size()), \
s.end()); //+ve = right, -ve = left
ll binpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
bool isPrime(ll n) {
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
int total(int n) { return int((-1 + sqrt(1 + 8 * n)) / 2); }
const int N = 1e5 + 1;
ll f[N], n, q;
ll sum;
void solve() {
int num;
cin >> n;
FOR(i, 0, n) {
cin >> num;
sum += num;
f[num]++;
}
cin >> q;
FOR(j, 0, q) {
int i, r;
cin >> i >> r;
sum += (r - i) * f[i];
f[r] += f[i];
f[i] = 0;
cout << sum << n_l;
// dbg(f);
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
clock_t start = clock();
// int t;
// cin>>t;
// while(t--)
solve();
// // Google KS
// for(int i = 1; i < t+1; i++) {
//
// cout<<"Case #"<<i<<": "<<solve()<<"\n";
// }
clock_t stop = clock();
double elapsed = (double)10 * (stop - start) / CLOCKS_PER_SEC;
cerr << setprecision(5) << fixed;
cerr << "\nProcess finished in: " << elapsed << "ms\n";
return 0;
} | replace | 130 | 131 | 130 | 131 | 0 |
Process finished in: 0.00049ms
|
p02630 | 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;
typedef pair<int, int> P;
int main() {
int n;
cin >> n;
int a[n];
rep(i, n) cin >> a[i];
int q;
cin >> q;
int b[n], c[n];
rep(i, q) cin >> b[i] >> c[i];
map<int, int> count;
rep(i, n) count[a[i]]++;
ll sum = 0;
for (auto v : count)
sum += (ll)v.first * v.second;
rep(i, q) {
if (count[b[i]] != 0) {
int tmp = count[b[i]];
count[c[i]] += tmp;
count[b[i]] = 0;
sum += (ll)(c[i] - b[i]) * tmp;
}
cout << sum << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
int n;
cin >> n;
int a[n];
rep(i, n) cin >> a[i];
int q;
cin >> q;
int b[q], c[q];
rep(i, q) cin >> b[i] >> c[i];
map<int, int> count;
rep(i, n) count[a[i]]++;
ll sum = 0;
for (auto v : count)
sum += (ll)v.first * v.second;
rep(i, q) {
if (count[b[i]] != 0) {
int tmp = count[b[i]];
count[c[i]] += tmp;
count[b[i]] = 0;
sum += (ll)(c[i] - b[i]) * tmp;
}
cout << sum << endl;
}
return 0;
} | replace | 13 | 14 | 13 | 14 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
vector<ll> vi(100000, 0);
ll sum = 0;
for (int i = 0; i < N; i++) {
ll a;
cin >> a;
vi.at(a)++;
sum += a;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll from, to;
cin >> from >> to;
ll dif = vi.at(from) * (to - from);
sum = sum + dif;
vi.at(to) += vi.at(from);
vi.at(from) -= vi.at(from);
cout << sum << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
vector<ll> vi(100001, 0);
ll sum = 0;
for (int i = 0; i < N; i++) {
ll a;
cin >> a;
vi.at(a)++;
sum += a;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
ll from, to;
cin >> from >> to;
ll dif = vi.at(from) * (to - from);
sum = sum + dif;
vi.at(to) += vi.at(from);
vi.at(from) -= vi.at(from);
cout << sum << endl;
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr first
#define sec second
#define rep(i, n) for (i = 0; i < n; i++)
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define M 1000000007
#define ios \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define open freopen("input.txt", "r", stdin);
#define close freopen("output.txt", "w", stdout);
#define M_PI 3.14159265358979323846
#define pp pair<int, int>
#define nn 100003
int main() {
ios;
ll n, i, q, b, c, sum = 0;
map<ll, ll> mp;
cin >> n;
ll a[n];
rep(i, n) {
cin >> a[i];
sum += a[i];
mp[a[i]]++;
}
cin >> q;
rep(i, q) {
ll currsum;
cin >> b >> c;
if (mp.find(b) != mp.end()) {
ll x = mp[b];
currsum = sum - x * b + x * c;
sum = currsum;
replace(a, a + n, b, c);
mp.erase(b);
if (mp.find(c) != mp.end())
mp[c] += x;
else
mp[c] = x;
} else
currsum = sum;
cout << currsum << "\n";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr first
#define sec second
#define rep(i, n) for (i = 0; i < n; i++)
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define M 1000000007
#define ios \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define open freopen("input.txt", "r", stdin);
#define close freopen("output.txt", "w", stdout);
#define M_PI 3.14159265358979323846
#define pp pair<int, int>
#define nn 100003
int main() {
ios;
ll n, i, q, b, c, sum = 0;
map<ll, ll> mp;
cin >> n;
ll a[n];
rep(i, n) {
cin >> a[i];
sum += a[i];
mp[a[i]]++;
}
cin >> q;
rep(i, q) {
ll currsum;
cin >> b >> c;
if (mp.find(b) != mp.end()) {
ll x = mp[b];
currsum = sum - x * b + x * c;
sum = currsum;
mp.erase(b);
if (mp.find(c) != mp.end())
mp[c] += x;
else
mp[c] = x;
} else
currsum = sum;
cout << currsum << "\n";
}
return 0;
}
| delete | 42 | 43 | 42 | 42 | TLE | |
p02630 | C++ | Runtime Error | // noobie_corleone
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define ss second
#define ff first
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define f(i, n) fr(i, 0, n)
#define rf(i, b, a) for (ll i = b - 1; i >= a; i--)
#define r(i, n) rf(i, n, 0)
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pd pair<ld, ld>
#define endl '\n'
#define PI \
3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define mod 1000000007
#define inf 1000000007
#define eps 0.000000000000001
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// vector<int>
// adj[200010],value(200010),par(200010),vis(200010,0),dis(200010,0),g(200010,0),col(200010,-1);
// int myrandom (int i) { return std::rand()%i;}
int main() {
ll n;
cin >> n;
vl a(n), cnt(10001, 0);
ll s = 0;
f(i, n) {
cin >> a[i];
cnt[a[i]]++;
s += a[i];
}
ll q;
cin >> q;
vl b(q), c(q);
f(i, q) {
cin >> b[i] >> c[i];
s -= (cnt[b[i]] * b[i]);
s += (cnt[b[i]] * c[i]);
cnt[c[i]] += cnt[b[i]];
cnt[b[i]] = 0;
cout << s << endl;
}
return 0;
}
| // noobie_corleone
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define ss second
#define ff first
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define f(i, n) fr(i, 0, n)
#define rf(i, b, a) for (ll i = b - 1; i >= a; i--)
#define r(i, n) rf(i, n, 0)
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pd pair<ld, ld>
#define endl '\n'
#define PI \
3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define mod 1000000007
#define inf 1000000007
#define eps 0.000000000000001
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// vector<int>
// adj[200010],value(200010),par(200010),vis(200010,0),dis(200010,0),g(200010,0),col(200010,-1);
// int myrandom (int i) { return std::rand()%i;}
int main() {
ll n;
cin >> n;
vl a(n), cnt(100001, 0);
ll s = 0;
f(i, n) {
cin >> a[i];
cnt[a[i]]++;
s += a[i];
}
ll q;
cin >> q;
vl b(q), c(q);
f(i, q) {
cin >> b[i] >> c[i];
s -= (cnt[b[i]] * b[i]);
s += (cnt[b[i]] * c[i]);
cnt[c[i]] += cnt[b[i]];
cnt[b[i]] = 0;
cout << s << endl;
}
return 0;
}
| replace | 50 | 51 | 50 | 51 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
unsigned long long int ans = 0;
cin >> N;
vector<int> num(100000, 0);
for (int i = 0; i < N; i++) {
int A;
cin >> A;
ans += A;
num.at(A)++;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
int B, C;
cin >> B >> C;
ans += (C - B) * num.at(B);
num.at(C) += num.at(B);
num.at(B) = 0;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
unsigned long long int ans = 0;
cin >> N;
vector<int> num(100001, 0);
for (int i = 0; i < N; i++) {
int A;
cin >> A;
ans += A;
num.at(A)++;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
int B, C;
cin >> B >> C;
ans += (C - B) * num.at(B);
num.at(C) += num.at(B);
num.at(B) = 0;
cout << ans << endl;
}
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long MAX = 100005;
int main(void) {
long long N;
cin >> N;
vector<long long> bucket(N);
long long sum = 0;
for (int i = 0; i < N; i++) {
long long tmp;
cin >> tmp;
sum += tmp;
bucket[tmp]++;
}
long long Q;
cin >> Q;
long long B, C;
for (int i = 0; i < Q; i++) {
cin >> B >> C;
long long diff = C - B;
sum += bucket[B] * diff;
bucket[C] += bucket[B];
bucket[B] = 0;
cout << sum << "\n";
} // for
} // main
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long MAX = 100005;
int main(void) {
long long N;
cin >> N;
vector<long long> bucket(MAX);
long long sum = 0;
for (int i = 0; i < N; i++) {
long long tmp;
cin >> tmp;
sum += tmp;
bucket[tmp]++;
}
long long Q;
cin >> Q;
long long B, C;
for (int i = 0; i < Q; i++) {
cin >> B >> C;
long long diff = C - B;
sum += bucket[B] * diff;
bucket[C] += bucket[B];
bucket[B] = 0;
cout << sum << "\n";
} // for
} // main
| replace | 9 | 10 | 9 | 10 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; // ↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w) {
return (y >= 0 && y < h && x >= 0 && x < w);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int ti = clock();
// start-----------------------------------------------
ll n;
cin >> n;
vi a(n, 0);
ll s = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
a[t - 1]++;
s += t;
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
s += (c - b) * a[b - 1];
a[c - 1] += a[b - 1];
a[b - 1] = 0;
cout << s << endl;
}
// end-----------------------------------------------
// cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}
| #include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; // ↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w) {
return (y >= 0 && y < h && x >= 0 && x < w);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int ti = clock();
// start-----------------------------------------------
ll n;
cin >> n;
vi a(100000, 0);
ll s = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
a[t - 1]++;
s += t;
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b, c;
cin >> b >> c;
s += (c - b) * a[b - 1];
a[c - 1] += a[b - 1];
a[b - 1] = 0;
cout << s << endl;
}
// end-----------------------------------------------
// cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}
| replace | 27 | 28 | 27 | 28 | 0 | |
p02630 | Python | Runtime Error | from sys import stdin
readline = stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
t = [0] * (N + 1)
s = sum(A)
for a in A:
t[a] += 1
for _ in range(Q):
B, C = map(int, readline().split())
s -= B * t[B]
s += C * t[B]
t[C] += t[B]
t[B] = 0
print(s)
| from sys import stdin
readline = stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
t = [0] * (10**5 + 1)
s = sum(A)
for a in A:
t[a] += 1
for _ in range(Q):
B, C = map(int, readline().split())
s -= B * t[B]
s += C * t[B]
t[C] += t[B]
t[B] = 0
print(s)
| replace | 8 | 9 | 8 | 9 | 0 | |
p02630 | C++ | Runtime Error | #include <iostream>
#include <map>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
map<int, ll> A;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
auto it = A.find(a);
if (it == A.end()) {
A.emplace(a, 1);
} else {
(it->second)++;
}
}
ll S = 0;
for (auto p : A) {
S += p.first * p.second;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
int B, C;
cin >> B >> C;
if (A.find(B) != A.end()) {
S += (C - B) * A.at(B);
A.at(C) += A.at(B);
A.erase(B);
}
cout << S << endl;
}
return 0;
}
| #include <iostream>
#include <map>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
map<int, ll> A;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
auto it = A.find(a);
if (it == A.end()) {
A.emplace(a, 1);
} else {
(it->second)++;
}
}
ll S = 0;
for (auto p : A) {
S += p.first * p.second;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
int B, C;
cin >> B >> C;
if (A.find(B) != A.end()) {
S += (C - B) * A.at(B);
if (A.find(C) == A.end()) {
A.emplace(C, A.at(B));
} else {
A.at(C) += A.at(B);
}
A.erase(B);
}
cout << S << endl;
}
return 0;
}
| replace | 30 | 31 | 30 | 35 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int q;
cin >> q;
vector<int> b(q);
vector<int> c(q);
for (int i = 0; i < q; i++) {
cin >> b[i] >> c[i];
}
vector<int> d(q);
for (int i = 0; i < q; i++) {
d[i] = c[i] - b[i];
}
sort(a.begin(), a.end());
vector<int> k(a[n - 1]);
for (int i = 0; i < n; i++) {
k[a[i] - 1]++;
}
long long s = 0;
for (int i = 0; i < n; i++) {
s += a[i];
}
for (int i = 0; i < q; i++) {
s += k[b[i] - 1] * d[i];
cout << s << endl;
k[c[i] - 1] += k[b[i] - 1];
k[b[i] - 1] = 0;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int q;
cin >> q;
vector<int> b(q);
vector<int> c(q);
for (int i = 0; i < q; i++) {
cin >> b[i] >> c[i];
}
vector<int> d(q);
for (int i = 0; i < q; i++) {
d[i] = c[i] - b[i];
}
sort(a.begin(), a.end());
vector<int> k(100000);
for (int i = 0; i < n; i++) {
k[a[i] - 1]++;
}
long long s = 0;
for (int i = 0; i < n; i++) {
s += a[i];
}
for (int i = 0; i < q; i++) {
s += k[b[i] - 1] * d[i];
cout << s << endl;
k[c[i] - 1] += k[b[i] - 1];
k[b[i] - 1] = 0;
}
}
| replace | 23 | 24 | 23 | 24 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
vector<ll> cnt(n);
ll ans = 0;
ll b[100010], c[100010];
ll q;
rep(i, n) {
cin >> a[i];
ans += a[i];
a[i]--;
cnt[a[i]]++;
}
cin >> q;
rep(i, q) cin >> b[i] >> c[i];
rep(i, q) {
ans += (c[i] - b[i]) * cnt[b[i] - 1];
cnt[c[i] - 1] += cnt[b[i] - 1];
cnt[b[i] - 1] = 0;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
vector<ll> a(n);
vector<ll> cnt(100010);
ll ans = 0;
ll b[100010], c[100010];
ll q;
rep(i, n) {
cin >> a[i];
ans += a[i];
a[i]--;
cnt[a[i]]++;
}
cin >> q;
rep(i, q) cin >> b[i] >> c[i];
rep(i, q) {
ans += (c[i] - b[i]) * cnt[b[i] - 1];
cnt[c[i] - 1] += cnt[b[i] - 1];
cnt[b[i] - 1] = 0;
cout << ans << endl;
}
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define read(n) scanf("%d", &n)
#define f(i, a, b) for (int i = a; i <= b; ++i)
#define N 100005
ll num[N];
int main() {
ll n, q, sum = 0;
read(n);
f(i, 1, n) {
ll x;
read(x);
++num[x];
sum += x;
}
read(q);
f(i, 1, q) {
ll x, y;
read(x);
read(y);
sum += (y - x) * (num[x]);
num[y] += num[x];
num[x] = 0;
cout << sum << endl;
}
return 0;
} | #include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define read(n) scanf("%lld", &n)
#define f(i, a, b) for (int i = a; i <= b; ++i)
#define N 100005
ll num[N];
int main() {
ll n, q, sum = 0;
read(n);
f(i, 1, n) {
ll x;
read(x);
++num[x];
sum += x;
}
read(q);
f(i, 1, q) {
ll x, y;
read(x);
read(y);
sum += (y - x) * (num[x]);
num[y] += num[x];
num[x] = 0;
cout << sum << endl;
}
return 0;
} | replace | 6 | 7 | 6 | 7 | -11 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1];
int b[10005];
long long ans = 0;
memset(b, 0, sizeof(b));
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[a[i]]++;
ans += a[i];
}
int q, be, af;
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> be >> af;
ans += (af - be) * b[be];
b[af] += b[be];
b[be] = 0;
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1];
int b[100005];
long long ans = 0;
memset(b, 0, sizeof(b));
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[a[i]]++;
ans += a[i];
}
int q, be, af;
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> be >> af;
ans += (af - be) * b[be];
b[af] += b[be];
b[be] = 0;
cout << ans << endl;
}
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02630 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++) // n回繰り返す
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= (int)n; i++) // i=1からi=nまで
#define RREP(i, n) for (int i = n; i >= 1; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
int main() {
int N, Q;
cin >> N;
vector<int> A(N + 1);
ll ans = 0;
map<int, int> cnt;
REP(i, N) {
cin >> A[i];
ans += A[i];
cnt[A[i]]++;
}
cin >> Q;
vector<int> B(N + 1);
vector<int> C(N + 1);
REP(i, Q) { cin >> B[i] >> C[i]; }
REP(i, Q) {
if (cnt[B[i]] != 0) {
ans += (C[i] - B[i]) * cnt[B[i]];
cnt[C[i]] += cnt[B[i]];
cnt[B[i]] = 0;
cout << ans << endl;
} else {
cout << ans << endl;
}
}
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++) // n回繰り返す
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= (int)n; i++) // i=1からi=nまで
#define RREP(i, n) for (int i = n; i >= 1; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
int main() {
int N, Q;
cin >> N;
vector<int> A(N + 1);
ll ans = 0;
map<int, int> cnt;
REP(i, N) {
cin >> A[i];
ans += A[i];
cnt[A[i]]++;
}
cin >> Q;
vector<int> B(Q + 1);
vector<int> C(Q + 1);
REP(i, Q) { cin >> B[i] >> C[i]; }
REP(i, Q) {
if (cnt[B[i]] != 0) {
ans += (C[i] - B[i]) * cnt[B[i]];
cnt[C[i]] += cnt[B[i]];
cnt[B[i]] = 0;
cout << ans << endl;
} else {
cout << ans << endl;
}
}
}
| replace | 51 | 53 | 51 | 53 | 0 | |
p02630 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long lint;
using namespace std;
lint gcd(lint x, lint y) {
if (x == 0) {
return y;
} else {
return gcd(y % x, x);
}
}
lint lcm(lint x, lint y) { return x / gcd(x, y) * y; }
lint C(lint n, lint k) {
if (n == k) {
return 1;
} else if (n < k) {
return 0;
} else if (k == 0) {
return 1;
} else if (k == 1) {
return n;
} else
return C(n - 1, k - 1) + C(n - 1, k);
}
lint P(lint n, lint k) {
if (k == 1) {
return n;
}
return (n * (P(n - 1, k - 1) % 1000000007) % 1000000007);
}
int main() {
lint n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
lint q;
cin >> q;
vector<lint> b(q), c(q);
for (int i = 0; i < q; i++) {
cin >> b[i] >> c[i];
}
lint sum = 0;
vector<lint> d(n, 0);
for (int i = 0; i < n; i++) {
sum += a[i];
d[a[i] - 1]++;
}
for (int i = 0; i < q; i++) {
sum += (c[i] - b[i]) * d[b[i] - 1];
d[c[i] - 1] += d[b[i] - 1];
d[b[i] - 1] = 0;
cout << sum << endl;
}
return 0;
}
| #include <bits/stdc++.h>
typedef long long lint;
using namespace std;
lint gcd(lint x, lint y) {
if (x == 0) {
return y;
} else {
return gcd(y % x, x);
}
}
lint lcm(lint x, lint y) { return x / gcd(x, y) * y; }
lint C(lint n, lint k) {
if (n == k) {
return 1;
} else if (n < k) {
return 0;
} else if (k == 0) {
return 1;
} else if (k == 1) {
return n;
} else
return C(n - 1, k - 1) + C(n - 1, k);
}
lint P(lint n, lint k) {
if (k == 1) {
return n;
}
return (n * (P(n - 1, k - 1) % 1000000007) % 1000000007);
}
int main() {
lint n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
lint q;
cin >> q;
vector<lint> b(q), c(q);
for (int i = 0; i < q; i++) {
cin >> b[i] >> c[i];
}
lint sum = 0;
vector<lint> d(100000, 0);
for (int i = 0; i < n; i++) {
sum += a[i];
d[a[i] - 1]++;
}
for (int i = 0; i < q; i++) {
sum += (c[i] - b[i]) * d[b[i] - 1];
d[c[i] - 1] += d[b[i] - 1];
d[b[i] - 1] = 0;
cout << sum << endl;
}
return 0;
}
| replace | 49 | 50 | 49 | 50 | 0 | |
p02630 | C++ | Runtime Error | // g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int mod = 1000000007;
const int inf = 1000000007;
int main() {
int n, q;
cin >> n;
vector<int> a(n);
vector<int> cnt(n + 1);
ll sum = 0;
rep(i, n) {
cin >> a[i];
cnt[a[i]]++;
sum += a[i];
}
cin >> q;
vector<ll> bc(q + 1);
for (int i = 1; i <= q; i++) {
int b, c;
cin >> b >> c;
bc[i] = (c - b) * cnt[b];
// cout << (c - b) * cnt[b] << '/';
cnt[c] += cnt[b];
cnt[b] = 0;
}
// cout << endl;
vector<ll> ans(q);
ans[0] = bc[1] + sum;
for (int i = 1; i < q; i++) {
ans[i] = ans[i - 1] + bc[i + 1];
}
rep(i, q) cout << ans[i] << endl;
}
| // g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int mod = 1000000007;
const int inf = 1000000007;
int main() {
int n, q;
cin >> n;
vector<int> a(n);
vector<int> cnt(100005);
ll sum = 0;
rep(i, n) {
cin >> a[i];
cnt[a[i]]++;
sum += a[i];
}
cin >> q;
vector<ll> bc(q + 1);
for (int i = 1; i <= q; i++) {
int b, c;
cin >> b >> c;
bc[i] = (c - b) * cnt[b];
// cout << (c - b) * cnt[b] << '/';
cnt[c] += cnt[b];
cnt[b] = 0;
}
// cout << endl;
vector<ll> ans(q);
ans[0] = bc[1] + sum;
for (int i = 1; i < q; i++) {
ans[i] = ans[i - 1] + bc[i + 1];
}
rep(i, q) cout << ans[i] << endl;
}
| replace | 15 | 16 | 15 | 16 | 0 | |
p02630 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i, a, b) for (ll i = a; i < b; i++)
using namespace std;
ll mex(ll a, ll b, ll m) {
if (b == 0)
return 1;
if (b % 2)
return a * mex((a * a) % m, (b - 1) / 2, m) % m;
else
return mex((a * a) % m, b / 2, m);
}
int x, y;
void exteu(ll a, ll m) {
if (m == 0) {
x = 1;
y = 0;
} else {
exteu(m, a % m);
ll temp = x;
x = y;
y = temp - (a / m) * y;
}
}
ll fact(ll n) {
ll prod = 1;
for (ll i = 2; i <= n; i++) {
prod *= i;
}
return prod;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
// bool isprime[100001];
// void makesieve() {
// memset(isprime, true, sizeof(isprime));
// for (int i = 2; i <= sqrt(200000); ++i)
// {
// if(isprime[i]) {
// for (int j = i*i; j <= 200000; j+=i)
// {
// isprime[j]=false;
// }
// }
// }
// }
//
// 1 2 4 5 8
void solve() {
ll n;
cin >> n;
ll s = 0;
vll hash(100001, 0);
vll a(n);
lp(i, 0, n) {
cin >> a[i];
s += a[i];
hash[a[i]]++;
}
ll q;
cin >> q;
while (q--) {
ll b, c;
cin >> b >> c;
while (hash[b]--) {
s -= b;
s += c;
hash[c]++;
}
cout << s << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll TESTS = 1;
// cin >> TESTS;
// makesieve();
while (TESTS--) {
solve();
}
return 0;
}
| #include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i, a, b) for (ll i = a; i < b; i++)
using namespace std;
ll mex(ll a, ll b, ll m) {
if (b == 0)
return 1;
if (b % 2)
return a * mex((a * a) % m, (b - 1) / 2, m) % m;
else
return mex((a * a) % m, b / 2, m);
}
int x, y;
void exteu(ll a, ll m) {
if (m == 0) {
x = 1;
y = 0;
} else {
exteu(m, a % m);
ll temp = x;
x = y;
y = temp - (a / m) * y;
}
}
ll fact(ll n) {
ll prod = 1;
for (ll i = 2; i <= n; i++) {
prod *= i;
}
return prod;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
// bool isprime[100001];
// void makesieve() {
// memset(isprime, true, sizeof(isprime));
// for (int i = 2; i <= sqrt(200000); ++i)
// {
// if(isprime[i]) {
// for (int j = i*i; j <= 200000; j+=i)
// {
// isprime[j]=false;
// }
// }
// }
// }
//
// 1 2 4 5 8
void solve() {
ll n;
cin >> n;
ll s = 0;
vll hash(100001, 0);
vll a(n);
lp(i, 0, n) {
cin >> a[i];
s += a[i];
hash[a[i]]++;
}
ll q;
cin >> q;
while (q--) {
ll b, c;
cin >> b >> c;
s -= hash[b] * b;
s += hash[b] * c;
hash[c] += hash[b];
hash[b] = 0;
cout << s << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll TESTS = 1;
// cin >> TESTS;
// makesieve();
while (TESTS--) {
solve();
}
return 0;
}
| replace | 85 | 90 | 85 | 89 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll; // 溢出会变成负值
typedef long double ldb;
typedef unsigned long long ull; // 自动取模2^64
const double pi = acos(-1.0);
const int mod = 1e9 + 7; // 998244353;
const int inf = 0x7fffffff; // 2^31-1
const ll INF = 0x7fffffffffffffff;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
// ll begin_time=clock(); ll end_time=clock(); cout<<"time =
// "<<end_time-begin_time<<" ms!"<<endl; bool operator < (const mmp &a)
// const{return x<a.x||x==a.x&&y<a.y;} //map<int,map<int,int> >z;
// map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d
// %d\n",it->first,it->second); ll poww(ll a,ll b){ll
// s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
// //快速幂取模 lower_bound(begin,end,num); 第一个>=num的数字
// upper_bound(begin,end,num); 第一个>num的数字 返回地址
// freopen("input.in","r",stdin); freopen("output.out","w",stdout);
// //文件读写提交 reverse(s.begin(),s.end()); //反转字符串 floor();
// 向下取整 ceil(); 向上取证
// 数轴上n个点移动到同一位置,移动到该组数字的中位数的总距离最短
bool isPrime(int n) {
if (n == 2 || n == 3)
return 1;
if (n % 6 != 1 && n % 6 != 5)
return 0;
int t = sqrt(n);
for (int i = 5; i <= t; i += 6)
if (n % i == 0 || n % (i + 2) == 0)
return 0;
return 1;
} // 判断素数
int x[100005];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll a, b, c, d, e, f, g, T;
// cin>>T;
// while(T--)
{
cin >> a;
b = 0;
for (int i = 0; i < a; i++) {
cin >> x[i];
b ^= x[i];
}
for (int i = 0; i < a - 1; i++) {
cout << ll(b ^ x[i]);
cout << " ";
}
cout << ll(b ^ x[a - 1]) << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll; // 溢出会变成负值
typedef long double ldb;
typedef unsigned long long ull; // 自动取模2^64
const double pi = acos(-1.0);
const int mod = 1e9 + 7; // 998244353;
const int inf = 0x7fffffff; // 2^31-1
const ll INF = 0x7fffffffffffffff;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
// ll begin_time=clock(); ll end_time=clock(); cout<<"time =
// "<<end_time-begin_time<<" ms!"<<endl; bool operator < (const mmp &a)
// const{return x<a.x||x==a.x&&y<a.y;} //map<int,map<int,int> >z;
// map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d
// %d\n",it->first,it->second); ll poww(ll a,ll b){ll
// s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
// //快速幂取模 lower_bound(begin,end,num); 第一个>=num的数字
// upper_bound(begin,end,num); 第一个>num的数字 返回地址
// freopen("input.in","r",stdin); freopen("output.out","w",stdout);
// //文件读写提交 reverse(s.begin(),s.end()); //反转字符串 floor();
// 向下取整 ceil(); 向上取证
// 数轴上n个点移动到同一位置,移动到该组数字的中位数的总距离最短
bool isPrime(int n) {
if (n == 2 || n == 3)
return 1;
if (n % 6 != 1 && n % 6 != 5)
return 0;
int t = sqrt(n);
for (int i = 5; i <= t; i += 6)
if (n % i == 0 || n % (i + 2) == 0)
return 0;
return 1;
} // 判断素数
int x[200005];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll a, b, c, d, e, f, g, T;
// cin>>T;
// while(T--)
{
cin >> a;
b = 0;
for (int i = 0; i < a; i++) {
cin >> x[i];
b ^= x[i];
}
for (int i = 0; i < a - 1; i++) {
cout << ll(b ^ x[i]);
cout << " ";
}
cout << ll(b ^ x[a - 1]) << endl;
}
}
| replace | 35 | 36 | 35 | 36 | 0 | |
p02631 | C++ | Runtime Error | #ifndef INCLUDEHEADER_MY_TEMPLATE
#define INCLUDEHEADER_MY_TEMPLATE
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define endl "\n"
#define PI acos(-1.0)
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#define stoll(argument_string) atoll((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define CIN5(x, y, z, w, u) cin >> (x) >> (y) >> (z) >> (w) >> (u)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCAND5(x, y, z, w, u) scanf("%d%d%d%d%d", &(x), &(y), &(z), &(w), &(u))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define SCANLLD5(x, y, z, w, u) \
scanf("%lld%lld%lld%lld%lld", &(x), &(y), &(z), &(w), &(u))
#define PRINTD(x) printf("%d\n", (x))
#define PRINTLLD(x) printf("%lld\n", (x))
#define DEBUG(argument) cerr << (#argument) << " : " << (argument) << "\n"
typedef long long lli;
typedef unsigned long long ulli;
using namespace std;
#endif // header
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int alphabet_pos(char c) {
if (c >= 'a' and c <= 'z') {
return (int)(c - 'a');
}
return -1;
}
int alphabet_pos_capital(char c) {
if (c >= 'A' and c <= 'Z') {
return (int)(c - 'A');
}
return -1;
}
vector<string> split(string str, char ch) {
int first = 0;
int last = str.find_first_of(ch);
if (last == string::npos) {
last = SIZ(str);
}
vector<string> result;
while (first < SIZ(str)) {
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if (last == string::npos) {
last = SIZ(str);
}
}
return result;
}
int gcd(int a, int b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (b == 0) {
return a;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
long long gcd(long long a, long long b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (b == 0LL) {
return a;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long lcm(long long a, long long b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long pow_fast(long long x, long long n_power, long long modulus) {
if (n_power == 0) {
return 1;
}
if (n_power % 2 == 0) {
return pow_fast(x * x % modulus, n_power / 2, modulus);
}
return x * pow_fast(x, n_power - 1, modulus) % modulus;
}
struct CombinationTable {
vector<vector<long long>> val;
CombinationTable(int size)
: val(size + 1, vector<long long>(size + 1)) // constructor
{
for (int i = 0; i <= size; ++i) // note that 0 <= i <= size
{
for (int j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
val[i][j] = 1LL;
} else {
val[i][j] = val[i - 1][j - 1] + val[i - 1][j];
}
}
}
}
};
void print_vector(vector<int> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%d", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_vector(vector<long long> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%lld", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_matrix2D(vector<vector<int>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%d", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<vector<long long>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%lld", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<string> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%c", h[i][j]);
} else {
cerr << h[i][j];
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
void print_binary(int val, int num_digit = 31, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%d", (val >> k) & 1);
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_binary(long long val, int num_digit = 63, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%lld", ((val >> k) & 1));
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_all() { cout << endl; }
void print_all_nobreak() { return; }
template <class Head, class... Tail>
void print_all_nobreak(Head head, Tail... tail) {
cout << head;
if (sizeof...(tail) != 0) {
cout << " ";
}
print_all_nobreak(forward<Tail>(tail)...);
}
template <class Head, class... Tail> void print_all(Head head, Tail... tail) {
cout << head;
if (sizeof...(tail) != 0) {
cout << " ";
}
print_all(forward<Tail>(tail)...);
}
template <class T> void print_all_nobreak(vector<T> vec) {
cout << "[";
for (int i = 0; i < vec.size(); i++) {
cout << vec[i];
if (i != ((int)vec.size() - 1)) {
cout << ", ";
}
}
cout << "]";
}
template <class T> void print_all(vector<T> vec) {
cout << "[";
for (int i = 0; i < vec.size(); i++) {
cout << vec[i];
if (i != ((int)vec.size() - 1)) {
cout << ", ";
}
}
cout << "]";
cout << endl;
}
template <class T> void print_all(vector<vector<T>> df) {
cout << "[";
for (int i = 0; i < df.size(); i++) {
print_all_nobreak(df[i]);
if (i != ((int)df.size() - 1)) {
cout << ", ";
}
}
cout << "]";
cout << endl;
}
template <class T> void print_all_nobreak(vector<vector<T>> df) {
cout << "[";
for (int i = 0; i < df.size(); i++) {
print_all_nobreak(df[i]);
if (i != ((int)df.size() - 1)) {
cout << ", ";
}
}
cout << "]";
}
template <class T1, class T2> void print_all_nobreak(pair<T1, T2> p) {
cout << "(";
print_all_nobreak(p.first);
cout << ", ";
print_all_nobreak(p.second);
cout << ")";
}
template <class T1, class T2> void print_all(pair<T1, T2> p) {
cout << "(";
print_all_nobreak(p.first);
cout << ", ";
print_all_nobreak(p.second);
cout << ")";
cout << endl;
}
struct UnionFind // size-based
{
vector<int> parent, treesize;
UnionFind(int size)
: parent(size), treesize(size, 1) // constructor
{
for (int i = 0; i < size; ++i) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) {
return x;
}
return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y) {
return;
}
if (treesize[x] < treesize[y]) {
parent[x] = y;
treesize[y] += treesize[x];
} else {
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree(int x, int y) { return root(x) == root(y); }
int gettreesize(int x) { return treesize[root(x)]; }
};
template <typename Type_value>
struct SegmentTree // Range Minimum Query (RMQ)
{
private:
int n;
vector<Type_value> node;
Type_value identity_element_segmenttree;
public:
SegmentTree(vector<Type_value> v,
Type_value identity_element_st) // constructor
{
int sz = v.size();
identity_element_segmenttree = identity_element_st;
n = 1;
while (n < sz) {
n <<= 1;
}
node.resize(2 * n - 1, identity_element_segmenttree);
for (int i = 0; i < sz; ++i) {
node[i + n - 1] = v[i];
}
for (int i = n - 2; i >= 0; --i) {
node[i] = min(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int x, Type_value val) {
x += (n - 1);
node[x] = val;
while (x > 0) {
x = (x - 1) / 2;
node[x] = min(node[2 * x + 1], node[2 * x + 2]);
}
}
Type_value getmin(int a, int b, int k = 0, int l = 0,
int r = -1) // getting minimum value in [a,b)
{
// k : index of the referred node
// [l,r) : range covered by the k-th node
if (r < 0) {
r = n;
}
if (r <= a or b <= l) {
return identity_element_segmenttree;
}
if (a <= l and r <= b) {
return node[k];
}
Type_value vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
Type_value vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
return min(vl, vr);
}
};
template <typename Type_value>
struct BinaryIndexedTree // Range Sum Query (RSQ), 0-indexed
{
private:
int size_;
vector<Type_value> data;
public:
BinaryIndexedTree(int sz, Type_value identity_element_binaryindexedtree =
0.0) // constructor
{
size_ = sz;
data.resize(sz + 1, identity_element_binaryindexedtree);
}
Type_value sum(int i) // sum within [0,i)
{
if (i <= 0) {
return (Type_value)0.0;
}
if (i > size_) {
i = size_;
}
Type_value sm = 0.0;
while (i > 0) {
sm += data[i];
i -= i & -i;
}
return sm;
}
void add(int i, Type_value x) {
if (i < 0 or i >= size_) {
return;
}
++i;
while (i <= size_) {
data[i] += x;
i += i & -i;
}
}
};
struct RollingHash {
/*
10 primes near 1e9(for other mod(s)):
{
1000000007,
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000123,
1000000181
}
10 primes near 1e5(for other base(s)):
{100003,
100019,
100043,
100049,
100057,
100069,
100103,
100109,
100129,
100151}
*/
private:
vector<unsigned long long> hash;
vector<unsigned long long> base_pow;
unsigned long long base, modulus;
const unsigned long long MODULUS_DEFAULT = (1ULL << 61) - 1;
const unsigned long long MASK30 = (1ULL << 30) - 1;
const unsigned long long MASK31 = (1ULL << 31) - 1;
const unsigned long long BASE_MIN = 1e7;
unsigned long long Modulus_2pow61m1(unsigned long long val) {
val = (val & MODULUS_DEFAULT) + (val >> 61);
if (MODULUS_DEFAULT < val) {
val -= MODULUS_DEFAULT;
}
return val;
}
unsigned long long Multiple_2pow61m1(unsigned long long a,
unsigned long long b) {
unsigned long long au = a >> 31;
unsigned long long ad = a & MASK31;
unsigned long long bu = b >> 31;
unsigned long long bd = b & MASK31;
unsigned long long mid = ad * bu + au * bd;
unsigned long long midu = mid >> 30;
unsigned long long midd = mid & MASK30;
return Modulus_2pow61m1(((au * bu) << 1) + midu + (midd << 31) + ad * bd);
}
void initialize(string &S) {
int N = S.size();
vector<int> s(N);
for (int i = 0; i < N; ++i) {
s[i] = S[i];
}
initialize(s);
}
void initialize(vector<int> &S) {
hash.resize(S.size() + 1);
base_pow.resize(S.size() + 1);
hash[0] = 0;
base_pow[0] = 1;
if (modulus == MODULUS_DEFAULT) {
for (int i = 1; i <= S.size(); ++i) {
hash[i] =
Modulus_2pow61m1(Multiple_2pow61m1(hash[i - 1], base) + S[i - 1]);
base_pow[i] = Multiple_2pow61m1(base_pow[i - 1], base);
}
} else {
for (int i = 1; i <= S.size(); ++i) {
hash[i] = (hash[i - 1] * base + S[i - 1]) % modulus;
base_pow[i] = (base_pow[i - 1] * base) % modulus;
}
}
}
public:
RollingHash(string S = "", unsigned long long base_ = 0,
unsigned long long modulus_ = 0) {
if (0 < modulus_) {
modulus = modulus_;
} else {
modulus = MODULUS_DEFAULT;
}
if (0 < base_) {
base = base_;
} else {
mt19937_64 mt64(static_cast<unsigned int>(time(nullptr)));
uniform_int_distribution<unsigned long long> rand_uniform(
BASE_MIN, modulus - BASE_MIN);
base = rand_uniform(mt64);
}
if (S.size() > 0) {
initialize(S);
}
}
// 0-indexed, [a, b)
unsigned long long between(int a, int b) {
if (modulus == MODULUS_DEFAULT) {
return Modulus_2pow61m1(modulus + hash[b] -
Multiple_2pow61m1(hash[a], base_pow[b - a]));
}
return (modulus + hash[b] - (hash[a] * base_pow[b - a]) % modulus) %
modulus;
}
};
struct TrieTree {
private:
char chara_origin;
int numtypes_ch;
struct TrieNode {
public:
TrieNode **children;
bool isLeaf;
};
TrieNode *newNode() {
TrieNode *pNode = new TrieNode;
pNode->children = new TrieNode *[numtypes_ch];
pNode->isLeaf = false;
for (int i = 0; i < numtypes_ch; i++) {
pNode->children[i] = nullptr;
}
return pNode;
}
TrieNode *treeroot;
public:
TrieTree(int number_of_types_of_character = 26, char character_origin = 'a') {
numtypes_ch = number_of_types_of_character;
chara_origin = character_origin;
treeroot = newNode();
}
void insert(string key) {
TrieNode *pCrawl = treeroot;
for (int i = 0; i < key.size(); i++) {
int index = key[i] - chara_origin;
if (pCrawl->children[index] == nullptr) {
pCrawl->children[index] = newNode();
}
pCrawl = pCrawl->children[index];
}
// mark last node as leaf
pCrawl->isLeaf = true;
}
bool search(string key) {
TrieNode *pCrawl = treeroot;
for (int i = 0; i < key.size(); i++) {
int index = key[i] - chara_origin;
if (pCrawl->children[index] == nullptr) {
return false;
}
pCrawl = pCrawl->children[index];
}
return (pCrawl != nullptr and pCrawl->isLeaf);
}
};
/*------------------ the end of the template -----------------------*/
// global variables
int N;
vector<int> a;
vector<int> expected;
void give_inputs(int state_debug) {
if (state_debug == 0) {
// standard I/O
cin.tie(0);
ios::sync_with_stdio(false); /* making cin faster */
SCAND(N);
REP(i, N) { SCAND(a[i]); }
} else if (state_debug == 1) {
// testcase 1
} else if (state_debug == 2) {
// testcase 2
} else if (state_debug == 3) {
// testcase 3
}
}
vector<int> solve() // ここに処理を書く。型はansに合わせる。
{
int allxor = 0;
REP(i, N) { allxor ^= a[i]; }
vector<int> b(N);
REP(i, N) { b[i] = allxor ^ a[i]; }
return b;
}
signed main(signed argc, char *argv[]) {
if (argc == 1) {
give_inputs(0);
} else {
give_inputs(stoi(string(argv[1])));
}
auto ans = solve();
/*
print here!!!
*/
print_vector(ans);
// confirm expected == ans
if (argc != 1 and 0 < stoi(string(argv[1])) and expected != ans) {
puts("[WA]");
puts("expected: ");
print_all(expected);
puts("found: ");
print_all(ans);
}
}
| #ifndef INCLUDEHEADER_MY_TEMPLATE
#define INCLUDEHEADER_MY_TEMPLATE
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define endl "\n"
#define PI acos(-1.0)
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#define stoll(argument_string) atoll((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define CIN5(x, y, z, w, u) cin >> (x) >> (y) >> (z) >> (w) >> (u)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCAND5(x, y, z, w, u) scanf("%d%d%d%d%d", &(x), &(y), &(z), &(w), &(u))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define SCANLLD5(x, y, z, w, u) \
scanf("%lld%lld%lld%lld%lld", &(x), &(y), &(z), &(w), &(u))
#define PRINTD(x) printf("%d\n", (x))
#define PRINTLLD(x) printf("%lld\n", (x))
#define DEBUG(argument) cerr << (#argument) << " : " << (argument) << "\n"
typedef long long lli;
typedef unsigned long long ulli;
using namespace std;
#endif // header
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int alphabet_pos(char c) {
if (c >= 'a' and c <= 'z') {
return (int)(c - 'a');
}
return -1;
}
int alphabet_pos_capital(char c) {
if (c >= 'A' and c <= 'Z') {
return (int)(c - 'A');
}
return -1;
}
vector<string> split(string str, char ch) {
int first = 0;
int last = str.find_first_of(ch);
if (last == string::npos) {
last = SIZ(str);
}
vector<string> result;
while (first < SIZ(str)) {
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if (last == string::npos) {
last = SIZ(str);
}
}
return result;
}
int gcd(int a, int b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (b == 0) {
return a;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
long long gcd(long long a, long long b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (b == 0LL) {
return a;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long lcm(long long a, long long b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long pow_fast(long long x, long long n_power, long long modulus) {
if (n_power == 0) {
return 1;
}
if (n_power % 2 == 0) {
return pow_fast(x * x % modulus, n_power / 2, modulus);
}
return x * pow_fast(x, n_power - 1, modulus) % modulus;
}
struct CombinationTable {
vector<vector<long long>> val;
CombinationTable(int size)
: val(size + 1, vector<long long>(size + 1)) // constructor
{
for (int i = 0; i <= size; ++i) // note that 0 <= i <= size
{
for (int j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
val[i][j] = 1LL;
} else {
val[i][j] = val[i - 1][j - 1] + val[i - 1][j];
}
}
}
}
};
void print_vector(vector<int> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%d", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_vector(vector<long long> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%lld", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_matrix2D(vector<vector<int>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%d", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<vector<long long>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%lld", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<string> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%c", h[i][j]);
} else {
cerr << h[i][j];
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
void print_binary(int val, int num_digit = 31, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%d", (val >> k) & 1);
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_binary(long long val, int num_digit = 63, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%lld", ((val >> k) & 1));
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_all() { cout << endl; }
void print_all_nobreak() { return; }
template <class Head, class... Tail>
void print_all_nobreak(Head head, Tail... tail) {
cout << head;
if (sizeof...(tail) != 0) {
cout << " ";
}
print_all_nobreak(forward<Tail>(tail)...);
}
template <class Head, class... Tail> void print_all(Head head, Tail... tail) {
cout << head;
if (sizeof...(tail) != 0) {
cout << " ";
}
print_all(forward<Tail>(tail)...);
}
template <class T> void print_all_nobreak(vector<T> vec) {
cout << "[";
for (int i = 0; i < vec.size(); i++) {
cout << vec[i];
if (i != ((int)vec.size() - 1)) {
cout << ", ";
}
}
cout << "]";
}
template <class T> void print_all(vector<T> vec) {
cout << "[";
for (int i = 0; i < vec.size(); i++) {
cout << vec[i];
if (i != ((int)vec.size() - 1)) {
cout << ", ";
}
}
cout << "]";
cout << endl;
}
template <class T> void print_all(vector<vector<T>> df) {
cout << "[";
for (int i = 0; i < df.size(); i++) {
print_all_nobreak(df[i]);
if (i != ((int)df.size() - 1)) {
cout << ", ";
}
}
cout << "]";
cout << endl;
}
template <class T> void print_all_nobreak(vector<vector<T>> df) {
cout << "[";
for (int i = 0; i < df.size(); i++) {
print_all_nobreak(df[i]);
if (i != ((int)df.size() - 1)) {
cout << ", ";
}
}
cout << "]";
}
template <class T1, class T2> void print_all_nobreak(pair<T1, T2> p) {
cout << "(";
print_all_nobreak(p.first);
cout << ", ";
print_all_nobreak(p.second);
cout << ")";
}
template <class T1, class T2> void print_all(pair<T1, T2> p) {
cout << "(";
print_all_nobreak(p.first);
cout << ", ";
print_all_nobreak(p.second);
cout << ")";
cout << endl;
}
struct UnionFind // size-based
{
vector<int> parent, treesize;
UnionFind(int size)
: parent(size), treesize(size, 1) // constructor
{
for (int i = 0; i < size; ++i) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) {
return x;
}
return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y) {
return;
}
if (treesize[x] < treesize[y]) {
parent[x] = y;
treesize[y] += treesize[x];
} else {
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree(int x, int y) { return root(x) == root(y); }
int gettreesize(int x) { return treesize[root(x)]; }
};
template <typename Type_value>
struct SegmentTree // Range Minimum Query (RMQ)
{
private:
int n;
vector<Type_value> node;
Type_value identity_element_segmenttree;
public:
SegmentTree(vector<Type_value> v,
Type_value identity_element_st) // constructor
{
int sz = v.size();
identity_element_segmenttree = identity_element_st;
n = 1;
while (n < sz) {
n <<= 1;
}
node.resize(2 * n - 1, identity_element_segmenttree);
for (int i = 0; i < sz; ++i) {
node[i + n - 1] = v[i];
}
for (int i = n - 2; i >= 0; --i) {
node[i] = min(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int x, Type_value val) {
x += (n - 1);
node[x] = val;
while (x > 0) {
x = (x - 1) / 2;
node[x] = min(node[2 * x + 1], node[2 * x + 2]);
}
}
Type_value getmin(int a, int b, int k = 0, int l = 0,
int r = -1) // getting minimum value in [a,b)
{
// k : index of the referred node
// [l,r) : range covered by the k-th node
if (r < 0) {
r = n;
}
if (r <= a or b <= l) {
return identity_element_segmenttree;
}
if (a <= l and r <= b) {
return node[k];
}
Type_value vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
Type_value vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
return min(vl, vr);
}
};
template <typename Type_value>
struct BinaryIndexedTree // Range Sum Query (RSQ), 0-indexed
{
private:
int size_;
vector<Type_value> data;
public:
BinaryIndexedTree(int sz, Type_value identity_element_binaryindexedtree =
0.0) // constructor
{
size_ = sz;
data.resize(sz + 1, identity_element_binaryindexedtree);
}
Type_value sum(int i) // sum within [0,i)
{
if (i <= 0) {
return (Type_value)0.0;
}
if (i > size_) {
i = size_;
}
Type_value sm = 0.0;
while (i > 0) {
sm += data[i];
i -= i & -i;
}
return sm;
}
void add(int i, Type_value x) {
if (i < 0 or i >= size_) {
return;
}
++i;
while (i <= size_) {
data[i] += x;
i += i & -i;
}
}
};
struct RollingHash {
/*
10 primes near 1e9(for other mod(s)):
{
1000000007,
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000123,
1000000181
}
10 primes near 1e5(for other base(s)):
{100003,
100019,
100043,
100049,
100057,
100069,
100103,
100109,
100129,
100151}
*/
private:
vector<unsigned long long> hash;
vector<unsigned long long> base_pow;
unsigned long long base, modulus;
const unsigned long long MODULUS_DEFAULT = (1ULL << 61) - 1;
const unsigned long long MASK30 = (1ULL << 30) - 1;
const unsigned long long MASK31 = (1ULL << 31) - 1;
const unsigned long long BASE_MIN = 1e7;
unsigned long long Modulus_2pow61m1(unsigned long long val) {
val = (val & MODULUS_DEFAULT) + (val >> 61);
if (MODULUS_DEFAULT < val) {
val -= MODULUS_DEFAULT;
}
return val;
}
unsigned long long Multiple_2pow61m1(unsigned long long a,
unsigned long long b) {
unsigned long long au = a >> 31;
unsigned long long ad = a & MASK31;
unsigned long long bu = b >> 31;
unsigned long long bd = b & MASK31;
unsigned long long mid = ad * bu + au * bd;
unsigned long long midu = mid >> 30;
unsigned long long midd = mid & MASK30;
return Modulus_2pow61m1(((au * bu) << 1) + midu + (midd << 31) + ad * bd);
}
void initialize(string &S) {
int N = S.size();
vector<int> s(N);
for (int i = 0; i < N; ++i) {
s[i] = S[i];
}
initialize(s);
}
void initialize(vector<int> &S) {
hash.resize(S.size() + 1);
base_pow.resize(S.size() + 1);
hash[0] = 0;
base_pow[0] = 1;
if (modulus == MODULUS_DEFAULT) {
for (int i = 1; i <= S.size(); ++i) {
hash[i] =
Modulus_2pow61m1(Multiple_2pow61m1(hash[i - 1], base) + S[i - 1]);
base_pow[i] = Multiple_2pow61m1(base_pow[i - 1], base);
}
} else {
for (int i = 1; i <= S.size(); ++i) {
hash[i] = (hash[i - 1] * base + S[i - 1]) % modulus;
base_pow[i] = (base_pow[i - 1] * base) % modulus;
}
}
}
public:
RollingHash(string S = "", unsigned long long base_ = 0,
unsigned long long modulus_ = 0) {
if (0 < modulus_) {
modulus = modulus_;
} else {
modulus = MODULUS_DEFAULT;
}
if (0 < base_) {
base = base_;
} else {
mt19937_64 mt64(static_cast<unsigned int>(time(nullptr)));
uniform_int_distribution<unsigned long long> rand_uniform(
BASE_MIN, modulus - BASE_MIN);
base = rand_uniform(mt64);
}
if (S.size() > 0) {
initialize(S);
}
}
// 0-indexed, [a, b)
unsigned long long between(int a, int b) {
if (modulus == MODULUS_DEFAULT) {
return Modulus_2pow61m1(modulus + hash[b] -
Multiple_2pow61m1(hash[a], base_pow[b - a]));
}
return (modulus + hash[b] - (hash[a] * base_pow[b - a]) % modulus) %
modulus;
}
};
struct TrieTree {
private:
char chara_origin;
int numtypes_ch;
struct TrieNode {
public:
TrieNode **children;
bool isLeaf;
};
TrieNode *newNode() {
TrieNode *pNode = new TrieNode;
pNode->children = new TrieNode *[numtypes_ch];
pNode->isLeaf = false;
for (int i = 0; i < numtypes_ch; i++) {
pNode->children[i] = nullptr;
}
return pNode;
}
TrieNode *treeroot;
public:
TrieTree(int number_of_types_of_character = 26, char character_origin = 'a') {
numtypes_ch = number_of_types_of_character;
chara_origin = character_origin;
treeroot = newNode();
}
void insert(string key) {
TrieNode *pCrawl = treeroot;
for (int i = 0; i < key.size(); i++) {
int index = key[i] - chara_origin;
if (pCrawl->children[index] == nullptr) {
pCrawl->children[index] = newNode();
}
pCrawl = pCrawl->children[index];
}
// mark last node as leaf
pCrawl->isLeaf = true;
}
bool search(string key) {
TrieNode *pCrawl = treeroot;
for (int i = 0; i < key.size(); i++) {
int index = key[i] - chara_origin;
if (pCrawl->children[index] == nullptr) {
return false;
}
pCrawl = pCrawl->children[index];
}
return (pCrawl != nullptr and pCrawl->isLeaf);
}
};
/*------------------ the end of the template -----------------------*/
// global variables
int N;
vector<int> a;
vector<int> expected;
void give_inputs(int state_debug) {
if (state_debug == 0) {
// standard I/O
cin.tie(0);
ios::sync_with_stdio(false); /* making cin faster */
SCAND(N);
a.resize(N);
REP(i, N) { SCAND(a[i]); }
} else if (state_debug == 1) {
// testcase 1
} else if (state_debug == 2) {
// testcase 2
} else if (state_debug == 3) {
// testcase 3
}
}
vector<int> solve() // ここに処理を書く。型はansに合わせる。
{
int allxor = 0;
REP(i, N) { allxor ^= a[i]; }
vector<int> b(N);
REP(i, N) { b[i] = allxor ^ a[i]; }
return b;
}
signed main(signed argc, char *argv[]) {
if (argc == 1) {
give_inputs(0);
} else {
give_inputs(stoi(string(argv[1])));
}
auto ans = solve();
/*
print here!!!
*/
print_vector(ans);
// confirm expected == ans
if (argc != 1 and 0 < stoi(string(argv[1])) and expected != ans) {
puts("[WA]");
puts("expected: ");
print_all(expected);
puts("found: ");
print_all(ans);
}
}
| insert | 865 | 865 | 865 | 866 | -11 | |
p02631 | C++ | Runtime Error | // SMOKE SHISHA PLAY FIFA //
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
ll modu(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b & 1)
ans = (ans * a) % mod;
b /= 2;
a = (a * a) % mod;
}
return ans;
}
int main() {
fastio ll n;
ll a[n];
ll al;
cin >> a[0] >> a[1];
al = a[0] ^ a[1];
lp(i, 2, n - 1) {
cin >> a[i];
al = al ^ a[i];
}
for (ll i = 0; i < n; i++)
cout << (al ^ a[i]) << " ";
cout << endl;
return 0;
}
| // SMOKE SHISHA PLAY FIFA //
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c) \
cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
ll modu(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b & 1)
ans = (ans * a) % mod;
b /= 2;
a = (a * a) % mod;
}
return ans;
}
int main() {
fastio ll n;
cin >> n;
ll a[n];
ll al;
cin >> a[0] >> a[1];
al = a[0] ^ a[1];
lp(i, 2, n - 1) {
cin >> a[i];
al = al ^ a[i];
}
for (ll i = 0; i < n; i++)
cout << (al ^ a[i]) << " ";
cout << endl;
return 0;
}
| insert | 37 | 37 | 37 | 38 | -11 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN = 301;
const int MAXK = 19;
const int INF = 1e9;
const ll MOD = 998244353;
ll N, a, b, c, d, e, f;
ll A[MAXN];
ll B[MAXN];
int main() {
cin >> N;
ll T = 0;
for (int i = 1; i <= N; ++i) {
cin >> A[i];
T ^= A[i];
}
for (int i = 1; i <= N; ++i)
cout << (T ^ A[i]) << ' ';
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN = 200100;
const int MAXK = 19;
const int INF = 1e9;
const ll MOD = 998244353;
ll N, a, b, c, d, e, f;
ll A[MAXN];
ll B[MAXN];
int main() {
cin >> N;
ll T = 0;
for (int i = 1; i <= N; ++i) {
cin >> A[i];
T ^= A[i];
}
for (int i = 1; i <= N; ++i)
cout << (T ^ A[i]) << ' ';
} | replace | 15 | 16 | 15 | 16 | 0 | |
p02631 | Python | Time Limit Exceeded | n = int(input())
a = [int(i) for i in input().split()]
ans = []
for i in range(n):
temp = 0
for j, aa in enumerate(a):
if j == i:
continue
temp = temp ^ aa
ans.append(temp)
ans = [str(i) for i in ans]
print(" ".join(ans))
| n = int(input())
a = [int(i) for i in input().split()]
ans = []
alld = 0
for aa in a:
alld = alld ^ aa
for aa in a:
ans.append(alld ^ aa)
ans = [str(i) for i in ans]
print(" ".join(ans))
| replace | 5 | 12 | 5 | 12 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPR(i, x, n) for (int i = n - 1; i >= x; i--)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout << endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef tuple<ll, ll, ll, ll> PPP;
const ll mod = 1000000007;
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outp(T a) {
cout << '(' << a.fi << ',' << a.se << ')' << '\n';
}
template <class T> void outvp(T v) {
rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')';
cout << '\n';
}
template <class T> void outvvp(T v) { rep(i, v.size()) outvp(v[i]); }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); }
template <class T> void yes(T b) {
if (b)
out("yes");
else
out("no");
}
template <class T> void Yes(T b) {
if (b)
out("Yes");
else
out("No");
}
template <class T> void YES(T b) {
if (b)
out("YES");
else
out("NO");
}
template <class T> void no(T b) {
if (b)
out("no");
else
out("yes");
}
template <class T> void No(T b) {
if (b)
out("No");
else
out("Yes");
}
template <class T> void NO(T b) {
if (b)
out("NO");
else
out("YES");
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll modpow(ll a, ll b) {
ll res = 1;
a %= mod;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
int main() {
ll n;
cin >> n;
ll ans[101010] = {};
ll a[101010] = {};
ll xo = 0;
rep(i, n) {
cin >> a[i];
xo = xo ^ a[i];
// cout<<xo;
}
rep(i, n) { cout << (a[i] ^ xo) << " "; }
// cout<<(0^20)<<endl;
EN;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPR(i, x, n) for (int i = n - 1; i >= x; i--)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout << endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef tuple<ll, ll, ll, ll> PPP;
const ll mod = 1000000007;
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outp(T a) {
cout << '(' << a.fi << ',' << a.se << ')' << '\n';
}
template <class T> void outvp(T v) {
rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')';
cout << '\n';
}
template <class T> void outvvp(T v) { rep(i, v.size()) outvp(v[i]); }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); }
template <class T> void yes(T b) {
if (b)
out("yes");
else
out("no");
}
template <class T> void Yes(T b) {
if (b)
out("Yes");
else
out("No");
}
template <class T> void YES(T b) {
if (b)
out("YES");
else
out("NO");
}
template <class T> void no(T b) {
if (b)
out("no");
else
out("yes");
}
template <class T> void No(T b) {
if (b)
out("No");
else
out("Yes");
}
template <class T> void NO(T b) {
if (b)
out("NO");
else
out("YES");
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll modpow(ll a, ll b) {
ll res = 1;
a %= mod;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
int main() {
ll n;
cin >> n;
ll ans[201010] = {};
ll a[201010] = {};
ll xo = 0;
rep(i, n) {
cin >> a[i];
xo = xo ^ a[i];
// cout<<xo;
}
rep(i, n) { cout << (a[i] ^ xo) << " "; }
// cout<<(0^20)<<endl;
EN;
}
| replace | 96 | 98 | 96 | 98 | 0 | |
p02631 | C++ | Runtime Error |
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) \
freopen(x ".in", "r", stdin); \
freopen(x ".out", "w", stdout)
#define int long long
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
inline int gi() {
int f = 1, x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = x * 10 + c - '0', c = getchar();
return f * x;
}
inline LL gl() {
LL f = 1, x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = x * 10 + c - '0', c = getchar();
return f * x;
}
const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;
int n, m;
int a[N];
signed main() {
// File("");
n = gi();
int sum = 0;
for (int i = 1; i <= n; i += 1)
a[i] = gi(), sum ^= a[i];
for (int i = 1; i <= n; i += 1)
cout << (sum ^ a[i]) << ' ';
return 0;
} |
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) \
freopen(x ".in", "r", stdin); \
freopen(x ".out", "w", stdout)
#define int long long
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
inline int gi() {
int f = 1, x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = x * 10 + c - '0', c = getchar();
return f * x;
}
inline LL gl() {
LL f = 1, x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = x * 10 + c - '0', c = getchar();
return f * x;
}
const int INF = 0x3f3f3f3f, N = 1000003, M = N << 1;
int n, m;
int a[N];
signed main() {
// File("");
n = gi();
int sum = 0;
for (int i = 1; i <= n; i += 1)
a[i] = gi(), sum ^= a[i];
for (int i = 1; i <= n; i += 1)
cout << (sum ^ a[i]) << ' ';
return 0;
} | replace | 48 | 49 | 48 | 49 | 0 | |
p02631 | Python | Time Limit Exceeded | import numpy as np
N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
# b = np.bitwise_xor.reduce(a)
# c = np.bitwise_xor(a, b)
# print(*c, sep=" ")
for n in range(N):
print(np.bitwise_xor.reduce(a) ^ a[n])
| import numpy as np
N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
b = np.bitwise_xor.reduce(a)
c = np.bitwise_xor(a, b)
print(*c, sep=" ")
| replace | 4 | 9 | 4 | 7 | TLE | |
p02631 | C++ | Runtime Error | // Apparat : drobucs, aleonov, vit_72
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
// #pragma warning(disable : 4996)
// #pragma GCC optimize("O3")
using namespace std;
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs \
ios_base::sync_with_stdio(0); \
cout.tie(0); \
cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()
typedef long long ll;
const int maxn = (int)1e5 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7,
MOD2 = 998244353; // 1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
int a[maxn];
int main() {
drobucs;
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
int xr = 0;
for (int i = 1; i <= n; ++i)
xr ^= a[i];
for (int i = 1; i <= n; ++i)
cout << (xr ^ a[i]) << " ";
return 0;
} | // Apparat : drobucs, aleonov, vit_72
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
// #pragma warning(disable : 4996)
// #pragma GCC optimize("O3")
using namespace std;
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs \
ios_base::sync_with_stdio(0); \
cout.tie(0); \
cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()
typedef long long ll;
const int maxn = (int)2e5 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7,
MOD2 = 998244353; // 1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
int a[maxn];
int main() {
drobucs;
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
int xr = 0;
for (int i = 1; i <= n; ++i)
xr ^= a[i];
for (int i = 1; i <= n; ++i)
cout << (xr ^ a[i]) << " ";
return 0;
} | replace | 31 | 32 | 31 | 32 | 0 | |
p02631 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <vector>
#define ll long long
#define N 100005
#define inf 1000000000
using namespace std;
int n;
int a[N], c[N];
int q;
int main() {
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]), sum ^= a[i];
for (int i = 1; i <= n; ++i)
printf("%d ", a[i] ^ sum);
return 0;
} | #include <algorithm>
#include <cstdio>
#include <vector>
#define ll long long
#define N 200005
#define inf 1000000000
using namespace std;
int n;
int a[N], c[N];
int q;
int main() {
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]), sum ^= a[i];
for (int i = 1; i <= n; ++i)
printf("%d ", a[i] ^ sum);
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02631 | C++ | Runtime Error | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
int a[100000];
int s = 0;
cin >> n;
rep(i, n) {
cin >> a[i];
s ^= a[i];
}
rep(i, n) {
cout << (s ^ a[i]);
if (i != n - 1) {
cout << " ";
} else {
cout << endl;
}
}
} | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
int a[200000];
int s = 0;
cin >> n;
rep(i, n) {
cin >> a[i];
s ^= a[i];
}
rep(i, n) {
cout << (s ^ a[i]);
if (i != n - 1) {
cout << " ";
} else {
cout << endl;
}
}
} | replace | 10 | 11 | 10 | 11 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define mod 1000000007
int solve(int A[], int n) {
int i;
int B[n];
int x = 0;
for (i = 0; i < n; i++)
x = x ^ A[i];
for (i = 0; i < n; i++) {
B[i] = x ^ A[i];
}
for (i = 0; i < n; i++)
cout << B[i] << " ";
cout << endl;
}
int32_t main() {
// code
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t, n, w, k, x, i;
// cin>>t;
t = 1;
while (t--) {
cin >> n;
int A[n];
for (i = 0; i < n; i++)
cin >> A[i];
solve(A, n);
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define mod 1000000007
void solve(int A[], int n) {
int i;
int B[n];
int x = 0;
for (i = 0; i < n; i++)
x = x ^ A[i];
for (i = 0; i < n; i++) {
B[i] = x ^ A[i];
}
for (i = 0; i < n; i++)
cout << B[i] << " ";
cout << endl;
}
int32_t main() {
// code
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t, n, w, k, x, i;
// cin>>t;
t = 1;
while (t--) {
cin >> n;
int A[n];
for (i = 0; i < n; i++)
cin >> A[i];
solve(A, n);
}
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;
// グローバル変数(入力)
ll n;
vll a;
void input() {
cin >> n;
rep(i, n) {
ll A;
cin >> A;
a.push_back(A);
}
}
void solve() {
ll M = 0;
rep(i, n) { M = max(M, a[i]); }
ll m = (ll)floor(log2((ld)M)) + 1;
vvll b(n, vll(m));
rep(i, n) {
for (ll j = m - 1; j >= 0; j--) {
b[i][j] = a[i] % 2;
a[i] /= 2;
}
}
/*
rep(i,n){
rep(j,m){
cout << b[i][j] << " ";
}
cout << endl;
}
*/
vll c(m, 0);
rep(j, m) {
rep(i, n) { c[j] += b[i][j]; }
// cout << c[j] << " ";
}
rep(j, m) {
if (c[j] % 2 == 1) {
rep(i, n) { b[i][j] = (b[i][j] + 1) % 2; }
}
}
rep(i, n) {
ll s = 0;
rep(j, m) { s += (ll)pow(2, m - j - 1) * b[i][j]; }
cout << s;
if (i != n - 1) {
cout << " ";
} else {
cout << endl;
}
}
}
int main() {
input();
solve();
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;
// グローバル変数(入力)
ll n;
vll a;
void input() {
cin >> n;
rep(i, n) {
ll A;
cin >> A;
a.push_back(A);
}
}
void solve() {
ll M = 0;
rep(i, n) { M = max(M, a[i]); }
ll m;
if (M != 0) {
m = (ll)floor(log2((ld)M)) + 1;
} else {
m = 0;
}
// cout << "m:" << m << endl;
vvll b(n, vll(m));
rep(i, n) {
for (ll j = m - 1; j >= 0; j--) {
b[i][j] = a[i] % 2;
a[i] /= 2;
}
}
/*
rep(i,n){
rep(j,m){
cout << b[i][j] << " ";
}
cout << endl;
}
*/
vll c(m, 0);
rep(j, m) {
rep(i, n) { c[j] += b[i][j]; }
// cout << c[j] << " ";
}
rep(j, m) {
if (c[j] % 2 == 1) {
rep(i, n) { b[i][j] = (b[i][j] + 1) % 2; }
}
}
rep(i, n) {
ll s = 0;
rep(j, m) { s += (ll)pow(2, m - j - 1) * b[i][j]; }
cout << s;
if (i != n - 1) {
cout << " ";
} else {
cout << endl;
}
}
}
int main() {
input();
solve();
return 0;
}
| replace | 27 | 28 | 27 | 34 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FAST \
ios_base::sync_with_stdio(0); \
cin.tie(); \
cout.tie();
#define MAXX 100005
#define PI 3.14159265358979323846264338327950
#define ll long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];
char str[MAXX];
int main() {
FAST;
ll n, k, ans = 0;
cin >> n;
cin >> a[0];
k = a[0];
for (ll i = 1; i < n; i++) {
cin >> a[i];
k ^= a[i];
}
for (ll i = 0; i < n; i++) {
ll t = k;
t ^= a[i];
cout << t << " ";
}
} | #include <bits/stdc++.h>
using namespace std;
#define FAST \
ios_base::sync_with_stdio(0); \
cin.tie(); \
cout.tie();
#define MAXX 200020
#define PI 3.14159265358979323846264338327950
#define ll long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];
char str[MAXX];
int main() {
FAST;
ll n, k, ans = 0;
cin >> n;
cin >> a[0];
k = a[0];
for (ll i = 1; i < n; i++) {
cin >> a[i];
k ^= a[i];
}
for (ll i = 0; i < n; i++) {
ll t = k;
t ^= a[i];
cout << t << " ";
}
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02631 | C++ | Runtime Error | #define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (lint)(n); i++)
#define REP(i, n) for (int i = 1; i <= (lint)(n); i++)
#define all(V) V.begin(), V.end()
#define stackReplaceBegin(size) \
void *p = malloc(size); \
esp_new = (lint)p + size - 1; \
void *stack_extend_memory_ = malloc(size); \
void *stack_extend_origin_memory_; \
char *stack_extend_dummy_memory_ = (char *)alloca( \
(1 + (int)(((long long)stack_extend_memory_) & 127)) * 16); \
*stack_extend_dummy_memory_ = 0; \
asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp" \
: "=b"(stack_extend_origin_memory_) \
: "a"((char *)stack_extend_memory_ + (size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
template <class T, class U> inline bool chmax(T &lhs, const U &rhs) {
if (lhs < rhs) {
lhs = rhs;
return 1;
}
return 0;
}
template <class T, class U> inline bool chmin(T &lhs, const U &rhs) {
if (lhs > rhs) {
lhs = rhs;
return 1;
}
return 0;
}
inline lint gcd(lint a, lint b) {
while (b) {
lint c = a;
a = b;
b = c % b;
}
return a;
}
inline lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool isprime(lint n) {
if (n == 1)
return false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
template <typename T> T mypow(T a, unsigned int b) {
if (!b)
return T(1);
if (b & 1)
return mypow(a, b - 1) * a;
T memo = mypow(a, b >> 1);
return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
if (!b)
return 1;
if (b & 1)
return modpow(a, b - 1, m) * a % m;
lint memo = modpow(a, b >> 1, m);
return memo * memo % m;
}
template <typename T> void printArray(std::vector<T> &vec) {
rep(i, vec.size() - 1) std::cout << vec[i] << " ";
std::cout << vec.back() << std::endl;
}
template <typename T> void printArray(T l, T r) {
T rprev = r;
rprev--;
for (T i = l; i != rprev; i++) {
std::cout << *i << " ";
}
std::cout << *rprev << std::endl;
}
int n, a[100010];
int main() {
std::cin >> n;
lint sum = 0;
rep(i, n) {
std::cin >> a[i];
sum ^= a[i];
}
rep(i, n) a[i] ^= sum;
printArray(a, a + n);
return 0;
}
| #define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (lint)(n); i++)
#define REP(i, n) for (int i = 1; i <= (lint)(n); i++)
#define all(V) V.begin(), V.end()
#define stackReplaceBegin(size) \
void *p = malloc(size); \
esp_new = (lint)p + size - 1; \
void *stack_extend_memory_ = malloc(size); \
void *stack_extend_origin_memory_; \
char *stack_extend_dummy_memory_ = (char *)alloca( \
(1 + (int)(((long long)stack_extend_memory_) & 127)) * 16); \
*stack_extend_dummy_memory_ = 0; \
asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp" \
: "=b"(stack_extend_origin_memory_) \
: "a"((char *)stack_extend_memory_ + (size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template <class T>
class prique : public std::priority_queue<T, std::vector<T>, std::greater<T>> {
};
template <class T, class U> inline bool chmax(T &lhs, const U &rhs) {
if (lhs < rhs) {
lhs = rhs;
return 1;
}
return 0;
}
template <class T, class U> inline bool chmin(T &lhs, const U &rhs) {
if (lhs > rhs) {
lhs = rhs;
return 1;
}
return 0;
}
inline lint gcd(lint a, lint b) {
while (b) {
lint c = a;
a = b;
b = c % b;
}
return a;
}
inline lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool isprime(lint n) {
if (n == 1)
return false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
template <typename T> T mypow(T a, unsigned int b) {
if (!b)
return T(1);
if (b & 1)
return mypow(a, b - 1) * a;
T memo = mypow(a, b >> 1);
return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
if (!b)
return 1;
if (b & 1)
return modpow(a, b - 1, m) * a % m;
lint memo = modpow(a, b >> 1, m);
return memo * memo % m;
}
template <typename T> void printArray(std::vector<T> &vec) {
rep(i, vec.size() - 1) std::cout << vec[i] << " ";
std::cout << vec.back() << std::endl;
}
template <typename T> void printArray(T l, T r) {
T rprev = r;
rprev--;
for (T i = l; i != rprev; i++) {
std::cout << *i << " ";
}
std::cout << *rprev << std::endl;
}
int n, a[200010];
int main() {
std::cin >> n;
lint sum = 0;
rep(i, n) {
std::cin >> a[i];
sum ^= a[i];
}
rep(i, n) a[i] ^= sum;
printArray(a, a + n);
return 0;
}
| replace | 115 | 116 | 115 | 116 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read() {
ll a = 0, b = getchar(), c = 1;
while (!isdigit(b))
c = b == '-' ? -1 : 1, b = getchar();
while (isdigit(b))
a = a * 10 + b - '0', b = getchar();
return a * c;
}
ll n, ans, a[100005];
int main() {
n = read();
for (int i = 0; i < n; i++)
a[i] = read(), ans ^= a[i];
for (int i = 0; i < n; i++)
printf("%lld ", ans ^ a[i]);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read() {
ll a = 0, b = getchar(), c = 1;
while (!isdigit(b))
c = b == '-' ? -1 : 1, b = getchar();
while (isdigit(b))
a = a * 10 + b - '0', b = getchar();
return a * c;
}
ll n, ans, a[200005];
int main() {
n = read();
for (int i = 0; i < n; i++)
a[i] = read(), ans ^= a[i];
for (int i = 0; i < n; i++)
printf("%lld ", ans ^ a[i]);
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mp make_pair
#define mm(a) memset(a, 0, sizeof(a))
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repn(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k, m) for (auto k : m)
#define in_edges(m) \
repp(i, 1, m) { \
ll a, b; \
cin >> a >> b; \
adj[a].pb(b), adj[b].pb(a); \
}
#define debug(this) cerr << "> " << #this << " : " << this << "\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// stoll(s);
int main() {
quick ll t;
t = 1;
// cin >> t;
while (t--) {
ll n;
cin >> n;
ll a[n];
rep(i, 0, n) { cin >> a[i]; }
ll k = 0;
vector<ll> ans;
rep(i, 0, n) {
k = 0;
rep(j, 0, n) {
if (j == i)
continue;
k ^= a[j];
}
ans.pb(k);
}
fto(j, ans) cout << j << " ";
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mp make_pair
#define mm(a) memset(a, 0, sizeof(a))
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repn(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k, m) for (auto k : m)
#define in_edges(m) \
repp(i, 1, m) { \
ll a, b; \
cin >> a >> b; \
adj[a].pb(b), adj[b].pb(a); \
}
#define debug(this) cerr << "> " << #this << " : " << this << "\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// stoll(s);
int main() {
quick ll t;
t = 1;
// cin >> t;
while (t--) {
ll n;
cin >> n;
ll a[n];
rep(i, 0, n) { cin >> a[i]; }
ll k = 0;
vector<ll> ans;
rep(i, 0, n) { k ^= a[i]; }
rep(i, 0, n) { ans.pb(k ^ a[i]); }
fto(k, ans) cout << k << " ";
}
} | replace | 39 | 49 | 39 | 42 | TLE | |
p02631 | C++ | Time Limit Exceeded | //============================================================================
// Name : template.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string.h> // for memset in CF judge.
#include <vector>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages
// (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with
// it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i, n) for (int i = 0; i < (n); i++)
#define TRvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
// memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path
// distances memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP
// memoization table memset(arr, 0, sizeof arr); // useful to clear array of
// integers
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll a[n];
forn(i, n) cin >> a[i];
ll start = 0;
vi ans;
forn(i, n) {
start = 0;
forn(j, n) {
if (i == j)
continue;
start ^= a[j];
}
cout << start << " ";
}
return 0;
}
| //============================================================================
// Name : template.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string.h> // for memset in CF judge.
#include <vector>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages
// (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with
// it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i, n) for (int i = 0; i < (n); i++)
#define TRvi(c, it) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
// memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path
// distances memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP
// memoization table memset(arr, 0, sizeof arr); // useful to clear array of
// integers
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll a[n];
forn(i, n) cin >> a[i];
ll start = 0;
forn(i, n) { start ^= a[i]; }
forn(i, n) { cout << (start ^ a[i]) << " "; }
return 0;
}
| replace | 54 | 64 | 54 | 56 | TLE | |
p02631 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int i, j;
cin >> N;
vector<int> a(N);
for (i = 0; i < N; i++)
cin >> a[i];
for (i = 0; i < N; i++) {
bitset<32> ans;
for (j = 0; j < N; j++)
if (i != j)
ans ^= a[j];
cout << ans.to_ullong() << " ";
}
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int i, j;
cin >> N;
vector<int> a(N);
for (i = 0; i < N; i++)
cin >> a[i];
bitset<32> ans;
for (i = 1; i < N; i++)
ans ^= a[i];
cout << ans.to_ullong() << " ";
for (i = 1; i < N; i++) {
ans ^= a[i];
ans ^= a[i - 1];
cout << ans.to_ullong() << " ";
}
cout << endl;
}
| replace | 10 | 15 | 10 | 17 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update>
oset;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x) \
sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \
c i) {
sim > struct rge {
c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i;
ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
void test_case() {
int n;
cin >> n;
vector<int> hash(n);
ll j = 0;
for (auto &x : hash) {
cin >> x;
j ^= x;
}
vector<int> ans;
for (auto x : hash)
ans.push_back(x ^ j);
for (auto x : ans)
cout << x << " ";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T;
cin >> T;
while (T--) {
test_case();
}
return 0;
}
| #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;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update>
oset;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x) \
sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \
c i) {
sim > struct rge {
c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i;
ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
void test_case() {
int n;
cin >> n;
vector<int> hash(n);
ll j = 0;
for (auto &x : hash) {
cin >> x;
j ^= x;
}
vector<int> ans;
for (auto x : hash)
ans.push_back(x ^ j);
for (auto x : ans)
cout << x << " ";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T = 1;
//~ cin >> T;
while (T--) {
test_case();
}
return 0;
}
| replace | 64 | 66 | 64 | 66 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int LL
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); --i)
#define sim template <class n
sim, class s > ostream &operator<<(ostream &p, pair<n, s> x) {
return p << "<" << x.f << ", " << x.s << ">";
}
sim > auto operator<<(ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value,
decltype(y.begin(), p)>::type {
int o = 0;
p << "{";
for (auto c : y) {
if (o++)
p << ", ";
p << c;
}
return p << "}";
}
void dor() { cerr << endl; }
sim, class... s > void dor(n p, s... y) {
cerr << p << " ";
dor(y...);
}
sim, class s > void mini(n &p, s y) {
if (p > y)
p = y;
}
sim, class s > void maxi(n &p, s y) {
if (p < y)
p = y;
}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif
#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
const int MXN = 1e5 + 5;
int in[MXN];
int32_t main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int x = 0;
REP(i, n) {
cin >> in[i];
x ^= in[i];
}
REP(i, n) cout << (x ^ in[i]) << " ";
}
/*
4
1101
1110
1011
0111
*/ | #include <bits/stdc++.h>
using namespace std;
#define int LL
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); --i)
#define sim template <class n
sim, class s > ostream &operator<<(ostream &p, pair<n, s> x) {
return p << "<" << x.f << ", " << x.s << ">";
}
sim > auto operator<<(ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value,
decltype(y.begin(), p)>::type {
int o = 0;
p << "{";
for (auto c : y) {
if (o++)
p << ", ";
p << c;
}
return p << "}";
}
void dor() { cerr << endl; }
sim, class... s > void dor(n p, s... y) {
cerr << p << " ";
dor(y...);
}
sim, class s > void mini(n &p, s y) {
if (p > y)
p = y;
}
sim, class s > void maxi(n &p, s y) {
if (p < y)
p = y;
}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif
#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
const int MXN = 3e5 + 5;
int in[MXN];
int32_t main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int x = 0;
REP(i, n) {
cin >> in[i];
x ^= in[i];
}
REP(i, n) cout << (x ^ in[i]) << " ";
}
/*
4
1101
1110
1011
0111
*/ | replace | 57 | 58 | 57 | 58 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ll n, a[100005], q, sum = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum = sum ^ a[i];
}
for (int i = 0; i < n; i++) {
cout << (a[i] ^ sum);
cout << " ";
}
cout << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ll n, a[200005], q, sum = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum = sum ^ a[i];
}
for (int i = 0; i < n; i++) {
cout << (a[i] ^ sum);
cout << " ";
}
cout << "\n";
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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;
}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
const pair<double, ll> &secondElof) {
return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
const pair<double, ll> &secondElof) {
return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge { // グラフに使うヤツ
ll from, to, cost;
};
typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
if (a % b == 0)
return (b);
else
return (gcd(b, a % b));
}
int main() {
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++)
cin >> a[i];
for (ll i = 0; i < n; i++) {
ll x = 0;
for (ll j = 0; j < n; j++) {
if (i == j)
continue;
x ^= a[j];
}
cout << x << " ";
}
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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;
}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
const pair<double, ll> &secondElof) {
return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
const pair<double, ll> &secondElof) {
return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge { // グラフに使うヤツ
ll from, to, cost;
};
typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
if (a % b == 0)
return (b);
else
return (gcd(b, a % b));
}
int main() {
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++)
cin >> a[i];
ll x = 0;
for (ll i = 1; i < n; i++) {
x = x ^ a[i];
}
cout << x << " ";
for (ll i = 1; i < n; i++) {
x ^= a[i - 1];
x ^= a[i];
cout << x << " ";
}
cout << endl;
return 0;
}
| replace | 49 | 56 | 49 | 57 | TLE | |
p02631 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>
int main() {
int n;
cin >> n;
vector<int> a(n);
REP(i, n) cin >> a[i];
int mx = 0;
REP(i, n) { mx = max(mx, a[i]); }
int digit = (int)log2(mx) + 1;
vint sum(digit, 0);
REP(i, n) {
REP(j, digit) {
if (a[i] & (1 << j))
sum[j]++;
}
}
vector<int> ans(n, 0);
REP(i, n) {
REP(j, digit) {
if (sum[j] % 2 == 0) {
if (a[i] & (1 << j)) {
ans[i] |= (1 << j);
}
} else {
if (!(a[i] & (1 << j))) {
ans[i] |= (1 << j);
}
}
}
}
REP(i, n) cout << ans[i] << " ";
cout << endl;
return 0;
} | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>
int main() {
int n;
cin >> n;
vector<int> a(n);
REP(i, n) cin >> a[i];
int mx = 0;
REP(i, n) { mx = max(mx, a[i]); }
int digit = 32;
vint sum(digit, 0);
REP(i, n) {
REP(j, digit) {
if (a[i] & (1 << j))
sum[j]++;
}
}
vector<int> ans(n, 0);
REP(i, n) {
REP(j, digit) {
if (sum[j] % 2 == 0) {
if (a[i] & (1 << j)) {
ans[i] |= (1 << j);
}
} else {
if (!(a[i] & (1 << j))) {
ans[i] |= (1 << j);
}
}
}
}
REP(i, n) cout << ans[i] << " ";
cout << endl;
return 0;
} | replace | 24 | 25 | 24 | 25 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define LL long long
#define li i << 1
#define ri i << 1 | 1
using namespace std;
inline LL read() {
char c = getchar();
LL x = 0, f = 1;
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
const int maxn = 200005;
LL n, a[maxn], ans[maxn];
int main() {
n = read();
for (int i = 1; i <= n; ++i)
a[i] = read();
for (int p = 0;; ++p) {
ans[1] = p;
for (int i = 2; i <= n; ++i) {
ans[i] = (a[i - 1] ^ a[i] ^ ans[i - 1]);
}
if ((a[1] ^ a[n]) != (ans[1] ^ ans[n]))
continue;
LL num = 0;
for (int i = 2; i <= n; ++i)
num ^= ans[i];
if (num == a[1])
break;
}
for (int i = 1; i <= n; ++i) {
if (i != 1)
printf(" ");
printf("%lld", ans[i]);
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define LL long long
#define li i << 1
#define ri i << 1 | 1
using namespace std;
inline LL read() {
char c = getchar();
LL x = 0, f = 1;
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
const int maxn = 200005;
LL n, a[maxn], ans[maxn];
int main() {
n = read();
for (int i = 1; i <= n; ++i)
a[i] = read();
for (int i = 2; i <= n; ++i)
ans[1] ^= a[i];
for (int i = 2; i <= n; ++i)
ans[i] = (a[i - 1] ^ a[i] ^ ans[i - 1]);
for (int i = 1; i <= n; ++i) {
if (i != 1)
printf(" ");
printf("%lld", ans[i]);
}
return 0;
}
| replace | 34 | 47 | 34 | 38 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define mod 1000000007
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
ll power(ll a, ll b, ll modi) {
a %= modi;
ll res = 1;
while (b) {
if (b % 2) {
res = (res * a) % modi;
}
b /= 2;
a = (a * a) % modi;
}
return res;
}
// ll a[100001];
ll a[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
while (t--) {
ll n;
cin >> n;
for (ll i = 0; i < n; i++)
cin >> a[i];
ll x = 0;
for (ll i = 0; i < n; i++)
x ^= a[i];
for (ll i = 0; i < n; i++)
a[i] = a[i] ^ x;
for (ll i = 0; i < n; i++)
cout << a[i] << " ";
}
return 0;
}
| #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define mod 1000000007
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
ll power(ll a, ll b, ll modi) {
a %= modi;
ll res = 1;
while (b) {
if (b % 2) {
res = (res * a) % modi;
}
b /= 2;
a = (a * a) % modi;
}
return res;
}
// ll a[100001];
ll a[200001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
while (t--) {
ll n;
cin >> n;
for (ll i = 0; i < n; i++)
cin >> a[i];
ll x = 0;
for (ll i = 0; i < n; i++)
x ^= a[i];
for (ll i = 0; i < n; i++)
a[i] = a[i] ^ x;
for (ll i = 0; i < n; i++)
cout << a[i] << " ";
}
return 0;
}
| replace | 32 | 33 | 32 | 33 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
typedef long long int ll;
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...);
}
const ll mod = 1e9 + 7;
const double eps = 1e-9;
const int maxN = 1e5 + 10;
int a[maxN], n;
void solve() {
cin >> n;
int t = 0;
for (int i = 0; i < n; ++i)
cin >> a[i], t ^= a[i];
for (int i = 0; i < n; i++)
cout << (a[i] ^ t) << " ";
cout << "\n";
}
int main() {
fastio int test = 1;
while (test--)
solve();
return 0;
}
| #include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
typedef long long int ll;
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...);
}
const ll mod = 1e9 + 7;
const double eps = 1e-9;
const int maxN = 2e5 + 10;
int a[maxN], n;
void solve() {
cin >> n;
int t = 0;
for (int i = 0; i < n; ++i)
cin >> a[i], t ^= a[i];
for (int i = 0; i < n; i++)
cout << (a[i] ^ t) << " ";
cout << "\n";
}
int main() {
fastio int test = 1;
while (test--)
solve();
return 0;
}
| replace | 51 | 52 | 51 | 52 | 0 | |
p02631 | C++ | Runtime Error | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <iostream> // cout, endl, cin
#include <math.h> // sqrt
#include <string> // string, to_string, stoi
#include <vector> // vector
using namespace std;
long long ruijo(int n) {
long long ans = 1;
for (int i = 0; i < n; i++) {
ans *= 2;
}
return ans;
}
int main() {
int N;
cin >> N;
vector<long long> data(N);
for (int i = 0; i < N; i++) {
cin >> data.at(i);
}
vector<int> two(31, 0);
long long num;
int j;
for (int i = 0; i < N; i++) {
num = data.at(i);
j = 0;
while (true) {
if (num % 2 == 1) {
two.at(j)++;
}
if (num < 2) {
break;
}
num = floor(num / 2);
j++;
}
}
long long ans = 0;
for (int i = 0; i < N; i++) {
if (two.at(i) % 2 == 1) {
ans += ruijo(i);
}
}
long long ansa;
for (int i = 0; i < N; i++) {
ansa = ans;
num = data.at(i);
j = 0;
while (true) {
if (num % 2 == 1) {
if (two.at(j) % 2 == 0) {
ansa += ruijo(j);
} else {
ansa -= ruijo(j);
}
}
if (num < 2) {
break;
}
num = floor(num / 2);
j++;
}
cout << ansa << ' ';
}
cout << endl;
} | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <iostream> // cout, endl, cin
#include <math.h> // sqrt
#include <string> // string, to_string, stoi
#include <vector> // vector
using namespace std;
long long ruijo(int n) {
long long ans = 1;
for (int i = 0; i < n; i++) {
ans *= 2;
}
return ans;
}
int main() {
int N;
cin >> N;
vector<long long> data(N);
for (int i = 0; i < N; i++) {
cin >> data.at(i);
}
vector<int> two(31, 0);
long long num;
int j;
for (int i = 0; i < N; i++) {
num = data.at(i);
j = 0;
while (true) {
if (num % 2 == 1) {
two.at(j)++;
}
if (num < 2) {
break;
}
num = floor(num / 2);
j++;
}
}
long long ans = 0;
for (int i = 0; i < 31; i++) {
if (two.at(i) % 2 == 1) {
ans += ruijo(i);
}
}
long long ansa;
for (int i = 0; i < N; i++) {
ansa = ans;
num = data.at(i);
j = 0;
while (true) {
if (num % 2 == 1) {
if (two.at(j) % 2 == 0) {
ansa += ruijo(j);
} else {
ansa -= ruijo(j);
}
}
if (num < 2) {
break;
}
num = floor(num / 2);
j++;
}
cout << ansa << ' ';
}
cout << endl;
} | replace | 40 | 41 | 40 | 41 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll i, j, k, l, m, n, o, p, q, r, t, a[100001] = {0};
cin >> n;
m = 0;
for (i = 0; i < n; i++) {
cin >> a[i];
m ^= a[i];
}
for (i = 0; i < n; i++) {
cout << (m ^ a[i]) << " ";
}
cout << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll i, j, k, l, m, n, o, p, q, r, t, a[300001] = {0};
cin >> n;
m = 0;
for (i = 0; i < n; i++) {
cin >> a[i];
m ^= a[i];
}
for (i = 0; i < n; i++) {
cout << (m ^ a[i]) << " ";
}
cout << endl;
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x) \
sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \
c i) {
sim > struct rge {
c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i;
ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long;
const int nax = 1e9;
int ff(int xorr, int num) {
for (int i = 1; i < nax; i++) {
if ((xorr ^ i) == num) {
return i;
}
}
}
int main() {
int n;
cin >> n;
vector<int> a(n);
int xorr = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
xorr ^= a[i];
}
debug() << imie(xorr);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[i] = ff(xorr, a[i]);
assert((xorr ^ a[i]) == ans[i]);
}
for (auto it : ans) {
cout << it << " ";
}
}
| #include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x) \
sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \
c i) {
sim > struct rge {
c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i;
ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long;
const int nax = 1e9;
int ff(int xorr, int num) { return (xorr ^ num); }
int main() {
int n;
cin >> n;
vector<int> a(n);
int xorr = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
xorr ^= a[i];
}
debug() << imie(xorr);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[i] = ff(xorr, a[i]);
assert((xorr ^ a[i]) == ans[i]);
}
for (auto it : ans) {
cout << it << " ";
}
}
| replace | 39 | 46 | 39 | 40 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 1e5 + 5;
int vt[MX];
int main() {
int i, j, k;
int n;
cin >> n;
for (i = 0; i < n; ++i)
cin >> vt[i];
int sm = 0;
for (i = 0; i < n; ++i)
sm ^= vt[i];
for (i = 0; i < n; ++i) {
cout << (sm ^ vt[i]) << " ";
}
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 2e5 + 5;
int vt[MX];
int main() {
int i, j, k;
int n;
cin >> n;
for (i = 0; i < n; ++i)
cin >> vt[i];
int sm = 0;
for (i = 0; i < n; ++i)
sm ^= vt[i];
for (i = 0; i < n; ++i) {
cout << (sm ^ vt[i]) << " ";
}
cout << endl;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02631 | C++ | Runtime Error | // #pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()
ll quick_pow(ll base, ll n) {
ll ans = 1;
while (n) {
if (n & 1)
ans *= base;
base *= base;
n >>= 1;
}
return ans;
}
void solve();
int main() {
int T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
}
int a[100050];
void solve() {
int n;
cin >> n;
int t = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
t ^= a[i];
}
t ^= 1;
for (int i = 0; i < n; ++i) {
t ^= a[i];
cout << t << ' ';
t ^= a[i];
}
} | // #pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()
ll quick_pow(ll base, ll n) {
ll ans = 1;
while (n) {
if (n & 1)
ans *= base;
base *= base;
n >>= 1;
}
return ans;
}
void solve();
int main() {
int T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
}
int a[200050];
void solve() {
int n;
cin >> n;
int t = 1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
t ^= a[i];
}
t ^= 1;
for (int i = 0; i < n; ++i) {
t ^= a[i];
cout << t << ' ';
t ^= a[i];
}
} | replace | 25 | 26 | 25 | 26 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL bin(LL a, LL b, LL p) {
LL res = 1;
for (; b; b >>= 1, a = a * a % p)
if (b & 1)
res = res * a % p;
return res;
}
const int N = 1e5 + 50;
int a[N];
int n;
int main(int argc, char const *argv[]) {
scanf("%d", &n);
int s = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
s ^= a[i];
}
for (int i = 0; i < n; ++i) {
printf("%d%c", s ^ a[i], i == n - 1 ? '\n' : ' ');
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL bin(LL a, LL b, LL p) {
LL res = 1;
for (; b; b >>= 1, a = a * a % p)
if (b & 1)
res = res * a % p;
return res;
}
const int N = 3e5 + 50;
int a[N];
int n;
int main(int argc, char const *argv[]) {
scanf("%d", &n);
int s = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
s ^= a[i];
}
for (int i = 0; i < n; ++i) {
printf("%d%c", s ^ a[i], i == n - 1 ? '\n' : ' ');
}
return 0;
}
| replace | 12 | 13 | 12 | 13 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
// int t;cin>>t;while(t--)
{
ll a, b, c, d, i, j, k, l, m, n, cnt = 0, sum = 0;
ll arr[1000];
cin >> n;
for (i = 0; i < n; i++) {
cin >> arr[i];
}
k = arr[0];
for (i = 1; i < n; i++) {
k ^= arr[i];
}
for (i = 0; i < n; i++) {
l = arr[i] ^ k;
cout << l << " ";
}
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
// int t;cin>>t;while(t--)
{
ll a, b, c, d, i, j, k, l, m, n, cnt = 0, sum = 0;
ll arr[300000];
cin >> n;
for (i = 0; i < n; i++) {
cin >> arr[i];
}
k = arr[0];
for (i = 1; i < n; i++) {
k ^= arr[i];
}
for (i = 0; i < n; i++) {
l = arr[i] ^ k;
cout << l << " ";
}
}
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02631 | C++ | Runtime Error | #include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;
#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
vector<int> ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return ret;
}
int main() {
long long ans;
int N;
int a[20002];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i];
}
int sum = 0;
for (int i = 0; i < N; i++) {
sum = sum ^ a[i];
}
for (int i = 0; i < N; i++) {
ans = sum ^ a[i];
cout << ans << " ";
}
cin >> ans;
return 0;
} | #include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;
#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
vector<int> ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return ret;
}
int main() {
long long ans;
int N;
int a[200020];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i];
}
int sum = 0;
for (int i = 0; i < N; i++) {
sum = sum ^ a[i];
}
for (int i = 0; i < N; i++) {
ans = sum ^ a[i];
cout << ans << " ";
}
cin >> ans;
return 0;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p02631 | C++ | Runtime Error | /* _
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
____/`---'\____
/ \\| |// \
/ \\||| /:\ |||// \
/ _||||| -:- |||||- \
| | \\\ \-/ /// | |
| \_| ''\---/'' |_/ |
\ .-\__ '-' ___/-. /
____'. .' /--.--\ `. .'_____
/"" '< `.___\_<|>_/___.' >' "" \
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `_. \_ __\ /__ _/ .-` / _/
`-.____`.___ \_____/___.-`___.-'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JENISH MONPARA S. IIT PATNA I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005
#define fio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define mpq priority_queue<int, vector<int>, greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt \
cin >> t; \
for (int tt = 1; tt <= t; ++tt)
#define forr(i, n) for ((i) = 1; (i) <= (n); (i)++)
#define Rev(v) reverse(v.begin(), v.end())
#define Sort(v) sort(v.begin(), v.end())
#define mem(a, b) memset(a, b, sizeof(a))
#define umii unordered_map<int, int>
#define all(a) a.begin(), a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout << "\nhi\n"
#define pii pair<int, int>
#define mii map<int, int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout << "\n"
#define pb push_back
#define int long long
#define sp << " " <<
#define se second
#define fi first
int fpow(int x, int y, int m) {
int temp;
if (y == 0 || x == 1)
return 1;
temp = fpow(x, y / 2, m);
if (y % 2 == 0)
return ((temp) * (temp)) % m;
else
return (((x) % m) * ((temp * temp) % m)) % m;
}
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
void sieve(int n) {
bool prime[5 * LIM];
memset(prime, true, sizeof(prime));
int rootn = (int)sqrt(n);
for (int p = 2; p <= rootn; p++)
if (prime[p] == true)
for (int i = p * p; i <= n; i += p)
prime[i] = false;
prime[1] = 0;
}
int cnt, sum, mid, mx = -1e17, mn = 1e17;
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;
vi a(2 * LIM);
//*************************************************************************************************************************
int32_t main() {
fio;
cin >> n;
forr(i, n) cin >> a[i];
vi pre(LIM, 0), suff(LIM, 0);
x = 0;
forr(i, n) {
pre[i] = x;
x ^= a[i];
}
x = 0;
for (i = n; i > 0; i--) {
suff[i] = x;
x ^= a[i];
}
forr(i, n) { cout << (pre[i] ^ suff[i]) << " "; }
}
| /* _
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
____/`---'\____
/ \\| |// \
/ \\||| /:\ |||// \
/ _||||| -:- |||||- \
| | \\\ \-/ /// | |
| \_| ''\---/'' |_/ |
\ .-\__ '-' ___/-. /
____'. .' /--.--\ `. .'_____
/"" '< `.___\_<|>_/___.' >' "" \
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `_. \_ __\ /__ _/ .-` / _/
`-.____`.___ \_____/___.-`___.-'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JENISH MONPARA S. IIT PATNA I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005
#define fio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define mpq priority_queue<int, vector<int>, greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt \
cin >> t; \
for (int tt = 1; tt <= t; ++tt)
#define forr(i, n) for ((i) = 1; (i) <= (n); (i)++)
#define Rev(v) reverse(v.begin(), v.end())
#define Sort(v) sort(v.begin(), v.end())
#define mem(a, b) memset(a, b, sizeof(a))
#define umii unordered_map<int, int>
#define all(a) a.begin(), a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout << "\nhi\n"
#define pii pair<int, int>
#define mii map<int, int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout << "\n"
#define pb push_back
#define int long long
#define sp << " " <<
#define se second
#define fi first
int fpow(int x, int y, int m) {
int temp;
if (y == 0 || x == 1)
return 1;
temp = fpow(x, y / 2, m);
if (y % 2 == 0)
return ((temp) * (temp)) % m;
else
return (((x) % m) * ((temp * temp) % m)) % m;
}
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
void sieve(int n) {
bool prime[5 * LIM];
memset(prime, true, sizeof(prime));
int rootn = (int)sqrt(n);
for (int p = 2; p <= rootn; p++)
if (prime[p] == true)
for (int i = p * p; i <= n; i += p)
prime[i] = false;
prime[1] = 0;
}
int cnt, sum, mid, mx = -1e17, mn = 1e17;
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;
vi a(2 * LIM);
//*************************************************************************************************************************
int32_t main() {
fio;
cin >> n;
forr(i, n) cin >> a[i];
vi pre(2 * LIM, 0), suff(2 * LIM, 0);
x = 0;
forr(i, n) {
pre[i] = x;
x ^= a[i];
}
x = 0;
for (i = n; i > 0; i--) {
suff[i] = x;
x ^= a[i];
}
forr(i, n) { cout << (pre[i] ^ suff[i]) << " "; }
}
| replace | 96 | 97 | 96 | 97 | 0 | |
p02631 | C++ | Runtime Error | // In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn = 1e5 + 5, inf = 1e18 + 18;
ll n, ans, a[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
ans = ans ^ a[i];
}
for (int i = 0; i < n; i++) {
ans = ans ^ a[i];
cout << ans << endl;
ans = ans ^ a[i];
}
}
| // In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn = 2e5 + 5, inf = 1e18 + 18;
ll n, ans, a[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
ans = ans ^ a[i];
}
for (int i = 0; i < n; i++) {
ans = ans ^ a[i];
cout << ans << endl;
ans = ans ^ a[i];
}
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;
ll a[100010];
int main() {
int n;
cin >> n;
rep(i, n) cin >> a[i];
ll b = a[0];
rep(i, n - 1) { b ^= a[i + 1]; }
rep(i, n) cout << (b ^ a[i]) << " ";
cout << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;
ll a[200010];
int main() {
int n;
cin >> n;
rep(i, n) cin >> a[i];
ll b = a[0];
rep(i, n - 1) { b ^= a[i + 1]; }
rep(i, n) cout << (b ^ a[i]) << " ";
cout << endl;
return 0;
}
| replace | 12 | 13 | 12 | 13 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;
void solve() {
int n;
cin >> n;
vector<ll> a(n);
forn(i, n) cin >> a[i];
vector<ll> ans(n);
int i, j;
for (i = 0; i < n; i++) {
ans[i] = 0;
for (j = 0; j < n; j++) {
if (i == j)
continue;
ans[i] = ans[i] ^ a[j];
}
}
for (auto x : ans) {
cout << x << " ";
}
cout << endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
} | #include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;
void solve() {
int n;
cin >> n;
vector<ll> a(n);
forn(i, n) cin >> a[i];
vector<ll> ans(n);
int i, j;
ans[0] = 0;
for (i = 1; i < n; i++) {
ans[0] = ans[0] ^ a[i];
}
ll temp = ans[0];
for (i = 1; i < n; i++) {
temp = temp ^ a[i];
temp = temp ^ a[i - 1];
ans[i] = temp;
}
for (auto x : ans) {
cout << x << " ";
}
cout << endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
} | replace | 13 | 20 | 13 | 22 | TLE | |
p02631 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian() {
freopen("concatenation.in", "r", stdin);
freopen("concatenation.out", "w", stdout);
}
void tempwj() {
freopen("hash.in", "r", stdin);
freopen("hash.out", "w", stdout);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b, ll mod) {
a %= mod;
ll ans = 1;
while (b) {
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
struct cmp {
bool operator()(const pii &a, const pii &b) { return a.second > b.second; }
};
int lb(int x) { return x & -x; }
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int a[maxn];
int main() {
int n;
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum ^= a[i];
}
for (int i = 1; i <= n; i++) {
a[i] = a[i] ^ sum;
printf("%d ", a[i]);
}
printf("\n");
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian() {
freopen("concatenation.in", "r", stdin);
freopen("concatenation.out", "w", stdout);
}
void tempwj() {
freopen("hash.in", "r", stdin);
freopen("hash.out", "w", stdout);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b, ll mod) {
a %= mod;
ll ans = 1;
while (b) {
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
struct cmp {
bool operator()(const pii &a, const pii &b) { return a.second > b.second; }
};
int lb(int x) { return x & -x; }
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 3e5 + 5;
int a[maxn];
int main() {
int n;
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum ^= a[i];
}
for (int i = 1; i <= n; i++) {
a[i] = a[i] ^ sum;
printf("%d ", a[i]);
}
printf("\n");
} | replace | 50 | 51 | 50 | 51 | 0 | |
p02631 | C++ | Runtime Error | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
// #pragma warning(disable : 4996)
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif
#include <limits.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) \
REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
void fail() {
cout << -1 << endl;
exit(0);
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 50050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
// const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };
int A[100010], B[100010];
void solve() {
int N;
cin >> N;
REP(i, N) { cin >> A[i]; }
int sum = 0;
REP(i, N) { sum ^= A[i]; }
REP(i, N) {
B[i] = A[i] ^ sum;
print(B[i]);
}
// REP(i, N) {
// int res = 0;
// REP(j, N)if (j != i)res ^= B[j];
// pe(i); print(res);
// }
// print(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// mt.seed((int)(time(0)));
// int q;
// cin >> q;
// while (q--)
solve();
}
| #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
// #pragma warning(disable : 4996)
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif
#include <limits.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) \
REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
void fail() {
cout << -1 << endl;
exit(0);
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 50050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
// const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };
int A[200010], B[200010];
void solve() {
int N;
cin >> N;
REP(i, N) { cin >> A[i]; }
int sum = 0;
REP(i, N) { sum ^= A[i]; }
REP(i, N) {
B[i] = A[i] ^ sum;
print(B[i]);
}
// REP(i, N) {
// int res = 0;
// REP(j, N)if (j != i)res ^= B[j];
// pe(i); print(res);
// }
// print(ans);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
// mt.seed((int)(time(0)));
// int q;
// cin >> q;
// while (q--)
solve();
}
| replace | 83 | 84 | 83 | 84 | 0 | |
p02631 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;
#define PI 3.1415926535897932384626433
#define _DBG_
int main(void) {
ULONG N;
cin >> N;
vector<ULONG> a(N);
for (ULONG i = 0; i < N; i++) {
cin >> a[i];
}
for (ULONG i = 0; i < N; i++) {
ULONG xor_ = 0;
for (ULONG j = 0; j < N; j++) {
if (i == j)
continue;
xor_ = xor_ ^ a[j];
}
cout << xor_;
if (i != N - 1) {
cout << " ";
}
}
cout << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;
#define PI 3.1415926535897932384626433
#define _DBG_
int main(void) {
ULONG N;
cin >> N;
vector<ULONG> a(N);
for (ULONG i = 0; i < N; i++) {
cin >> a[i];
}
ULONG xor_ = 0;
for (ULONG j = 1; j < N; j++) {
xor_ = xor_ ^ a[j];
}
cout << xor_ << " ";
for (ULONG i = 1; i < N; i++) {
xor_ = xor_ ^ a[i - 1];
xor_ = xor_ ^ a[i];
cout << xor_;
if (i != N - 1) {
cout << " ";
}
}
cout << endl;
return 0;
} | replace | 28 | 35 | 28 | 37 | TLE | |
p02631 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using namespace __gnu_pbds;
#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define rev(a) a.rbegin(), a.rend()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>
void solve() {
ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
cin >> n;
vl v(n);
for (auto &i : v)
cin >> i;
rep(i, n) {
ans = 0;
rep(j, n) {
if (i == j)
continue;
ans ^= v[j];
}
cout << ans << " ";
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/* ll t;
cin>>t;
while(t--){ */
solve();
/* } */
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using namespace __gnu_pbds;
#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define rev(a) a.rbegin(), a.rend()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>
void solve() {
ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
cin >> n;
vl v(n);
for (auto &i : v)
cin >> i;
rep(i, n) { ans ^= v[i]; }
rep(i, n) { cout << (ans ^ v[i]) << " "; }
cout << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/* ll t;
cin>>t;
while(t--){ */
solve();
/* } */
}
| replace | 50 | 59 | 50 | 53 | TLE | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a, int b) { return a > b; }
int gcd(int x, int y) {
while (y ^= x ^= y ^= x %= y)
;
return x;
}
int a[100005];
int n, num = 0;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
num ^= a[i];
}
for (int i = 0; i < n; i++) {
cout << (num ^ a[i]) << " ";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a, int b) { return a > b; }
int gcd(int x, int y) {
while (y ^= x ^= y ^= x %= y)
;
return x;
}
int a[200004];
int n, num = 0;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
num ^= a[i];
}
for (int i = 0; i < n; i++) {
cout << (num ^ a[i]) << " ";
}
return 0;
}
| replace | 12 | 13 | 12 | 13 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second
const int maxn = 1e5 + 5;
const int maxv = 1e9;
int T, tc;
int n;
int a[maxn];
int main() {
// freopen("inp.txt", "r", stdin);
cin >> n;
int x = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
x ^= a[i];
}
for (int i = 0; i < n; i++) {
printf("%d ", x ^ a[i]);
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second
const int maxn = 2e5 + 5;
const int maxv = 1e9;
int T, tc;
int n;
int a[maxn];
int main() {
// freopen("inp.txt", "r", stdin);
cin >> n;
int x = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
x ^= a[i];
}
for (int i = 0; i < n; i++) {
printf("%d ", x ^ a[i]);
}
return 0;
} | replace | 10 | 11 | 10 | 11 | 0 | |
p02631 | C++ | Runtime Error | /*
Powered by C++11.
Author : Alex_Wei.
*/
#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize(3)
// #define int long long
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x, v) memset(x, v, sizeof(x))
// Templates start.
namespace IO {
char buf[1 << 21], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
#ifdef __WIN32
#define gc getchar()
#else
#define gc \
(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) \
? EOF \
: *p1++)
#endif
#define pc(x) (*O++ = x)
#define flush() fwrite(obuf, O - obuf, 1, stdout)
inline int read() {
int x = 0, sign = 0;
char s = gc;
while (!isdigit(s))
sign |= s == '-', s = gc;
while (isdigit(s))
x = (x << 1) + (x << 3) + (s - '0'), s = gc;
return sign ? -x : x;
}
void print(int x) {
if (x > 9)
print(x / 10);
pc(x % 10 + '0');
}
} // namespace IO
namespace math {
const int mod = 998244353;
const int maxn = 1e6 + 5;
ll ksm(ll a, ll b) {
ll s = 1, m = a;
while (b) {
if (b & 1)
s = s * m % mod;
m = m * m % mod, b >>= 1;
}
return s;
}
ll inv(ll x) { return ksm(x, mod - 2); }
ll fc[maxn], ifc[maxn];
void init_m(int n) {
fc[0] = 1;
for (int i = 1; i <= n; i++)
fc[i] = fc[i - 1] * i % mod;
ifc[n] = inv(fc[n]);
for (int i = n - 1; i >= 0; i--)
ifc[i] = ifc[i + 1] * (i + 1) % mod;
}
ll C(ll n, ll m) { return fc[n] * ifc[m] % mod * ifc[n - m] % mod; }
} // namespace math
// Templates end. Please give me more points.
using namespace IO;
// using namespace math;
const int N = 1e5 + 5;
int n, a[N], t;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], t ^= a[i];
for (int i = 1; i <= n; i++)
cout << (t ^ a[i]) << " ";
return 0;
}
| /*
Powered by C++11.
Author : Alex_Wei.
*/
#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize(3)
// #define int long long
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x, v) memset(x, v, sizeof(x))
// Templates start.
namespace IO {
char buf[1 << 21], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
#ifdef __WIN32
#define gc getchar()
#else
#define gc \
(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) \
? EOF \
: *p1++)
#endif
#define pc(x) (*O++ = x)
#define flush() fwrite(obuf, O - obuf, 1, stdout)
inline int read() {
int x = 0, sign = 0;
char s = gc;
while (!isdigit(s))
sign |= s == '-', s = gc;
while (isdigit(s))
x = (x << 1) + (x << 3) + (s - '0'), s = gc;
return sign ? -x : x;
}
void print(int x) {
if (x > 9)
print(x / 10);
pc(x % 10 + '0');
}
} // namespace IO
namespace math {
const int mod = 998244353;
const int maxn = 1e6 + 5;
ll ksm(ll a, ll b) {
ll s = 1, m = a;
while (b) {
if (b & 1)
s = s * m % mod;
m = m * m % mod, b >>= 1;
}
return s;
}
ll inv(ll x) { return ksm(x, mod - 2); }
ll fc[maxn], ifc[maxn];
void init_m(int n) {
fc[0] = 1;
for (int i = 1; i <= n; i++)
fc[i] = fc[i - 1] * i % mod;
ifc[n] = inv(fc[n]);
for (int i = n - 1; i >= 0; i--)
ifc[i] = ifc[i + 1] * (i + 1) % mod;
}
ll C(ll n, ll m) { return fc[n] * ifc[m] % mod * ifc[n - m] % mod; }
} // namespace math
// Templates end. Please give me more points.
using namespace IO;
// using namespace math;
const int N = 2e5 + 5;
int n, a[N], t;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], t ^= a[i];
for (int i = 1; i <= n; i++)
cout << (t ^ a[i]) << " ";
return 0;
}
| replace | 84 | 85 | 84 | 85 | 0 | |
p02631 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
const long long inf = 0x3f3f3f3f;
long long a[maxn], num;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
long long n;
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
num ^= a[i];
}
for (long long i = 1; i <= n; i++)
cout << (num ^ a[i]) << " ";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5;
const long long inf = 0x3f3f3f3f;
long long a[maxn], num;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
long long n;
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
num ^= a[i];
}
for (long long i = 1; i <= n; i++)
cout << (num ^ a[i]) << " ";
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.