답안 #172736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172736 2020-01-02T13:40:49 Z arnold518 Matryoshka (JOI16_matryoshka) C++14
51 / 100
2000 ms 8312 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;

struct Point
{
    int x, y;
};

int N, Q;
Point A[MAXN+10];

int main()
{
    int i, j;

    scanf("%d%d", &N, &Q);
    for(i=1; i<=N; i++) scanf("%d%d", &A[i].x, &A[i].y);

    while(Q--)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        vector<Point> V;
        for(j=1; j<=N; j++) if(A[j].x>=a && A[j].y<=b) V.push_back({A[j].x, A[j].y});
        sort(V.begin(), V.end(), [&](const Point &p, const Point &q)
             {
                 if(p.x!=q.x) return p.x<q.x;
                 return p.y>q.y;
             });

        int ans=V.size();
        multiset<int> S;
        for(i=0; i<V.size();)
        {
            for(j=i; j<V.size() && V[j].x==V[i].x; j++)
            {
                auto it = S.lower_bound(V[j].y);
                if(it==S.begin()) continue;
                it--;
                S.erase(it); ans--;
            }
            for(j=i; j<V.size() && V[j].x==V[i].x; j++)
            {
                S.insert(V[j].y);
            }
            i=j;
        }
        printf("%d\n", ans);
    }
}

Compilation message

matryoshka.cpp: In function 'int main()':
matryoshka.cpp:39:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0; i<V.size();)
                  ~^~~~~~~~~
matryoshka.cpp:41:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(j=i; j<V.size() && V[j].x==V[i].x; j++)
                      ~^~~~~~~~~
matryoshka.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(j=i; j<V.size() && V[j].x==V[i].x; j++)
                      ~^~~~~~~~~
matryoshka.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &Q);
     ~~~~~^~~~~~~~~~~~~~~~
matryoshka.cpp:23:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d%d", &A[i].x, &A[i].y);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:28: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 2 ms 700 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 63 ms 376 KB Output is correct
23 Correct 255 ms 488 KB Output is correct
24 Correct 134 ms 532 KB Output is correct
25 Correct 335 ms 484 KB Output is correct
26 Correct 150 ms 504 KB Output is correct
27 Correct 126 ms 516 KB Output is correct
28 Correct 351 ms 504 KB Output is correct
29 Correct 331 ms 760 KB Output is correct
30 Correct 296 ms 376 KB Output is correct
31 Correct 257 ms 532 KB Output is correct
32 Correct 261 ms 632 KB Output is correct
33 Correct 251 ms 508 KB Output is correct
34 Correct 248 ms 632 KB Output is correct
35 Correct 261 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 63 ms 376 KB Output is correct
23 Correct 255 ms 488 KB Output is correct
24 Correct 134 ms 532 KB Output is correct
25 Correct 335 ms 484 KB Output is correct
26 Correct 150 ms 504 KB Output is correct
27 Correct 126 ms 516 KB Output is correct
28 Correct 351 ms 504 KB Output is correct
29 Correct 331 ms 760 KB Output is correct
30 Correct 296 ms 376 KB Output is correct
31 Correct 257 ms 532 KB Output is correct
32 Correct 261 ms 632 KB Output is correct
33 Correct 251 ms 508 KB Output is correct
34 Correct 248 ms 632 KB Output is correct
35 Correct 261 ms 504 KB Output is correct
36 Execution timed out 2027 ms 8312 KB Time limit exceeded
37 Halted 0 ms 0 KB -