# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
27271 |
2017-07-12T06:29:20 Z |
구사과(#1145) |
Ruka (COI15_ruka) |
C++11 |
|
2000 ms |
5532 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
struct jaryo{
vector<pi> v;
int offset;
void update(int dx){
offset += dx;
}
int query(){
int ans = 0;
for(auto &i : v){
if(i.first + offset < 0) ans += i.second;
}
return ans;
}
void add(pi x){
x.first -= offset;
v.push_back(x);
}
void erase(pi x){
x.first -= offset;
v.erase(find(v.begin(), v.end(), x));
}
}jx0, jx1, jy0, jy1;
void add(jaryo &j, int s, int e){
if(s > e) swap(s, e);
j.add(pi(s, 1));
j.add(pi(e, -1));
}
void rem(jaryo &j, int s, int e){
if(s > e) swap(s, e);
j.erase(pi(s, 1));
j.erase(pi(e, -1));
}
char buf[4];
int n, q, x[100005], y[100005];
int main(){
scanf("%d",&n);
for(int i=1; i<=n; i++) scanf("%d %d",&x[i],&y[i]);
int p = 1, sx = 1, sy = 1;
for(int i=1; i<=n; i++){
if(i != 1) add(jx1, sx, sx + x[i]);
if(i != 1) add(jy1, sy, sy + y[i]);
sx += x[i];
sy += y[i];
}
sx = sy = 1;
scanf("%d",&q);
while(q--){
scanf("%s", buf);
if(*buf == 'Q'){
int ans = jx0.query() + jx1.query() + jy0.query() + jy1.query();
if(1ll * sx * (sx + x[p]) < 0) ans++;
if(1ll * sy * (sy + y[p]) < 0) ans++;
printf("%d\n", ans);
}
if(*buf == 'B'){
if(p == 1) continue;
add(jx1, sx, sx + x[p]);
add(jy1, sy, sy + y[p]);
p--;
sx -= x[p];
sy -= y[p];
rem(jx0, sx, sx + x[p]);
rem(jy0, sy, sy + y[p]);
}
if(*buf == 'F'){
if(p == n) continue;
add(jx0, sx, sx + x[p]);
add(jy0, sy, sy + y[p]);
sx += x[p];
sy += y[p];
p++;
rem(jx1, sx, sx + x[p]);
rem(jy1, sy, sy + y[p]);
}
if(*buf == 'C'){
int nx, ny;
scanf("%d %d",&nx,&ny);
jx1.update(nx - x[p]);
jy1.update(ny - y[p]);
x[p] = nx, y[p] = ny;
}
}
}
Compilation message
ruka.cpp: In function 'int main()':
ruka.cpp:46:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
ruka.cpp:47:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i=1; i<=n; i++) scanf("%d %d",&x[i],&y[i]);
^
ruka.cpp:56:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
ruka.cpp:58:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", buf);
^
ruka.cpp:87:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&nx,&ny);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
3 ms |
2936 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
3 ms |
2800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
3 ms |
2936 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
3 ms |
2800 KB |
Output is correct |
5 |
Execution timed out |
2000 ms |
5532 KB |
Execution timed out |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
3 ms |
2936 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
3 ms |
2800 KB |
Output is correct |
5 |
Execution timed out |
2000 ms |
5532 KB |
Execution timed out |
6 |
Halted |
0 ms |
0 KB |
- |