Submission #973423

# Submission time Handle Problem Language Result Execution time Memory
973423 2024-05-02T01:45:07 Z fatman87878 Joker (BOI20_joker) C++17
100 / 100
240 ms 17848 KB
/*
The middle of adventure, such a perfect place to start
⣿⣿⣿⣿⣿⣿⣿⢿⠟⢿⣿⣿⣿⣿⠿⠛⠛⠿⢿⣿⣿⣿⣿⠛⣿⢿⣿⣿⣿⣿
⣿⣿⣿⡿⢿⣿⣿⣄⠄⣼⣿⡿⠋⠄⠄⠄⠄⠄⠄⠄⠛⣿⣿⠄⢀⣤⣿⣿⣿⣿
⣿⣿⣷⣤⣸⣿⠛⡛⢛⣿⠋⠄⠄⢀⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⡿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⡿⠁⠄⠁⠈⠄⠄⠄⠄⣿⡀⠄⠄⠄⠄⠄⠄⠄⠓⠸⠏⠄⢹⣿⣿⣿
⣿⣿⣿⡿⠄⠄⠄⠄⠄⠄⠄⢠⠿⠿⢻⣦⣤⣠⠄⠄⠄⠄⠄⠄⠄⠄⠈⠻⣿⣿
⣿⣿⡿⠁⠄⠄⠄⠄⠈⠄⠄⢸⣿⣿⣿⣿⣿⢭⡛⡀⠄⠄⠨⠄⠄⠄⠄⠄⣿⣿
⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠻⣧⡀⣈⣿⣿⠟⠄⠄⠠⢇⠄⠄⠄⠄⠄⣿⣿
⣿⡁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⢀⣉⡉⠉⠄⠄⠄⠄⠄⠰⠂⠄⠄⠄⠄⢹⣿
⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣿⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿
⣿⣿⣶⣤⣤⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣼⣿
We're not strangers to love
You know the rules, and so do I
A full comitment of what I'm thinking of
You can't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you, understand
Never gonna give you up
Never gonna let you down
Never gonna round around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
duh duh duh duh duh`
*/
#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt")
#include<bits/stdc++.h>
using namespace std;
#define IOS cin.tie(nullptr)->sync_with_stdio(0),cin.exceptions(cin.failbit);
#define lb(x) (x)&-(x)
#define INF 5e18
#define all(x) x.begin(),x.end()
#define I int
#define ll long long
#define pii pair<I,I>
#define pll pair<ll,ll>
#define F .first
#define S .second
#define ld long double
#define pdd pair<ld,ld>
#define rep(i,l,r) for(I i = l;i<r;i++)
constexpr I maxN=2e5+5;

I n,m,q,oddcir,dp[maxN],dsu[maxN<<1];

pii edges[maxN];

vector<pii> opt;

inline I find(I pos){
    return dsu[pos]<0?pos:find(dsu[pos]);
}

inline void join(I a,I b){
    I fa=find(a),fb=find(b);
    if(fa==fb)return;
    if(dsu[fa]<dsu[fb])swap(fa,fb),swap(a,b);
    opt.emplace_back(fa,dsu[fa]),opt.emplace_back(fb,dsu[fb]);
    dsu[fb]+=dsu[fa],dsu[fa]=fb;
    if(find(2*n+1-a)==fb||find(2*n+1-b)==fb)opt.emplace_back(-1,oddcir),oddcir++;
}

inline void add(I a,I b){
    join(a,2*n+1-b),join(b,2*n+1-a);
}

inline void query(I l,I r){
    for(;l<=r;l++)add(edges[l] F,edges[l] S);
}

inline void roll_back(I val){
    for(;opt.size()>val;opt.pop_back()){
        if(opt.back() F>0)dsu[opt.back() F]=opt.back() S;
        else oddcir--;
    }
}

void fun_and_jizz(I tl,I tr,I l,I r){
    if(l>r)return;
    I mid=l+r>>1,t=tl-1,chkpt0,chkpt1;
    chkpt0=opt.size();
    query(mid+1,r);
    for(chkpt1=opt.size();!oddcir&&t<min(tr,mid+1);)++t,query(t,t);
    dp[mid]=t;
    roll_back(chkpt1);
    query(mid,mid);
    t=max(tl,t);
    fun_and_jizz(tl,t,l,mid-1);
    roll_back(chkpt0);
    query(tl,t-1);
    fun_and_jizz(t,tr,mid+1,r);
    roll_back(chkpt0);
}

