답안 #51049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51049 2018-06-15T17:42:56 Z SpaimaCarpatilor Matryoshka (JOI16_matryoshka) C++17
0 / 100
3 ms 660 KB
#include<bits/stdc++.h>

using namespace std;

int nr, N, Q, h[100009];
pair < int, int > v[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &Q);
for (int i=1; i<=N; i++)
    scanf ("%d %d", &v[i].first, &v[i].second);
sort (v + 1, v + N + 1);
while (Q --)
{
    int X, Y;
    scanf ("%d %d", &X, &Y), nr = 0;
    for (int i=1; i<=N; i++)
        if (v[i].first >= X && v[i].second <= Y)
            h[++nr] = v[i].second;
    set < int > S;
    for (int i=1; i<=nr; i++)
    {
        auto it = S.upper_bound (h[i]);
        if (it == S.begin ()) S.insert (h[i]);
        else
        {
            it --;
            S.erase (it), S.insert (h[i]);
        }
    }
    printf ("%d\n", S.size ());
}
return 0;
}

Compilation message

matryoshka.cpp: In function 'int main()':
matryoshka.cpp:35:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf ("%d\n", S.size ());
                     ~~~~~~~~~^
matryoshka.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d", &N, &Q);
 ~~~~~~^~~~~~~~~~~~~~~~~
matryoshka.cpp:15:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &v[i].first, &v[i].second);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:20:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &X, &Y), nr = 0;
     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Incorrect 3 ms 660 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Incorrect 3 ms 660 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Incorrect 3 ms 660 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Incorrect 3 ms 660 KB Output isn't correct