Submission #277272

# Submission time Handle Problem Language Result Execution time Memory
277272 2020-08-21T04:31:04 Z 반딧불(#5119) Interval Collection (CCO20_day2problem2) C++17
4 / 25
1046 ms 56060 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int q;
set<pair<int, int> > st;
multiset<int> mst;

int main(){
    scanf("%d", &q);
    while(q--){
        char c;
        scanf(" %c", &c);
        if(c == 'A'){
            int s, e;
            scanf("%d %d", &s, &e);
            auto it = st.lower_bound({s, e});
            if(it != st.begin() && it != st.end()){
                auto it2 = prev(it);
                mst.erase(mst.find(it->second - it2->first));
            }
            if(it != st.end()){
                mst.insert(it->second - s);
            }
            if(it != st.begin()){
                mst.insert(e - prev(it)->first);
            }
            st.insert({s, e});
        }
        else{
            int s, e;
            scanf("%d %d", &s, &e);
            st.erase({s, e});

            auto it = st.lower_bound({s, e});
            if(it != st.begin() && it != st.end()){
                auto it2 = prev(it);
                mst.insert(it->second - it2->first);
            }
            if(it != st.end()){
                mst.erase(mst.find(it->second - s));
            }
            if(it != st.begin()){
                mst.erase(mst.find(e - prev(it)->first));
            }
        }
        if(st.size() == 1) printf("%d\n", st.begin()->second - st.begin()->first);
        else printf("%d\n", *mst.begin());
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
Main.cpp:18:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |             scanf("%d %d", &s, &e);
      |             ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |             scanf("%d %d", &s, &e);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 237 ms 22616 KB Output is correct
2 Correct 250 ms 22648 KB Output is correct
3 Correct 470 ms 44920 KB Output is correct
4 Correct 469 ms 44820 KB Output is correct
5 Correct 641 ms 56036 KB Output is correct
6 Correct 639 ms 56060 KB Output is correct
7 Correct 815 ms 9464 KB Output is correct
8 Correct 728 ms 7664 KB Output is correct
9 Correct 632 ms 7428 KB Output is correct
10 Correct 981 ms 11104 KB Output is correct
11 Correct 691 ms 7824 KB Output is correct
12 Correct 615 ms 7380 KB Output is correct
13 Correct 1046 ms 11860 KB Output is correct
14 Correct 669 ms 7700 KB Output is correct
15 Correct 639 ms 7416 KB Output is correct
16 Correct 466 ms 8824 KB Output is correct
17 Correct 488 ms 8664 KB Output is correct
18 Correct 476 ms 8860 KB Output is correct
19 Correct 473 ms 8596 KB Output is correct
20 Correct 469 ms 8712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -