Submission #1295101

#TimeUsernameProblemLanguageResultExecution timeMemory
1295101glupanThe Collection Game (BOI21_swaps)C++20
Compilation error
0 ms0 KiB
// // --- Sample implementation for the task swaps --- // // To compile this program with the sample grader, place: // swaps.h swaps_sample.cpp sample_grader.cpp // in a single folder and run: // g++ swaps_sample.cpp sample_grader.cpp // in this folder. // #include "swaps.h" #include <bits/stdc++.h> using namespace std; void solve(int N, int V) { map<int,int>m; 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); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:31:32: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   31 |                 m[vec[i].first][vec[i].second] = res[i];
      |                                ^
swaps.cpp:41:24: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   41 |                 if(m[i][j]) cnt++;
      |                        ^
swaps.cpp:43:25: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   43 |                 if(!m[j][i]) cnt++;
      |                         ^