답안 #107008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107008 2019-04-21T12:46:55 Z chan12 곡선 자르기 (KOI17_cut) C++
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int N, Dot[1000000][2];

int fwd(int a)
{
    if(a == N-1) return Dot[0][1];
    return Dot[a+1][1];
}

int bwd(int b)
{
    if(!b) return Dot[N-1][1];
    return Dot[b-1][1];
}

int compareBig(int X, int Y)
{
    if(X>=Y) return X;
    return Y;
}

int compareSmall(int A, int B)
{
    if(B>=A) return A;
    return B;
}

int main()
{
    int i, j, k=0, gotoN=0, Save = 0;
    scanf("%d", &N);
    int Line[N][2];
    for(i=0; i<N; i++)
    {
        scanf("%d %d", &Dot[i][0], &Dot[i][1]);
    }
    for(i=0; i<N; i++)
    {
        if(Dot[i][1]<0 && fwd(i)>0 && bwd(i)<0)
        {
            gotoN = 1;
            Line[k][0] = Dot[i][0];
        } else if(Dot[i][1]<0 && fwd(i)<0 && bwd(i)>0)
        {
            if(gotoN)
            {
                gotoN = 0;
                Line[k][1] = Dot[i][0];
                k++;
            } else
            {
                Save = 1;
                Line[0][1] = Dot[i][0];
                k++;
            }
        }
    }
    if(Save)
    {
        Line[0][0] = Line[k][0];
    }
    int ans1 = k, ans2=0;
    int Checklist[k];
    for(i=0; i<k; i++)
        Checklist[i]=1;
    for(i=0; i<k-1; i++)
    {
        for(j=i+1; j<k; j++)
        {
            if(compareSmall(Line[i][1],Line[i][0])>compareSmall(Line[j][1],Line[j][0]))
            {
                if(compareBig(Line[i][1],Line[i][0])<compareBig(Line[j][1],Line[j][0]))
                {
                    ans1--;
                    Checklist[j]=0;
                }
            }
            else if(compareSmall(Line[i][1],Line[i][0])<compareSmall(Line[j][1],Line[j][0]))
            {
                if(compareBig(Line[i][1],Line[i][0])>compareBig(Line[j][1],Line[j][0]))
                {
                    ans1--;
                    Checklist[i]=0;
                }
            }
        }
    }
    for(i=0; i<k; i++)
    {
        ans2 += Checklist[i];
    }
    printf("%d %d", ans1, ans2);
    return 0;
}



Compilation message

cut.cpp: In function 'int main()':
cut.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
cut.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &Dot[i][0], &Dot[i][1]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -