답안 #883422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883422 2023-12-05T09:14:09 Z stelle Ruka (COI15_ruka) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int x[N],y[N];
int n,q;
int tinh()
{
    int ans=0;
    int x1=1,y1=1;
    for(int i=1;i<=n;i++)
    {
        int ul,yl;
        ul=x1+x[i];
        yl=y1+y[i];
        if(x1*y1*ul*yl<0)ans++;
        if(x1<0&&y1<0&&ul>0&&yl>0)ans+=2;
        if(x1>0&&y1>0&&ul<0&&yl<0)ans+=2;
        if(x1<0&&y1>0&&ul>0&&yl<0)ans+=2;
        if(x1>0&&y1<0&&ul<0&&yl>0)ans+=2;
        x1=ul;
        y1=yl;
    }
    return ans;
}
void sub1()
{
    int i=1;
    while(q--)
    {
        char a;
        cin>>a;
        if(a=='B')
        {
            if(i==1)continue;
            i--;
        }
        if(a=='F')
        {
            if(i!=n)
            {
                i++;
            }
        }
        if(a=='Q')
        {
            cout<<tinh()<<'\n';
        }
        if(a=='C')
        {
            int nx,ny;
            cin>>nx>>ny;
            x[i]=nx;
            y[i]=ny;
        }
    }
}
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen("simulation.inp","r",stdin);
    freopen("simulation.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>x[i]>>y[i];
    cin>>q;
    if(n<=1000)
    {
        sub1();
        return 0;
    }
}

Compilation message

ruka.cpp: In function 'int main()':
ruka.cpp:62:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |     freopen("simulation.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ruka.cpp:63:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |     freopen("simulation.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -