# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
883443 | catlover | Ruka (COI15_ruka) | C++14 | 2041 ms | 3816 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Author : Hoang Van Tra - HSGS Bac Giang
// Train VOI 2023 - 2024
#include <bits/stdc++.h>
using namespace std;
// -------------------------------------------------------INDEF-----------------------------------------------------------------------
#define For(i, a, b) for (int i = a; i <= b; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define ii pair<int, int>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define RRH(v) v.resize(unique(all(v)) - v.begin())
const int N = 1e6 + 7;
const int M = 1e9 + 7;
const ll oo = 1e18;
const int block = 708;
int n, q;
ii a[N];
int solve() {
int ans = 0;
int x = 1, y = 1;
int cur_x = 1;
int cur_y = 1;
For(i, 1, n) {
x += a[i].fi;
y += a[i].se;
if (cur_x * x < 0) {
ans++;
cur_x = -cur_x;
}
if (cur_y * y < 0) {
ans++;
cur_y = -cur_y;
}
}
return ans;
}
// -------------------------------------------------------ENDEF----------------------------------------------------------------------
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
#define TASK ""
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
cin >> n;
For(i, 1, n) cin >> a[i].fi >> a[i].se;
cin >> q;
a[0] = { 1, 1 };
int pos = 1;
while (q--) {
char t;
cin >> t;
if (t == 'B')
pos = max(1, pos - 1);
if (t == 'F')
pos = min(n, pos + 1);
if (t == 'C') {
int x, y;
cin >> x >> y;
a[pos] = { x, y };
}
if (t == 'Q')
cout << solve() << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |