제출 #83415

#제출 시각아이디문제언어결과실행 시간메모리
83415tjdgus4384곡선 자르기 (KOI17_cut)C++14
0 / 100
2 ms416 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...