Submission #51052

#TimeUsernameProblemLanguageResultExecution timeMemory
51052SpaimaCarpatilorMatryoshka (JOI16_matryoshka)C++17
0 / 100
3 ms704 KiB
#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 () && (it == S.end () || *it != h[i])) S.insert (h[i]); else { it --; S.erase (it), S.insert (h[i]); } } printf ("%d\n", S.size ()); } return 0; }

Compilation message (stderr)

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