답안 #83415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83415 2018-11-07T13:47:42 Z tjdgus4384 곡선 자르기 (KOI17_cut) C++14
0 / 100
2 ms 416 KB
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, int> > v;
vector<pair<int, int> > bong;

int main()
{
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d %d", &x, &y);
        v.push_back({x, y});
    }
    int state = 0, last;
    for(int i = 0;i < n;i++)
    {
        if((long long)v[i].second * v[i + 1].second < 0)
        {
            if(!state) last = v[i].first;
            else bong.push_back({min(last, v[i].first), max(last, v[i].first)});
            state ^= 1;
        }
    }
    sort(bong.begin(), bong.end());
    int ans1 = 0, ans2 = 0;
    x = -1000000000;
    for(int i = 0;i < bong.size();i++)
    {
        if(x < bong[i].first) ans1++;
        x = max(x, bong[i].second);
        if(i == bong.size() - 1 || bong[i + 1].first > bong[i].second) ans2++;
    }
    printf("%d %d", ans1, ans2);
    return 0;
}

Compilation message

cut.cpp: In function 'int main()':
cut.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < bong.size();i++)
                   ~~^~~~~~~~~~~~~
cut.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i == bong.size() - 1 || bong[i + 1].first > bong[i].second) ans2++;
            ~~^~~~~~~~~~~~~~~~~~
cut.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
cut.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 416 KB Output isn't correct
4 Halted 0 ms 0 KB -