Submission #83415

# Submission time Handle Problem Language Result Execution time Memory
83415 2018-11-07T13:47:42 Z tjdgus4384 None (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);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -