Submission #334876

# Submission time Handle Problem Language Result Execution time Memory
334876 2020-12-10T06:51:56 Z beksultan04 Segments (IZhO18_segments) C++14
7 / 100
5000 ms 2072 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
set <int> s;
multiset <pair<int,pii> > m;
pii p[N];
int der[N];
set <int> ss;
int mex(){
    for(int i=1;i<=5001;++i){
        if (!ss.count(i))ret i;
    }
}

/*
void build(int v,int l,int r){
    if (l == r){
        der[v] = l;
        ret ;
    }
    else {
        int m = l+r>>1;
        build(v<<1,l,m);
        build((v<<1)+1,m+1,r);
        der[v] = min(der[v<<1],der[(v<<1)+1]);
    }
}

void update(int v,int l,int r,int x,int y){
    if (l == x && r == x){
        der[v] = y;
        ret ;
    }
    else {
        int m = l+r>>1;
        if (m < x){
            update((v<<1)+1,m+1,r,x,y);
        }
        else {
            update(v<<1,l,m,x,y);
        }
        der[v] = min(der[v<<1],der[(v<<1)+1]);
    }
}
*/
int fun(pii a,pii b){
    if (a.sc < b.fr || a.fr > b.sc)ret 0;
    ret min(a.sc,b.sc)-max(a.fr,b.fr)+1;
}

main(){
    int n,t,i,j,lastans=0;
    scan2(n,t)
    //build(1,1,200000);
    for (j=1;j<=n;++j){
        int type;
        scan1(type)
        if (type == 1){
            int x = mex(),l,r;
            scan2(l,r)
            ss.insert(x);
            //update(1,1,200000,x,INF);
            l = (l^(t*lastans));
            r = (r^(t*lastans));
            if (l > r)swap(l,r);
            p[x] = {l,r};
            m.insert({x,{l,r}});
        }
        if (type == 2){
            int id;
            scan1(id)
            //update(1,1,200000,id,id);
            s.erase(id);
            m.erase({id,{p[id].fr,p[id].sc}});
        }
        if (type == 3){
            int l,r,k,ans=0;
            scan3(l,r,k)
            l = (l^(t*lastans));
            r = (r^(t*lastans));

            if (l > r)swap(l,r);

            for (auto it: m){
                pii x = it.sc;
                if (fun({l,r},x) >= k)ans++;
            }
            cout <<ans<<"\n";
            lastans=ans;
        }
    }
}




Compilation message

segments.cpp:63:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   63 | main(){
      |      ^
segments.cpp: In function 'int main()':
segments.cpp:64:13: warning: unused variable 'i' [-Wunused-variable]
   64 |     int n,t,i,j,lastans=0;
      |             ^
segments.cpp: In function 'long long int mex()':
segments.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
   25 | }
      | ^
segments.cpp: In function 'int main()':
segments.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
segments.cpp:65:5: note: in expansion of macro 'scan2'
   65 |     scan2(n,t)
      |     ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:69:9: note: in expansion of macro 'scan1'
   69 |         scan1(type)
      |         ^~~~~
segments.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
segments.cpp:72:13: note: in expansion of macro 'scan2'
   72 |             scan2(l,r)
      |             ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:83:13: note: in expansion of macro 'scan1'
   83 |             scan1(id)
      |             ^~~~~
segments.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
segments.cpp:90:13: note: in expansion of macro 'scan3'
   90 |             scan3(l,r,k)
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 41 ms 492 KB Output is correct
4 Correct 41 ms 492 KB Output is correct
5 Correct 388 ms 892 KB Output is correct
6 Correct 326 ms 748 KB Output is correct
7 Correct 86 ms 620 KB Output is correct
8 Correct 275 ms 784 KB Output is correct
9 Correct 245 ms 748 KB Output is correct
10 Correct 472 ms 1132 KB Output is correct
11 Correct 176 ms 620 KB Output is correct
12 Correct 177 ms 748 KB Output is correct
13 Correct 462 ms 1004 KB Output is correct
14 Correct 225 ms 748 KB Output is correct
15 Correct 43 ms 492 KB Output is correct
16 Correct 44 ms 492 KB Output is correct
17 Correct 140 ms 620 KB Output is correct
18 Correct 396 ms 1004 KB Output is correct
19 Correct 141 ms 620 KB Output is correct
20 Correct 154 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 2072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5051 ms 1336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5084 ms 1184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 41 ms 492 KB Output is correct
4 Correct 41 ms 492 KB Output is correct
5 Correct 388 ms 892 KB Output is correct
6 Correct 326 ms 748 KB Output is correct
7 Correct 86 ms 620 KB Output is correct
8 Correct 275 ms 784 KB Output is correct
9 Correct 245 ms 748 KB Output is correct
10 Correct 472 ms 1132 KB Output is correct
11 Correct 176 ms 620 KB Output is correct
12 Correct 177 ms 748 KB Output is correct
13 Correct 462 ms 1004 KB Output is correct
14 Correct 225 ms 748 KB Output is correct
15 Correct 43 ms 492 KB Output is correct
16 Correct 44 ms 492 KB Output is correct
17 Correct 140 ms 620 KB Output is correct
18 Correct 396 ms 1004 KB Output is correct
19 Correct 141 ms 620 KB Output is correct
20 Correct 154 ms 640 KB Output is correct
21 Execution timed out 5054 ms 2072 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 41 ms 492 KB Output is correct
4 Correct 41 ms 492 KB Output is correct
5 Correct 388 ms 892 KB Output is correct
6 Correct 326 ms 748 KB Output is correct
7 Correct 86 ms 620 KB Output is correct
8 Correct 275 ms 784 KB Output is correct
9 Correct 245 ms 748 KB Output is correct
10 Correct 472 ms 1132 KB Output is correct
11 Correct 176 ms 620 KB Output is correct
12 Correct 177 ms 748 KB Output is correct
13 Correct 462 ms 1004 KB Output is correct
14 Correct 225 ms 748 KB Output is correct
15 Correct 43 ms 492 KB Output is correct
16 Correct 44 ms 492 KB Output is correct
17 Correct 140 ms 620 KB Output is correct
18 Correct 396 ms 1004 KB Output is correct
19 Correct 141 ms 620 KB Output is correct
20 Correct 154 ms 640 KB Output is correct
21 Execution timed out 5054 ms 2072 KB Time limit exceeded
22 Halted 0 ms 0 KB -