CC Wing Selection Contest 2026

Revision en2, by vishwas_16.0, 2026-08-12 09:54:52

Editorial — CC Wing Selection Contest 2026

CC-Wing Trial GeekHaven 2026

Problem A : Terms and Conditions
Author : vishwas_16.0

Hint 1
Solution
Code

Problem B: Guess the Permutation

Hint 1
Hint 2

Solution

  • query 1: indices $$$2,3,4 \Rightarrow q_1 = p_2+p_3+p_4$$$
  • query 2: indices $$$1,3,4 \Rightarrow q_2 = p_1+p_3+p_4$$$
  • query 3: indices $$$1,2,4 \Rightarrow q_3 = p_1+p_2+p_4$$$
  • query 4: indices $$$1,2,3 \Rightarrow q_4 = p_1+p_2+p_3$$$

Adding all four queries, every $$$p_i$$$ ($$$1 \le i \le 4$$$) is counted exactly $$$3$$$ times:

$$$q_1+q_2+q_3+q_4 = 3(p_1+p_2+p_3+p_4)$$$

So $$$\dfrac{q_1+q_2+q_3+q_4}{3} = p_1+p_2+p_3+p_4$$$.

Now for each $$$i \in {1,2,3,4}$$$, $$$q_i$$$ is exactly the sum of the other three values, i.e. $$$q_i = (p_1+p_2+p_3+p_4) - p_i$$$. Rearranging:

$$$p_i = \frac{q_1+q_2+q_3+q_4}{3} - q_i$$$

This recovers $$$p_1,p_2,p_3,p_4$$$ using just $$$4$$$ queries.

Once $$$p_1$$$ and $$$p_2$$$ are known, every remaining index $$$i$$$ ($$$5 \le i \le n$$$) can be found with a single query on indices $$$1,2,i$$$:

$$$p_i = \text{query}(1,2,i) - p_1 - p_2$$$

Total queries: $$$4 + (n-4) = n$$$, well within the interactive limit.

Time Complexity: $$$O(n)$$$ queries per test Space Complexity: $$$O(n)$$$

Code

include<bits/stdc++.h>

using namespace std;

int query(int i,int j,int k){ int x; cout << "? " << i << ' ' << j << ' ' << k << flush << endl; cin >> x; return x; }

int main(){ int t; cin >> t; while(t--){ int n; cin >> n; vector p(n+1); int q[5]; q[1] = query(2,3,4); q[2] = query(1,3,4); q[3] = query(1,2,4); q[4] = query(1,2,3); for(int i=1;i<=4;i++) p[i] = (q[1]+q[2]+q[3]+q[4])/3 — q[i]; for(int i=5;i<=n;i++) p[i] = query(1,2,i) — p[1] — p[2]; cout << "! "; for(int i=1;i<=n;i++) cout << p[i] << ' '; cout << flush << endl; } return 0; } ~~~~~

Problem C : Eleven Loves Mike
Author : vishwas_16.0

Hint 1

Rearrange using prefix sums: $$$ gain = (pref_b[r_2]-pref_b[l_2-1]) + (pref_a[l-1]-pref_a[r]). $$$

So while scanning rightwards you should keep best values of expressions like $$$(pref_a[l-1])$$$ and $$$(-pref_b[l_2-1]+pref_a[l-1])$$$ to build the optimal gain.

Hint 2

  • dp1[i] = max pref_a[0..i] — dp2[i] = max(dp2[i-1], -pref_b[i]+dp1[i]) — dp3[i] = max(dp3[i-1], dp2[i]+pref_b[i]) — dp4[i] = max(dp4[i-1], dp3[i]-pref_a[i])

The final answer is sum(a) + dp4[n].

Solution

Use four DP arrays to maintain best intermediate expressions (see hints). dp4[n] is the maximum extra sum achievable by removing some A[l..r] and inserting some B[l2..r2] with $$$(l \le l_2 \le r_2 \le r)$$$ (empty subarrays allowed).

The answer is sum(A) + dp4[n].

Code

include <bits/stdc++.h>

using namespace std;

typedef long long ll;

/* read vector */ void readVector(vector& v){ for(size_t i = 0; i < v.size(); ++i){ cin >> v[i]; } }

