Submission #1274984

#TimeUsernameProblemLanguageResultExecution timeMemory
1274984muhammad-ahmadIsland Hopping (JOI24_island)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "island.h" using namespace std; void solve(int n, int l) { map<int, map<int, bool>> P; map<pair<int, int>, int> C; for (int i = 1; i <= n; i++){ int f = query(i, 1), ex = query(i, 2); if (!C[{f, i}]){ C[{f, i}] = 1; C[{i, f}] = 1; answer(i, f); } if (!C[f, ex] && !C[i, ex]){ P[f][ex] = 1; P[i][ex] = 1; } } for (int i = 1; i <= n; i++){ for (auto [j, c] : P[i]){ if (!C[{i, j}] && P[j][i]){ answer(i, j); C[{i, j}] = 1; C[{j, i}] = 1; } } } }

Compilation message (stderr)

island.cpp: In function 'void solve(int, int)':
island.cpp:16:25: warning: top-level comma expression in array subscript is deprecated [-Wcomma-subscript]
   16 |                 if (!C[f, ex] && !C[i, ex]){
      |                         ^
island.cpp:16:23: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   16 |                 if (!C[f, ex] && !C[i, ex]){
      |                       ^
In file included from /usr/include/c++/13/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from island.cpp:1:
/usr/include/c++/13/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
island.cpp:16:38: warning: top-level comma expression in array subscript is deprecated [-Wcomma-subscript]
   16 |                 if (!C[f, ex] && !C[i, ex]){
      |                                      ^
island.cpp:16:36: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   16 |                 if (!C[f, ex] && !C[i, ex]){
      |                                    ^
/usr/include/c++/13/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~