I main(){
    IOS
    cin>>n>>m>>q;
    fill(dsu,dsu+(n<<1|1),-1);
    rep(i,1,m+1)cin>>edges[i] F>>edges[i] S;
    fun_and_jizz(1,m,1,m);
    for(I a,b;q--;)cin>>a>>b,cout<<(a>dp[b]?"YES\n":"NO\n");
}

Compilation message

Joker.cpp: In function 'void roll_back(int)':
Joker.cpp:74:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |     for(;opt.size()>val;opt.pop_back()){
      |          ~~~~~~~~~~^~~~
Joker.cpp: In function 'void fun_and_jizz(int, int, int, int)':
Joker.cpp:82:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   82 |     I mid=l+r>>1,t=tl-1,chkpt0,chkpt1;
      |           ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2516 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2516 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2528 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2532 KB Output is correct
41 Correct 1 ms 2848 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2532 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2648 KB Output is correct
48 Correct 2 ms 2676 KB Output is correct
49 Correct 2 ms 2532 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 2 ms 2648 KB Output is correct
53 Correct 2 ms 2652 KB Output is correct
54 Correct 2 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 122 ms 8060 KB Output is correct
4 Correct 187 ms 16072 KB Output is correct
5 Correct 141 ms 16984 KB Output is correct
6 Correct 116 ms 11648 KB Output is correct
7 Correct 134 ms 11632 KB Output is correct
8 Correct 158 ms 9416 KB Output is correct
9 Correct 177 ms 11200 KB Output is correct
10 Correct 232 ms 16112 KB Output is correct
11 Correct 160 ms 11708 KB Output is correct
12 Correct 177 ms 16028 KB Output is correct
13 Correct 130 ms 8564 KB Output is correct
14 Correct 163 ms 9968 KB Output is correct
15 Correct 207 ms 15504 KB Output is correct
16 Correct 230 ms 15544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2516 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 122 ms 8060 KB Output is correct
30 Correct 187 ms 16072 KB Output is correct
31 Correct 141 ms 16984 KB Output is correct
32 Correct 116 ms 11648 KB Output is correct
33 Correct 134 ms 11632 KB Output is correct
34 Correct 158 ms 9416 KB Output is correct
35 Correct 177 ms 11200 KB Output is correct
36 Correct 232 ms 16112 KB Output is correct
37 Correct 160 ms 11708 KB Output is correct
38 Correct 177 ms 16028 KB Output is correct
39 Correct 130 ms 8564 KB Output is correct
40 Correct 163 ms 9968 KB Output is correct
41 Correct 207 ms 15504 KB Output is correct
42 Correct 230 ms 15544 KB Output is correct
43 Correct 131 ms 11676 KB Output is correct
44 Correct 188 ms 16568 KB Output is correct
45 Correct 140 ms 16948 KB Output is correct
46 Correct 117 ms 12484 KB Output is correct
47 Correct 124 ms 11736 KB Output is correct
48 Correct 208 ms 12252 KB Output is correct
49 Correct 231 ms 16056 KB Output is correct
50 Correct 144 ms 11820 KB Output is correct
51 Correct 175 ms 15384 KB Output is correct
52 Correct 177 ms 15532 KB Output is correct
53 Correct 135 ms 8980 KB Output is correct
54 Correct 188 ms 11716 KB Output is correct
55 Correct 211 ms 15812 KB Output is correct
56 Correct 237 ms 16324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2516 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2528 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2532 KB Output is correct
41 Correct 1 ms 2848 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2532 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2648 KB Output is correct
48 Correct 2 ms 2676 KB Output is correct
49 Correct 2 ms 2532 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 2 ms 2648 KB Output is correct
53 Correct 2 ms 2652 KB Output is correct
54 Correct 2 ms 2648 KB Output is correct
55 Correct 98 ms 9428 KB Output is correct
56 Correct 158 ms 16236 KB Output is correct
57 Correct 116 ms 15808 KB Output is correct
58 Correct 87 ms 10700 KB Output is correct
59 Correct 172 ms 10440 KB Output is correct
60 Correct 207 ms 14792 KB Output is correct
61 Correct 136 ms 11228 KB Output is correct
62 Correct 169 ms 15308 KB Output is correct
63 Correct 121 ms 7116 KB Output is correct
64 Correct 179 ms 10872 KB Output is correct
65 Correct 225 ms 14544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2516 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2516 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2528 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2532 KB Output is correct
41 Correct 1 ms 2848 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2532 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2648 KB Output is correct
48 Correct 2 ms 2676 KB Output is correct
49 Correct 2 ms 2532 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2648 KB Output is correct
52 Correct 2 ms 2648 KB Output is correct
53 Correct 2 ms 2652 KB Output is correct
54 Correct 2 ms 2648 KB Output is correct
55 Correct 122 ms 8060 KB Output is correct
56 Correct 187 ms 16072 KB Output is correct
57 Correct 141 ms 16984 KB Output is correct
58 Correct 116 ms 11648 KB Output is correct
59 Correct 134 ms 11632 KB Output is correct
60 Correct 158 ms 9416 KB Output is correct
61 Correct 177 ms 11200 KB Output is correct
62 Correct 232 ms 16112 KB Output is correct
63 Correct 160 ms 11708 KB Output is correct
64 Correct 177 ms 16028 KB Output is correct
65 Correct 130 ms 8564 KB Output is correct
66 Correct 163 ms 9968 KB Output is correct
67 Correct 207 ms 15504 KB Output is correct
68 Correct 230 ms 15544 KB Output is correct
69 Correct 131 ms 11676 KB Output is correct
70 Correct 188 ms 16568 KB Output is correct
71 Correct 140 ms 16948 KB Output is correct
72 Correct 117 ms 12484 KB Output is correct
73 Correct 124 ms 11736 KB Output is correct
74 Correct 208 ms 12252 KB Output is correct
75 Correct 231 ms 16056 KB Output is correct
76 Correct 144 ms 11820 KB Output is correct
77 Correct 175 ms 15384 KB Output is correct
78 Correct 177 ms 15532 KB Output is correct
79 Correct 135 ms 8980 KB Output is correct
80 Correct 188 ms 11716 KB Output is correct
81 Correct 211 ms 15812 KB Output is correct
82 Correct 237 ms 16324 KB Output is correct
83 Correct 98 ms 9428 KB Output is correct
84 Correct 158 ms 16236 KB Output is correct
85 Correct 116 ms 15808 KB Output is correct
86 Correct 87 ms 10700 KB Output is correct
87 Correct 172 ms 10440 KB Output is correct
88 Correct 207 ms 14792 KB Output is correct
89 Correct 136 ms 11228 KB Output is correct
90 Correct 169 ms 15308 KB Output is correct
91 Correct 121 ms 7116 KB Output is correct
92 Correct 179 ms 10872 KB Output is correct
93 Correct 225 ms 14544 KB Output is correct
94 Correct 132 ms 12472 KB Output is correct
95 Correct 186 ms 17076 KB Output is correct
96 Correct 156 ms 17848 KB Output is correct
97 Correct 115 ms 12988 KB Output is correct
98 Correct 130 ms 13116 KB Output is correct
99 Correct 169 ms 11172 KB Output is correct
100 Correct 212 ms 17368 KB Output is correct
101 Correct 152 ms 11580 KB Output is correct
102 Correct 181 ms 14940 KB Output is correct
103 Correct 203 ms 17136 KB Output is correct
104 Correct 161 ms 10436 KB Output is correct
105 Correct 209 ms 13456 KB Output is correct
106 Correct 240 ms 16072 KB Output is correct
107 Correct 93 ms 16648 KB Output is correct
108 Correct 127 ms 12140 KB Output is correct
109 Correct 127 ms 12220 KB Output is correct
110 Correct 126 ms 12180 KB Output is correct
111 Correct 131 ms 12360 KB Output is correct
112 Correct 128 ms 12736 KB Output is correct
113 Correct 127 ms 12224 KB Output is correct
114 Correct 123 ms 12280 KB Output is correct
115 Correct 130 ms 12996 KB Output is correct
116 Correct 124 ms 12240 KB Output is correct