# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
883446 | catlover | Ruka (COI15_ruka) | C++14 | 1 ms | 344 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.
#include <bits/stdc++.h>
#define int long long
#define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int maxN = 1e6;
typedef pair<int, int> pii;
int N, M;
pii p[maxN+5];
void read(){}
template <typename Head, typename ...Tail>
void read(Head &H, Tail &...T)
{
int sign = 0;
char c;
for (c = getchar(); !isdigit(c); c = getchar())
if (c == '-') sign = 1;
H = c - '0';
for (c = getchar(); isdigit(c); c = getchar())
H = H * 10 + c - '0';
if (sign) H = -H;
read(T...);
}
void read_input()
{
read(N);
FOR(i, 1, N) read(p[i].fi), read(p[i].se);
}
namespace sub1
{
bool checkX(pii bf, pii aft)
{
return (bf.fi * aft.fi <= 0);
}
bool checkY(pii bf, pii aft)
{
return (bf.se * aft.se <= 0);
}
void solve()
{
int cur = 1;
p[0] = mp(1, 1);
read(M);
while(M --> 0)
{
char type = getchar();
if(type == 'C')
{
int nx, ny; read(nx); read(ny);
p[cur] = mp(nx, ny);
}
else if(type == 'Q')
{
int ans = 0;
pii pn = mp(1, 1), pw;
FOR(i, 1, N)
{
pw = mp(pn.fi + p[i].fi, pn.se + p[i].se);
if(checkX(pw, pn)) ++ans;
if(checkY(pw, pn)) ++ans;
pn = pw;
}
cout << ans << '\n';
}
else if(type == 'B')
{
if(cur == 1) continue;
--cur;
}
else
{
if(cur == N) continue;
++cur;
}
}
}
}
void solve()
{
sub1::solve();
}
int32_t main()
{
cin.tie(0)->sync_with_stdio(0);
file("SIMULATION");
read_input();
solve();
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... |