제출 #172736

#제출 시각아이디문제언어결과실행 시간메모리
172736arnold518Matryoshka (JOI16_matryoshka)C++14
51 / 100
2027 ms8312 KiB
#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);
    }
}

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

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