Submission #1295096

#TimeUsernameProblemLanguageResultExecution timeMemory
1295096glupanThe Collection Game (BOI21_swaps)C++20
Compilation error
0 ms0 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

map<int,int>m;

int main()
{
    int N=5;
    for(int i=1; i<=N-1; i++) {
        for(int TMP=0; TMP<=1; TMP++) {
            int visited[N+1];
            vector<pair<int,int>>vec;
            memset(visited,0,sizeof visited);
            for(int j=1+TMP*i; j<=N-i; j++) {
                if(visited[j] or visited[j+i]) continue;
                schedule(j, j+i);
                vec.push_back({j,j+i});
                visited[j] = 1;
                visited[j+i] = 1;
            }
            vector<int> res = visit();
            for(int i=0; i<vec.size(); i++) {
                m[vec[i].first][vec[i].second] = res[i];
            }
        }
    }
    int ans[N];
    for(int i=1; i<=N; i++) {
        int cnt=0;
        for(int j=1; j<=N; j++) {
            if(i==j) continue;
            if(i < j) {
                if(m[i][j]) cnt++;
            } else {
                if(!m[j][i]) cnt++; 
            }
        }
        ans[N-1-cnt] = i;
    }
    vector<int>Ans;
    for(int i=0; i<N; i++) Ans.push_back(ans[i]);
    answer(Ans);
    
    return 0;
}

Compilation message (stderr)

swaps.cpp: In function 'int main()':
swaps.cpp:25:17: error: 'schedule' was not declared in this scope
   25 |                 schedule(j, j+i);
      |                 ^~~~~~~~
swaps.cpp:30:36: error: no matching function for call to 'visit()'
   30 |             vector<int> res = visit();
      |                               ~~~~~^~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:80,
                 from swaps.cpp:9:
/usr/include/c++/13/variant:1851:5: note: candidate: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1851 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1851:5: note:   template argument deduction/substitution failed:
swaps.cpp:30:36: note:   candidate expects at least 1 argument, 0 provided
   30 |             vector<int> res = visit();
      |                               ~~~~~^~
/usr/include/c++/13/variant:1891:5: note: candidate: 'template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)'
 1891 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1891:5: note:   template argument deduction/substitution failed:
swaps.cpp:30:36: note:   candidate expects at least 1 argument, 0 provided
   30 |             vector<int> res = visit();
      |                               ~~~~~^~
swaps.cpp:32:32: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   32 |                 m[vec[i].first][vec[i].second] = res[i];
      |                                ^
swaps.cpp:42:24: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   42 |                 if(m[i][j]) cnt++;
      |                        ^
swaps.cpp:44:25: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   44 |                 if(!m[j][i]) cnt++;
      |                         ^
swaps.cpp:51:5: error: 'answer' was not declared in this scope
   51 |     answer(Ans);
      |     ^~~~~~