/* prefix sum: pref[i] = sum of first i elements (1-indexed logic) */ vector prefix(const vector& v){ int n = v.size(); vector pref(n + 1, 0); for(int i = 1; i <= n; ++i){ pref[i] = pref[i — 1] + v[i — 1]; } return pref; }

/* sum of vector */ ll sumV(const vector& v){ ll s = 0; for(ll x : v) s += x; return s; }

void resolve2(ll tc){ int n; cin >> n;

vector<ll> a(n);
readVector(a);

vector<ll> b(n);
readVector(b);

/*
    max(pref[r2]-pref[l2-1]-(pref[r]-pref[l-1]))
    l <= l2 <= r2 <= r
    transformed DP:
    max(-pref[r] + pref[r2] + pref[l-1] - pref[l2-1])
*/

vector<ll> pref = prefix(a);
vector<ll> prefb = prefix(b);

vector<ll> dp1(n + 1, 0); // max pref[l-1]
vector<ll> dp2(n + 1, 0); // max -prefb[i] + dp1[i]
vector<ll> dp3(n + 1, 0); // max dp2[j] + prefb[j]
vector<ll> dp4(n + 1, 0); // max dp3[j] - pref[j]

for(int i = 1; i <= n; ++i){
    dp1[i] = max(dp1[i - 1], pref[i]);
}

for(int i = 1; i <= n; ++i){
    dp2[i] = max(dp2[i - 1], -prefb[i] + dp1[i]);
}

for(int i = 1; i <= n; ++i){
    dp3[i] = max(dp3[i - 1], dp2[i] + prefb[i]);
}

for(int i = 1; i <= n; ++i){
    dp4[i] = max(dp4[i - 1], dp3[i] - pref[i]);
}

ll totSum = sumV(a);
cout << totSum + dp4[n] << '\n';

}

int main(){ ios::sync_with_stdio(false); cin.tie(NULL);

ll tc;
cin >> tc;
while(tc--){
    resolve2(tc);
}
return 0;

}

</spoiler>

[Problem D : Vecna and the Psychic Network]
(https://codeforces.me/gym/663321/problem/D)
 <br>
Author : [user:dheeraj.dontha,2026-02-01]
 

<spoiler summary="Hint 1"> The maximum strength of a connection between two chambers depends only on the maximum GCD achievable between one element from each chamber. You do not need to consider all possible pairs.</spoiler>

 

<spoiler summary="Hint 2"> A chamber can participate in an edge of weight g if it contains at least one number divisible by g. Use this to group chambers by divisors instead of building all possible edges.</spoiler>

 

<spoiler summary="Hint 3"> To maximize the total strength, process the groups in descending order of GCD and connect chambers greedily using a Disjoint Set Union (DSU) structure, similar to Kruskal's algorithm for Maximum Spanning Trees.</spoiler>

 

<spoiler summary="Solution"> We want to connect all psychic chambers into a single network with maximum total strength. Since the network must be connected and acyclic, this is a Maximum Spanning Tree problem.
 
For any two chambers, the best edge between them is the maximum GCD achievable between their elements. We do not need to explicitly build all edges.
 
Approach:
 
<ul> <li>For every value v, store all chambers that contain v.</li> <li>Iterate over all possible GCD values g from largest to smallest.</li> <li>For a fixed g, iterate over all multiples of g and collect all chambers that contain those values.</li> <li>Any two such chambers can be connected with an edge of weight at least g.</li> <li>Use Disjoint Set Union (DSU) to greedily connect these chambers. Each successful merge adds g to the total answer.</li> </ul>
 
Processing GCDs in descending order ensures that the first time two components are connected, they are connected using their maximum possible GCD. DSU guarantees no cycles and exactly N-1 edges.
 
This greedy procedure is equivalent to Kruskal's algorithm for Maximum Spanning Tree and produces the optimal result.
 
Time Complexity:
Enumerating multiples follows a harmonic series, giving O(M log M), where M = 2 * 10^5.
 
Space Complexity:
O(N + sum(k_i))
</spoiler>

 

<spoiler summary="Code"> 
~~~
#include <bits/stdc++.h>
using namespace std;
 
// Disjoint Set Union structure for maintaining connected components
struct DSU {
    vector<int> p, sz;
    DSU(int n) : p(n), sz(n,1) {
        iota(p.begin(), p.end(), 0);
    }
    int find(int x){
        return p[x] == x ? x : p[x] = find(p[x]); // path compression
    }
    bool unite(int a, int b){
        a = find(a);
        b = find(b);
        if(a == b) return false; // already connected
        if(sz[a] < sz[b]) swap(a,b); // union by size
        p[b] = a;
        sz[a] += sz[b];
        return true;
    }
};
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int T;
    cin >> T;
    while(T--){
        int N;
        cin >> N;
 
        const int MAXV = 200000;
        vector<vector<int>> pos(MAXV + 1); // pos[x] = list of chambers containing value x
 
        // Read chambers and store positions for each value
        for(int i = 0; i < N; i++){
            int k;
            cin >> k;
            while(k--){
                int x;
                cin >> x;
                pos[x].push_back(i);
            }
        }
 
        DSU dsu(N);
        long long ans = 0;
 
        vector<int> nodes;
        // Process all possible gcd values from largest to smallest
        for(int g = MAXV; g >= 1; g--){
            nodes.clear();
            // Gather all chambers containing multiples of g
            for(int m = g; m <= MAXV; m += g){
                for(int v : pos[m]){
                    nodes.push_back(v);
                }
            }
            if(nodes.empty()) continue;
 
            // Connect all gathered chambers with edges of weight g
            int root = nodes[0];
            for(int i = 1; i < (int)nodes.size(); i++){
                if(dsu.unite(root, nodes[i])){
                    ans += g; // add edge weight to total
                }
            }
        }
 
        cout << ans << "\n";
    }
 
    return 0;
}
 
