Submission #1291511

#TimeUsernameProblemLanguageResultExecution timeMemory
1291511LolkasMeepPermutation Game (APIO25_permgame)C++20
24 / 100
1 ms348 KiB
#include "permgame.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int Alice(int m, int e, vector<int> u, vector<int> v, int n, vector<int> p) {
    // cout << "hi\n";
    while(true){
        bool foundCycle = false;
        vector<bool> found(n, false);
        for(int i = 0; i < n && !foundCycle; i++){
            // cout << "checking: " << i << '\n';
            if(found[i]) continue;
            found[i] = true;
            if(i == p[i]) continue;

            vector<int> cycle;
            cycle.push_back(i);
            
            int index = i;
            while(p[index] != i){
                index = p[index];
                cycle.push_back(index);
                found[index] = true;
            }

            // cout << "found cycle: ";
            // for(const auto &x : cycle) cout << x << ", ";
            // cout << '\n';

            if(cycle.size() % 2 == 0) continue;
            foundCycle = true;

            assert(cycle.size() >= 3);

            vector<int> t = {cycle[0], cycle[1], cycle[2]};
            int j = Bob(t);
            swap(p[t[u[j]]], p[t[v[j]]]);
        }

        if(!foundCycle) break;
    }

    int score = 0;
    for(int i = 0; i < n; i++){
        if(i == p[i]) score++;
    }

    return score;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...