답안 #107013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107013 2019-04-21T12:53:55 Z ttjaerom 곡선 자르기 (KOI17_cut) C++14
0 / 100
3 ms 384 KB
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<stack>

using namespace std;

int n;
int m;
priority_queue<pair<int,int> > q;
stack<int> s;
int temp;
int t=1;
int t2=0;
int ans1=1;
int ans2;

int buho(int a)
{
    if(a<0) return 1; //음수면 리턴1
    return 0; //양수면 리턴0
}

int main()
{
    scanf(" %d",&n);
    int i;
    int a,b;
    for(i=1;i<=n;i++)
    {
        scanf(" %d %d",&a,&b);
        
        if(i==1)
        {
            if(buho(b)==1) temp=-1;
            else temp=1;
        }
        
        if(buho(temp)!=buho(b)) //전좌표 현좌표 y좌표 부호가 다르면
        {
            q.push(make_pair(a,t));
            t2++;
            if(t2%2==0) t++;
        }
        temp=b;
    }
    s.push(q.top().second);
    q.pop();
    for(i=2;i<=t;i++)
    {
        m=q.top().second;
        if(s.top()==q.top().second)
        {
            s.pop();
            q.pop();
        }
        else
        {
            if(s.empty()) ans1++;
            s.push(q.top().second);
            q.pop();
        }
        if(q.top().second==m) ans2++;
    }
    printf("%d %d",ans1,ans2);
    return 0;
}

Compilation message

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