~~~
</spoiler>

[Problem E : Mind Flayer's Hive Mind](https://codeforces.me/gym/663321/problem/E)
 
Author : [user:dheeraj.dontha,2026-02-01] , [user:zonedout,2026-02-01]

<spoiler summary="Hint 1">Since every node in the initial tree has a degree at most $$$k$$$, a node only becomes a Focus Point if its degree remains exactly $$$k$$$. To minimize the number of chambers destroyed, we need to find the largest possible connected subgraph (a tree) that contains exactly one node with degree $$$k$$$ and all other nodes with degree $$$ \lt  k$$$.</spoiler>


<spoiler summary="Hint 2">Define $$$a[u]$$$ as the maximum size of a "clean" subtree rooted at $$$u$$$ (where no node in that subtree has degree $$$k$$$). If the current node $$$u$$$ has degree $$$k$$$ within the subtree, you must prune the smallest child branch to reduce its degree to $$$k-1$$$ and keep the subtree "clean."</spoiler>


<spoiler summary="Hint 3">To satisfy the "exactly one Focus Point" rule, you can "restore" one pruned branch. If you restore the branch we pruned from node $$$i$$$, that branch size is $$$b[i]$$$. The total size becomes the "clean" tree size plus this restoration gain.</spoiler>

 

<spoiler summary="Solution">We want to find the largest possible connected network such that exactly one node has degree $$$k$$$ and all others have degree $$$ \lt  k$$$.
<b>Key Observation:</b> Because every node in the initial tree has $$$degree \le k$$$, we only need to worry about nodes having a degree of exactly $$$k$$$. To "fix" a node with degree $$$k$$$, we must remove at least one of its edges.
 
<b>Approach (Tree DP with Restoration):</b><ul><li><b>DP State $$$a[u]$$$:</b> The maximum number of nodes in a connected component rooted at $$$u$$$ such that $$$u$$$ and all its descendants have $$$degree  \lt  k$$$.</li><li><b>Pruning Logic:</b><ul><li>If $$$deg(u)  \lt  k$$$, $$$a[u] = 1 + \sum a[v]$$$.</li><li>If $$$deg(u) = k$$$, $$$a[u] = 1 + (\sum a[v]) - \min(a[v])$$$. We store the pruned value in $$$b[u] = \min(a[v])$$$.</li></ul></li><li><b>Focus Point Restoration:</b><ul><li>While traversing, we use add to track the best focus point found in subtrees below us where the connection to the parent is already broken.</li><li>We update ans = max(ans, current_total_clean_size + add) to handle focus points in isolated subtrees.</li><li>After the DFS, we check if node 1 or any other node $$$i$$$ can be the restored Focus Point using max(ans, a[1] + b[i]).</li></ul></li></ul>
 
<b>Correctness Proof:</b>The DP correctly calculates the maximum size of a "clean" tree. By returning the maximum of the internal subtree focus points (add) and the pruned branch size (mini), we ensure that we consider every possible node as a potential Focus Point exactly once while maintaining connectivity.
 
<b>Time Complexity:</b><ul><li>Tree Traversal: $$$O(N)$$$ because each node and edge is visited a constant number of times during the DFS.</li><li>Final Scan: $$$O(N)$$$ to iterate through the restoration array $$$b$$$.</li></ul><b>Overall:</b> $$$O(N)$$$ per test case.
 
<b>Space Complexity:</b> $$$O(N)$$$ to store the adjacency list and DP arrays $$$a$$$ and $$$b$$$.</spoiler>

 

<spoiler summary="Code">
~~~
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define vi vector<int>
#define graph vector<vector<int>>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// solve returns the best focus point bonus (restored branch) found in the subtree
int solve(int parent, int node, int& ans, graph& adj, vi& a, vi& b, int k) {
    if (adj[node].size() == 1 && parent != -1) {
        a[node] = 1;
        return 0;
    }
 
    int sum = 0;
    int mini = LLONG_MAX;
    int add = 0;
 
    for (auto child : adj[node]) {
        if (child != parent) {
            add = max(add, solve(node, child, ans, adj, a, b, k));
            sum += a[child];
            mini = min(mini, a[child]);
        }
    }
 
    if (adj[node].size() < k) {
        a[node] = sum + 1;
        return add;
    }
 
    // Node currently has degree k.
    // Calculate size if this node is chosen to be the Focus Point.
    int size_if_focus = sum + 1;
    ans = max(ans, size_if_focus + add);
 
    // To keep the subtree "clean" for the parent, we prune the smallest branch.
    a[node] = sum - mini + 1;
    b[node] = mini;
 
    // Return the best focus point candidate: either one from below or this node's pruned branch.
    return max(add, mini);
}
 
void solve_test_case() {
    int n, k;
    if (!(cin >> n >> k)) return;
    graph adj(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
 
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (adj[i].size() == k) count++;
    }
 
    // If only one or zero focus points exist, no chambers need to be destroyed.
    if (count <= 1) {
        cout << 0 << endl;
        return;
    }
 
    vi a(n + 1, 0), b(n + 1, 0);
    int ans = 0;
 
    // Start DFS from node 1.
    for (auto child : adj[1]) {
        solve(1, child, ans, adj, a, b, k);
    }
 
    int sum = 0;
    int mini = LLONG_MAX;
    for (auto child : adj[1]) {
        sum += a[child];
        mini = min(mini, a[child]);
    }
 
    a[1] = sum + 1;
    if (adj[1].size() == k) {
        a[1] -= mini;
        b[1] = mini;
    }
 
    ans = max(ans, a[1]);
 
    // Final check: what if node i is the restored Focus Point in node 1's component?
    for (int i = 1; i <= n; i++) {
        ans = max(ans, a[1] + b[i]);
    }
 
    cout << n - ans << endl;
}
 
int32_t main() {
    fastio;
    int t;
    cin >> t;
    while (t--) {
        solve_test_case();
    }
    return 0;
}
~~~
</spoiler>

[Problem F: The Hawkins Gate Alarm](https://codeforces.me/gym/663321/problem/F)
<br>
Author: [user:kanav67,2026-02-01]
 

<spoiler summary="Hint1">
Sort the manual activations array and iterate each manual activation in order computing automatic activations inbetween.
</spoiler>

 
 

<spoiler summary="Hint2">
Remember to use int64 datatype (long long) since $$$n*x$$$ can reach upto $$$10^{18}$$$.
</spoiler>

 
 

<spoiler summary="Hint3">
Keep track of the last end time of the alarm to avoid double-counting overlapping intervals.
</spoiler>

 
 

<spoiler summary="Hint4">
For automatic activations, note that after a trigger at time $$$t$$$, the next useful activation is at $$$time  \gt  t + k$$$. This allows you to skip multiple automatic activations at once.
</spoiler>

 

<spoiler summary="Solution"> 
Approach Overview
------------------
The key is to simulate the alarm efficiently without iterating over all automatic activations individually. First, sort all manual arrival times. Maintain `last` — the time until which the last alarm was active. For each manual arrival time, calculate how many automatic activations are already covered and whether a new interval needs to be added. Use the fact that automatic activations occur at regular intervals to batch-process multiple activations in constant time. Finally, handle any remaining automatic activations after the last manual arrival.
 
Detailed Solution
------------------
1) **Sorting and Initialization**
<br>
Sort the manual arrival times v to process events chronologically. Initialize two variables &mdash; `last` = 0 to track the end of the current active interval and `ans` = 0 to track the number of active intervals.
 
2) **Processing Each Manual Arrival**
<br>
For each arrival time `t`, call `update(t)` which:
 
