Submission #495835

# Submission time Handle Problem Language Result Execution time Memory
495835 2021-12-20T06:03:18 Z kingline Segments (IZhO18_segments) C++17
7 / 100
5000 ms 5240 KB
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >

using namespace std;

const int M = 4e5 + 5;
//const int mod = 1e9 + 7;

int n, t;

main() {
    //file("pieaters");
    /*ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    cin >> n >> t;
    int id = 0, last = 0, cs = 0;
    multiset < pair < int, pii > > st;
    while(n--) {
        int tp, a, b, k;
        cin >> tp;
        if(tp == 1) {
            cin >> a >> b;
            a ^= (t * last);
            b ^= (t * last);
            if(a > b) swap(a, b);
            st.insert({++id, {a, b}});
        } else if(tp == 2) {
            cin >> k;
            st.erase(*st.lower_bound({k, {0, 0}}));
        } else {
            cin >> a >> b >> k;
            a = a ^ (last * t);
            b = b ^ (last * t);
            if(a > b) swap(a, b);
            int ans = 0;
            //cout << "Case " << ++cs << ": " << a << " " << b << endl;
            for(multiset < pair < int, pii > >::iterator it = st.begin(); it != st.end(); it++) {
                pii z = (*it).second;
                //cout << z.first << " " << z.second << endl;
                if(min(z.second, b) - max(z.first, a) + 1 >= k) {
                    ans++;
                }
            }
            cout << ans << endl;
            last = ans;
        }
    }
}






Compilation message

segments.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main() {
      | ^~~~
segments.cpp: In function 'int main()':
segments.cpp:23:27: warning: unused variable 'cs' [-Wunused-variable]
   23 |     int id = 0, last = 0, cs = 0;
      |                           ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 204 KB Output is correct
4 Correct 7 ms 204 KB Output is correct
5 Correct 39 ms 460 KB Output is correct
6 Correct 46 ms 508 KB Output is correct
7 Correct 16 ms 332 KB Output is correct
8 Correct 21 ms 460 KB Output is correct
9 Correct 24 ms 460 KB Output is correct
10 Correct 11 ms 460 KB Output is correct
11 Correct 51 ms 448 KB Output is correct
12 Correct 54 ms 452 KB Output is correct
13 Correct 13 ms 540 KB Output is correct
14 Correct 26 ms 332 KB Output is correct
15 Correct 9 ms 204 KB Output is correct
16 Correct 8 ms 204 KB Output is correct
17 Correct 21 ms 380 KB Output is correct
18 Correct 21 ms 504 KB Output is correct
19 Correct 21 ms 380 KB Output is correct
20 Correct 21 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5036 ms 3692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 155 ms 324 KB Output is correct
2 Correct 132 ms 316 KB Output is correct
3 Correct 206 ms 668 KB Output is correct
4 Correct 146 ms 328 KB Output is correct
5 Execution timed out 5081 ms 4808 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 312 KB Output is correct
2 Correct 147 ms 432 KB Output is correct
3 Correct 150 ms 296 KB Output is correct
4 Correct 163 ms 296 KB Output is correct
5 Execution timed out 5038 ms 5240 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 204 KB Output is correct
4 Correct 7 ms 204 KB Output is correct
5 Correct 39 ms 460 KB Output is correct
6 Correct 46 ms 508 KB Output is correct
7 Correct 16 ms 332 KB Output is correct
8 Correct 21 ms 460 KB Output is correct
9 Correct 24 ms 460 KB Output is correct
10 Correct 11 ms 460 KB Output is correct
11 Correct 51 ms 448 KB Output is correct
12 Correct 54 ms 452 KB Output is correct
13 Correct 13 ms 540 KB Output is correct
14 Correct 26 ms 332 KB Output is correct
15 Correct 9 ms 204 KB Output is correct
16 Correct 8 ms 204 KB Output is correct
17 Correct 21 ms 380 KB Output is correct
18 Correct 21 ms 504 KB Output is correct
19 Correct 21 ms 380 KB Output is correct
20 Correct 21 ms 332 KB Output is correct
21 Execution timed out 5036 ms 3692 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 204 KB Output is correct
4 Correct 7 ms 204 KB Output is correct
5 Correct 39 ms 460 KB Output is correct
6 Correct 46 ms 508 KB Output is correct
7 Correct 16 ms 332 KB Output is correct
8 Correct 21 ms 460 KB Output is correct
9 Correct 24 ms 460 KB Output is correct
10 Correct 11 ms 460 KB Output is correct
11 Correct 51 ms 448 KB Output is correct
12 Correct 54 ms 452 KB Output is correct
13 Correct 13 ms 540 KB Output is correct
14 Correct 26 ms 332 KB Output is correct
15 Correct 9 ms 204 KB Output is correct
16 Correct 8 ms 204 KB Output is correct
17 Correct 21 ms 380 KB Output is correct
18 Correct 21 ms 504 KB Output is correct
19 Correct 21 ms 380 KB Output is correct
20 Correct 21 ms 332 KB Output is correct
21 Execution timed out 5036 ms 3692 KB Time limit exceeded
22 Halted 0 ms 0 KB -