답안 #883380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883380 2023-12-05T08:44:31 Z vjudge1 Ruka (COI15_ruka) C++17
9 / 100
2000 ms 1620 KB
#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=!c1;
        }
        if((c2&&y<0)||(!c2&&y>0))
        {
            res++;
            c2=!c2;
        }
    }
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Execution timed out 2008 ms 1620 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Execution timed out 2008 ms 1620 KB Time limit exceeded
6 Halted 0 ms 0 KB -