- Compute the number of automatic activations **before the previous last** (`curr = last / x`) and **before or equal to current time t** (`next = t / x`).
- Determine how many automatic activations are not yet covered and would start a new interval.
- The `step = 1 + k/x` represents the minimum gap of automatic triggers required to start a new interval without overlap.
- Update `last` to the end time of the last activation and increment `ans` for each new interval.
- After this, if the current last does not cover `t`, manually trigger a new interval ending at `t + k` and increment `ans`.
 
3) **Final Automatic Activation**
<br>
After processing all manual arrivals, call `update(n*x)` to account for any remaining automatic activations up to time $$$n*x$$$.
 
Finally compute the total time. Since each interval contributes exactly k seconds, so the **total active time** is:
`ans * k`
 
**Complexity Analysis**
<br>
Sorting the manual arrivals: $$$O(m * log m)$$$
<br>
Processing manual and automatic events: $$$O(m)$$$
<br>
Overall: $$$O(m * log m)$$$
</spoiler>

 
 

<spoiler summary="Code">
~~~
#include <bits/stdc++.h> 
using namespace std;
 
#define ll long long
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)
 
//covers all automatic and a manual before (and equal to) time t
void update(ll t, ll x, ll k, ll &last, ll &ans){
    ll prev = last/x; //previous count of automatic triggers completed
    ll curr = t/x;//new count of automatic triggers completed
 
    ll cnt = 0;
 
    //covers all automatic before and equal to t
    if(curr-prev > 0){
        //minimum gap of automatic triggers required to start a new interval without overlap.
        ll step = 1 + (k/x);
 
        cnt += (curr-prev+step-1)/step;
 
        ll lastcomplete = curr - (curr-prev-1)%step;
        last = lastcomplete*x + k;
    }
 
    //if the last automatic does not cover the t then handle it separately
    if(last < t){
        last = t + k;
        cnt++;
    }
 
    ans += cnt;
}
 
int main() {
    fastio();
 
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,m,x,k;
        cin >> n >> x >> k >> m;
 
        vector<long long> v(m);
        for(auto &val: v) cin >> val;
 
        sort(v.begin(), v.end());
 
        ll last = 0, ans = 0;
 
        for(int i=0; i<m; i++){
            update(v[i], x, k, last, ans);
        }
 
        //handle remaining automatics
        update(n*x, x, k, last, ans);
 
        cout << (ans*k) << endl;
    }
    return 0;
}
~~~
</spoiler>

[Problem G : Running Up That Hill](https://codeforces.me/gym/663321/problem/G)  <br>
Author : [user:vishwas_16.0,2026-01-30]

<spoiler summary="Hint 1"> First solve the classic LeetCode **Cat and Mouse** problem (retrograde/BFS on game states): [Cat And Mouse](https://leetcode.com/problems/cat-and-mouse/).

</spoiler>

<spoiler summary="Hint 2"> 
Model each game state as a 4-tuple `(m_pos, v_pos, mask, turn) `

where: &mdash; `m_pos` = Max’s node, &mdash; `v_pos` = Vecna’s node (never 1), &mdash; `mask` = bitmask of rescued children (0..(1<<k)-1), &mdash; `turn` = 0 (Max to move) or 1 (Vecna to move).
</spoiler>


<spoiler summary="Solution"> 
This problem is solved exactly like the **Cat and Mouse** game using **retrograde BFS on game states**.

The only difference is that when Max visits a node containing a child, we update the mask.
Since k ≤ 5, the mask has at most 2^k ≤ 32 possibilities, which is small.

So we just multiply the original Cat & Mouse state space by 32 to track children — everything else stays the same.
**Time Complexity:** $$$ O(n * n * 2^k) $$$ With $$$( n \le 50 , k \le 5 )$$$, this is at most about **160k states**, each processed in constant/degree time.

**Space Complexity:** $ O(n * n * 2^k). for storing outcomes and degrees.
Both comfortably fit within limits.
</spoiler>

<spoiler summary="Code">

include

include

include

include

using namespace std;

const int MAXN = 51; const int MAXK = 32;

int n, m, k; vector adj[MAXN]; int child_node[MAXN]; // -1 if no child, else 0..k-1 int outcome[MAXN][MAXN][MAXK][2]; // 0: DRAW, 1: MAX, 2: VECNA int degree[MAXN][MAXN][MAXK][2];

struct State { int m_pos, v_pos, mask, turn; };

int main() { ios::sync_with_stdio(false); cin.tie(0);

if (!(cin >> n >> m)) return 0;
for (int i = 0; i < m; ++i) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
}

cin >> k;
for (int i = 1; i <= n; ++i) child_node[i] = -1;
for (int i = 1; i <= n; ++i) {
    int c; cin >> c;
    if (c != -1) child_node[i] = c;
}

queue<State> q;

// 1. Initialize Degrees and Win/Loss States
for (int mp = 1; mp <= n; ++mp) {
    for (int vp = 2; vp <= n; ++vp) { // Vecna never at 1
        for (int mask = 0; mask < (1 << k); ++mask) {
            // Max's Turn (0)
            degree[mp][vp][mask][0] = adj[mp].size();

            // Vecna's Turn (1)
            for (int next_v : adj[vp]) {
                if (next_v != 1) degree[mp][vp][mask][1]++;
            }

            // Terminal Condition: Vecna catches Max
            // This happens if Vecna moves to Max, or Max moves to Vecna.
            if (mp == vp) {
                if (!outcome[mp][vp][mask][0]) { outcome[mp][vp][mask][0] = 2; q.push({mp, vp, mask, 0}); }
                if (!outcome[mp][vp][mask][1]) { outcome[mp][vp][mask][1] = 2; q.push({mp, vp, mask, 1}); }
            }
            // Terminal Condition: Max reaches cave with all children
            else if (mp == 1 && mask == (1 << k) - 1) {
                if (!outcome[mp][vp][mask][0]) { outcome[mp][vp][mask][0] = 1; q.push({mp, vp, mask, 0}); }
                if (!outcome[mp][vp][mask][1]) { outcome[mp][vp][mask][1] = 1; q.push({mp, vp, mask, 1}); }
            }
        }
    }
}

// 2. Retrograde Propagation
while (!q.empty()) {
    State curr = q.front();
    q.pop();
    int res = outcome[curr.m_pos][curr.v_pos][curr.mask][curr.turn];

    if (curr.turn == 1) { // Current is Vecna, Predecessor was Max
        for (int prev_m : adj[curr.m_pos]) {
            // To reach 'curr.mask' at 'curr.m_pos', Max must have had 'prev_mask'
            // at 'prev_m'. 
            for (int prev_mask = 0; prev_mask < (1 << k); ++prev_mask) {
                int next_mask = prev_mask;
                if (child_node[curr.m_pos] != -1) next_mask |= (1 << child_node[curr.m_pos]);

                if (next_mask == curr.mask) {
                    if (outcome[prev_m][curr.v_pos][prev_mask][0]) continue;

                    if (res == 1) { // Max found a move to win
                        outcome[prev_m][curr.v_pos][prev_mask][0] = 1;
                        q.push({prev_m, curr.v_pos, prev_mask, 0});
                    } else if (--degree[prev_m][curr.v_pos][prev_mask][0] == 0) {
                        outcome[prev_m][curr.v_pos][prev_mask][0] = 2;
                        q.push({prev_m, curr.v_pos, prev_mask, 0});
                    }
                }
            }
        }
    } else { // Current is Max, Predecessor was Vecna
        for (int prev_v : adj[curr.v_pos]) {
            if (prev_v == 1) continue;
            if (outcome[curr.m_pos][prev_v][curr.mask][1]) continue;

            if (res == 2) { // Vecna found a move to win
                outcome[curr.m_pos][prev_v][curr.mask][1] = 2;
                q.push({curr.m_pos, prev_v, curr.mask, 1});
            } else if (--degree[curr.m_pos][prev_v][curr.mask][1] == 0) {
                outcome[curr.m_pos][prev_v][curr.mask][1] = 1;
                q.push({curr.m_pos, prev_v, curr.mask, 1});
            }
        }
    }
}

// 3. Result
int start_mask = 0;
if (child_node[2] != -1) start_mask |= (1 << child_node[2]);
cout << outcome[2][3][start_mask][0] << endl;

return 0;

} ~~~~~

see this remember this now i will give u problem names and code u need to make the editorial for them ok The contest Cc wing selection contest 2026

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en25 English vishwas_16.0 2026-08-12 17:02:36 0 (published)
en24 English vishwas_16.0 2026-08-12 17:02:13 2 Tiny change: ' \n</br>\n[Problem' -> ' \n</br>\n\n[Problem'
en23 English vishwas_16.0 2026-08-12 17:01:52 265 (saved to drafts)
en22 English vishwas_16.0 2026-08-12 16:57:20 0 Tiny change: 're given $a+b$ and $a\&b$ directly' -> 're given $$ a+b $$ and $$a\&b$$ directly' (published)
en21 English vishwas_16.0 2026-08-12 16:55:57 1655 Tiny change: 're given $a+b$ and $a\&b$ directly' -> 're given $$ a+b $$ and $$a\&b$$ directly'
en20 English vishwas_16.0 2026-08-12 16:54:45 46 Tiny change: 're given $a+b$ and $a\&b$ directly' -> 're given $$ a+b $$ and $$a\&b$$ directly'
en19 English vishwas_16.0 2026-08-12 16:53:57 6 Tiny change: 're given $a+b$ and $a\&b$ directly' -> 're given $$ a+b $$ and $$a\&b$$ directly'
en18 English vishwas_16.0 2026-08-12 16:52:37 4
en17 English vishwas_16.0 2026-08-12 13:26:34 1 Tiny change: '") and $a \& b$ (the ' -> '") and $a & b$ (the '
en16 English vishwas_16.0 2026-08-12 13:20:16 8 Tiny change: 'Editorial &mdash; CC Wing S' -> 'Editorial CC Wing S'
en15 English vishwas_16.0 2026-08-12 13:16:29 2 Tiny change: 'Editorial &mdash; CC Wing S' -> 'Editorial - CC Wing S'
en14 English vishwas_16.0 2026-08-12 13:15:55 3482
en13 English vishwas_16.0 2026-08-12 13:09:37 1172
en12 English vishwas_16.0 2026-08-12 13:08:37 5946
en11 English vishwas_16.0 2026-08-12 12:52:18 3499
en10 English vishwas_16.0 2026-08-12 12:48:20 7030
en9 English vishwas_16.0 2026-08-12 12:47:49 3433
en8 English vishwas_16.0 2026-08-12 12:47:10 4887
en7 English vishwas_16.0 2026-08-12 12:46:23 10400
en6 English vishwas_16.0 2026-08-12 12:41:59 0
en5 English vishwas_16.0 2026-08-12 12:41:59 0
en4 English vishwas_16.0 2026-08-12 12:41:59 16235
en3 English vishwas_16.0 2026-08-12 09:59:11 3020
en2 English vishwas_16.0 2026-08-12 09:54:52 6475
en1 English vishwas_16.0 2026-08-12 09:46:08 29176 Initial revision (saved to drafts)