aboutsummaryrefslogtreecommitdiff
path: root/contests
diff options
context:
space:
mode:
Diffstat (limited to 'contests')
-rwxr-xr-xcontests/Round895/B/main.cpp7
-rwxr-xr-xcontests/Round895/E/main.cpp30
2 files changed, 20 insertions, 17 deletions
diff --git a/contests/Round895/B/main.cpp b/contests/Round895/B/main.cpp
index 25927ff..81803b7 100755
--- a/contests/Round895/B/main.cpp
+++ b/contests/Round895/B/main.cpp
@@ -120,16 +120,11 @@ template <typename T, typename... TS> void dbg(T val, TS... vals) {
void solve() {
int n;
cin >> n;
- vector<vi> v(201);
int mn = INT_MAX;
for (int i = 0; i < n; i++) {
int s, d;
cin >> s >> d;
- if (d % 2 == 0) {
- mn = min(mn, s + (d / 2 - 1));
- } else {
- mn = min(mn, s + d / 2);
- }
+ mn = min(mn , s + (d - 1) / 2);
}
cout << mn << endl;
}
diff --git a/contests/Round895/E/main.cpp b/contests/Round895/E/main.cpp
index c318b79..a507ff4 100755
--- a/contests/Round895/E/main.cpp
+++ b/contests/Round895/E/main.cpp
@@ -120,32 +120,40 @@ void solve() {
int n;
cin >> n;
vi v(n);
+ vi pfx(n + 1);
+ pfx[0] = 0;
for (auto &x : v) {
cin >> x;
}
+ for (int i = 0; i < n; i++) {
+ pfx[i + 1] = pfx[i] ^ v[i];
+ }
string s;
cin >> s;
int q;
cin >> q;
+ int x1 = 0, x2 = 0;
+ for (int i = 0; i < n; i++) {
+ if (s[i] == '0') {
+ x1 ^= v[i];
+ } else {
+ x2 ^= v[i];
+ }
+ }
for (int i = 0; i < q; i++) {
int op, x;
cin >> op >> x;
if (op == 1) {
- x--;
int y;
cin >> y;
- y--;
- for (int j = x; j <= y; j++) {
- s[j] = (s[j] == '0') ? '1' : '0';
- }
+ x1 ^= pfx[y] ^ pfx[x - 1];
+ x2 ^= pfx[y] ^ pfx[x - 1];
} else {
- int ans = 0;
- for (int j = 0; j < n; j++) {
- if (s[j] == x + '0') {
- ans ^= v[j];
- }
+ if (x == 0) {
+ cout << x1 << ' ';
+ } else {
+ cout << x2 << ' ';
}
- cout << ans << ' ';
}
}
cout << '\n';