# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
283875 |
2020-08-26T08:35:16 Z |
임성재(#5753) |
Ruka (COI15_ruka) |
C++17 |
|
2000 ms |
2736 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const ll inf = 1e9 + 7;
const int sz = 230;
int n, m, ans;
pii idx[sz * sz + 100];
int x[sz * sz + 100];
int y[sz * sz + 100];
int xh[sz+1];
int yh[sz+1];
int X[sz+1][sz+1], Y[sz+1][sz+1];
int xans[2][sz+1][sz], yans[2][sz+1][sz];
void upd(int t) {
for(int i=0; i<sz-1; i++) {
xans[0][t][i] = min(X[t][i+1], X[t][i]);
xans[1][t][i] = max(X[t][i+1], X[t][i]);
yans[0][t][i] = min(Y[t][i+1], Y[t][i]);
yans[1][t][i] = max(Y[t][i+1], Y[t][i]);
}
sort(xans[0][t], xans[0][t] + sz - 1), sort(xans[1][t], xans[1][t] + sz - 1);
sort(yans[0][t], yans[0][t] + sz - 1), sort(yans[1][t], yans[1][t] + sz - 1);
}
int main() {
fast;
cin >> n;
for(int i=1; i <= sz * sz; i++) {
idx[i] = idx[i-1];
if(i % sz == 0) idx[i].fi++, idx[i].se = 0;
else idx[i].se++;
}
X[0][0] = Y[0][0] = 1;
for(int i=1; i <= sz * sz; i++) {
if(i <= n) cin >> x[i] >> y[i];
X[idx[i].fi][idx[i].se] = X[idx[i-1].fi][idx[i-1].se] + x[i];
Y[idx[i].fi][idx[i].se] = Y[idx[i-1].fi][idx[i-1].se] + y[i];
}
for(int i=0; i<sz; i++) {
upd(i);
}
cin >> m;
int cur = 1;
while(m--) {
char c;
cin >> c;
if(c == 'B') cur = max(1, cur - 1);
else if(c == 'F') cur = min(n, cur + 1);
else if(c == 'Q') {
int ret = 0;
for(int i = 0; i < sz; i++) {
if(i && (ll) (X[i][0] - xh[i]) * (X[i-1][sz-1] - xh[i-1]) < 0) ret++;
if(i && (ll) (Y[i][0] - yh[i]) * (Y[i-1][sz-1] - yh[i-1]) < 0) ret++;
ret += lower_bound(xans[0][i], xans[0][i] + sz - 1, xh[i]) - xans[0][i];
ret -= lower_bound(xans[1][i], xans[1][i] + sz - 1, xh[i]) - xans[1][i];
ret += lower_bound(yans[0][i], yans[0][i] + sz - 1, yh[i]) - yans[0][i];
ret -= lower_bound(yans[1][i], yans[1][i] + sz - 1, yh[i]) - yans[1][i];
}
cout << ret << "\n";
}
else {
int dx = -x[cur];
int dy = -y[cur];
cin >> x[cur] >> y[cur];
dx += x[cur];
dy += y[cur];
for(int i = idx[cur].fi + 1; i < sz; i++) {
xh[i] -= dx;
yh[i] -= dy;
}
for(int i = idx[cur].se; i < sz; i++) {
X[idx[cur].fi][i] += dx;
Y[idx[cur].fi][i] += dy;
}
upd(idx[cur].fi);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2048 KB |
Output is correct |
2 |
Correct |
15 ms |
2048 KB |
Output is correct |
3 |
Correct |
30 ms |
2048 KB |
Output is correct |
4 |
Correct |
29 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2048 KB |
Output is correct |
2 |
Correct |
15 ms |
2048 KB |
Output is correct |
3 |
Correct |
30 ms |
2048 KB |
Output is correct |
4 |
Correct |
29 ms |
2048 KB |
Output is correct |
5 |
Correct |
1623 ms |
2736 KB |
Output is correct |
6 |
Correct |
1784 ms |
2424 KB |
Output is correct |
7 |
Execution timed out |
2064 ms |
2680 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2048 KB |
Output is correct |
2 |
Correct |
15 ms |
2048 KB |
Output is correct |
3 |
Correct |
30 ms |
2048 KB |
Output is correct |
4 |
Correct |
29 ms |
2048 KB |
Output is correct |
5 |
Correct |
1623 ms |
2736 KB |
Output is correct |
6 |
Correct |
1784 ms |
2424 KB |
Output is correct |
7 |
Execution timed out |
2064 ms |
2680 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |