이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N = 1e5+7;
int n, q;
pair<int, int> a[N];
int solve()
{
int res=0;
int x=1, y=1;
bool c1=true, c2=true;
for(int i=1; i<=n; i++)
{
x+=a[i].fi, y+=a[i].se;
if((c1&&x<0)||(!c1&&x>0))
{
res++;
c1^=1;
}
if((c2&&y<0)||(!c2&&y>0))
{
res++;
c2^=1;
}
}
return res;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1; i<=n; i++) 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |