Submission #1092053

#TimeUsernameProblemLanguageResultExecution timeMemory
1092053codexistentGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> int v, p[1005]; set<pair<int, int>> adj[1005]; set<pair<int, int>> edge[1005][1005]; int find(int x){ return (p[x] == x) ? x : (p[x] = find(p[x])); } void onion(int a, int b){ a = find(a), b = find(b); if(a == b) return; if(adj[a].size() < adj[b].size()) swap(a, b); for(auto i : adj[b]){ adj[a].insert(i); int x = find(i.first), y = find(i.second); if(x == b) swap(a, b); edge[min(a, y)][max(a, y)].insert(i); edge[min(b, y)][max(b, y)].erase(i); } adj[b].clear(i); p[a] = p[b] = a; } void initialize(int n) { v = n; FOR(i, 0, n - 1) p[i] = i; FOR(i, 0, n - 1){ FOR(j, i + 1, n - 1){ adj[i].insert(make_pair(i, j)); adj[j].insert(make_pair(i, j)); edge[i][j].insert(make_pair(i, j)); } } } int hasEdge(int u, int v) { pair<int, int> e = make_pair(min(u, v), max(u, v)); u = find(u), v = find(v); if(u == v) return 1; adj[u].erase(e); adj[v].erase(e); edge[min(u, v)][max(u, v)].erase(e); if(edge[min(u, v)][max(u, v)].size() == 0){ onion(u, v); return 1; } return 0; }

Compilation message (stderr)

game.cpp:5:1: error: 'set' does not name a type; did you mean 'setns'?
    5 | set<pair<int, int>> adj[1005];
      | ^~~
      | setns
game.cpp:6:1: error: 'set' does not name a type; did you mean 'setns'?
    6 | set<pair<int, int>> edge[1005][1005];
      | ^~~
      | setns
game.cpp: In function 'void onion(int, int)':
game.cpp:16:8: error: 'adj' was not declared in this scope
   16 |     if(adj[a].size() < adj[b].size()) swap(a, b);
      |        ^~~
game.cpp:16:39: error: 'swap' was not declared in this scope
   16 |     if(adj[a].size() < adj[b].size()) swap(a, b);
      |                                       ^~~~
game.cpp:16:39: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from game.cpp:2:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
game.cpp:18:18: error: 'adj' was not declared in this scope
   18 |     for(auto i : adj[b]){
      |                  ^~~
game.cpp:21:20: error: 'swap' was not declared in this scope
   21 |         if(x == b) swap(a, b);
      |                    ^~~~
game.cpp:21:20: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from game.cpp:2:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
game.cpp:23:9: error: 'edge' was not declared in this scope
   23 |         edge[min(a, y)][max(a, y)].insert(i);
      |         ^~~~
game.cpp:23:21: error: 'y' was not declared in this scope
   23 |         edge[min(a, y)][max(a, y)].insert(i);
      |                     ^
game.cpp:23:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |         edge[min(a, y)][max(a, y)].insert(i);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
game.cpp:23:25: error: 'max' was not declared in this scope; did you mean 'std::max'?
   23 |         edge[min(a, y)][max(a, y)].insert(i);
      |                         ^~~
      |                         std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
game.cpp:26:5: error: 'adj' was not declared in this scope
   26 |     adj[b].clear(i);
      |     ^~~
game.cpp:26:18: error: 'i' was not declared in this scope
   26 |     adj[b].clear(i);
      |                  ^
game.cpp: In function 'void initialize(int)':
game.cpp:33:9: error: 'i' was not declared in this scope
   33 |     FOR(i, 0, n - 1) p[i] = i;
      |         ^
game.cpp:33:5: error: 'FOR' was not declared in this scope
   33 |     FOR(i, 0, n - 1) p[i] = i;
      |     ^~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:45:5: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   45 |     pair<int, int> e = make_pair(min(u, v), max(u, v));
      |     ^~~~
      |     std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
game.cpp:45:10: error: expected primary-expression before 'int'
   45 |     pair<int, int> e = make_pair(min(u, v), max(u, v));
      |          ^~~
game.cpp:50:5: error: 'adj' was not declared in this scope
   50 |     adj[u].erase(e);
      |     ^~~
game.cpp:50:18: error: 'e' was not declared in this scope
   50 |     adj[u].erase(e);
      |                  ^
game.cpp:52:5: error: 'edge' was not declared in this scope
   52 |     edge[min(u, v)][max(u, v)].erase(e);
      |     ^~~~
game.cpp:52:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   52 |     edge[min(u, v)][max(u, v)].erase(e);
      |          ^~~
      |          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
game.cpp:52:21: error: 'max' was not declared in this scope; did you mean 'std::max'?
   52 |     edge[min(u, v)][max(u, v)].erase(e);
      |                     ^~~
      |                     std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~