Submission #1285225

#TimeUsernameProblemLanguageResultExecution timeMemory
1285225goulthenPermutation Game (APIO25_permgame)C++20
Compilation error
0 ms0 KiB
#include "permgame.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i = a; i <= b; ++i)

int Alice(int m, int e, std::vector<int> u, std::vector<int> v, int n, std::vector<int> p) {
    int cnt = 0;
    rep(i,0,n-1) if (p[i]==i) cnt++;
    vector<int> deg(m);
    rep(i,0,e-1) deg[u[i]]++, deg[v[i]]++;

    rep(i,0,m-1) if(deg[i] > 2) return cnt;

    while(1){
        pii cur = {-1,-1};
        vector<bool> mk(n+1,0);

        rep(i,0,n-1) {
            if(mk[i]) continue;
            mk[i] = 1;
            int st = p[i],sz = 1;
            while (!mk[st]){
                sz++;
                st = p[st];
            }
            cur = max({sz,i});
        }
        if(cur.fi < m) break;
        cnt++;

        vector<int> t;
        t.pb(cur.se);
        rep(i,1,m-1) {
            t.pb(p[t.back()]);
        }
        int j = Bob(t);
        swap(p[t[u[j]]], p[t[v[j]]]);
    }

    return cnt;

}

Compilation message (stderr)

permgame.cpp: In function 'int Alice(int, int, std::vector<int>, std::vector<int>, int, std::vector<int>)':
permgame.cpp:16:9: error: 'pii' was not declared in this scope
   16 |         pii cur = {-1,-1};
      |         ^~~
permgame.cpp:27:13: error: 'cur' was not declared in this scope
   27 |             cur = max({sz,i});
      |             ^~~
permgame.cpp:29:12: error: 'cur' was not declared in this scope
   29 |         if(cur.fi < m) break;
      |            ^~~
permgame.cpp:33:11: error: 'class std::vector<int>' has no member named 'pb'
   33 |         t.pb(cur.se);
      |           ^~
permgame.cpp:33:14: error: 'cur' was not declared in this scope
   33 |         t.pb(cur.se);
      |              ^~~
permgame.cpp:35:15: error: 'class std::vector<int>' has no member named 'pb'
   35 |             t.pb(p[t.back()]);
      |               ^~