Submission #1285228

#TimeUsernameProblemLanguageResultExecution timeMemory
1285228goulthenPermutation 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)
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>

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:31:29: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int')
   31 |             cur = max({sz,i});
      |                             ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/vector:62,
                 from permgame.h:1,
                 from permgame.cpp:1:
/usr/include/c++/13/bits/stl_pair.h:439:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) requires  _S_assignable<const _U1&, const _U2&>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  439 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:439:9: note:   template argument deduction/substitution failed:
permgame.cpp:31:29: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   31 |             cur = max({sz,i});
      |                             ^
/usr/include/c++/13/bits/stl_pair.h:451:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) requires  _S_assignable<_U1, _U2>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  451 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:451:9: note:   template argument deduction/substitution failed:
permgame.cpp:31:29: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   31 |             cur = max({sz,i});
      |                             ^
/usr/include/c++/13/bits/stl_pair.h:416:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_T1, _T2>&) requires  _S_assignable<const _T1&, const _T2&>() [with _T1 = int; _T2 = int]'
  416 |       operator=(const pair& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:416:29: note:   no known conversion for argument 1 from 'int' to 'const std::pair<int, int>&'
  416 |       operator=(const pair& __p)
      |                 ~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_pair.h:427:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_T1, _T2>&&) requires  _S_assignable<_T1, _T2>() [with _T1 = int; _T2 = int]'
  427 |       operator=(pair&& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:427:24: note:   no known conversion for argument 1 from 'int' to 'std::pair<int, int>&&'
  427 |       operator=(pair&& __p)
      |                 ~~~~~~~^~~