제출 #1207824

#제출 시각아이디문제언어결과실행 시간메모리
1207824quickslothPermutation Game (APIO25_permgame)C++20
12 / 100
1 ms328 KiB
#include <vector>
using namespace std;
template<class C> using vc=vector<C>;
#define For(i,a,b) for(int i=(a);i<(b);i++)
const int mx=400;

int Bob(vc<int> t);

int Alice(int m, int e, vc<int> u, vc<int> v, int n, vc<int> p) {
    /*
    graph with m vertices e edges
    max fixed points in permutation of size n>=m
    3n steps: pick m indices, bob swaps a pair corresponding to an edge
    if some edge is not i-a[i] in any direction, cannot gain fixed points
    */
    if(m==2) {
        // n-1 swaps
        For(i,0,n) if(p[i]!=i)
            For(j,i+1,n) if(p[j]==i) p[j]=p[i], p[i]=i, Bob({i,j});
        return n;
    }
    else if(e>m) {
        // too many edges
        int ans=0;
        For(i,0,n) if(p[i]==i) ans++;
        return ans;
    }
    else if(e<m) {
        // not path: deg 3
        // path: ?
        ;
    }
    else if(m==3&&e==3) {
        /*
        C_3: answer = no. odd cycles
        proof: if pick two from different cycles, join
        else if all in even cycle, swap a pair with an even gap
        construction: shrink cycles
        */
        int ans=0;
        bool vis[mx]={};
        For(i,0,n) if(!vis[i]) {
            vc<int> v={i};
            while(p[v.back()]!=i) v.push_back(p[v.back()]);
            for(int t:v) vis[t]=1;
            if(v.size()&1) {
                ans++;
                // operate on last 3
                int res=Bob({v[v.size()-3],v[v.size()-2],v[v.size()-1]});
                int x=u[res], y=v[res];
                if(x==1||y==1) break; // got fixed point
                v.pop_back(), v.pop_back();
            }
        }
        return ans;
    }
    else {
        /*
        not cycle: deg 3
        cycle: ?
        */
    }
    throw(0);
}
#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...