# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
883443 | catlover | Ruka (COI15_ruka) | C++14 | 2041 ms | 3816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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;
}
컴파일 시 표준 에러 (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... |