Submission #684385

#TimeUsernameProblemLanguageResultExecution timeMemory
684385doniKutije (COCI21_kutije)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second ll parent[1001]; ll rank[1001]; ll z=0; void make_set(ll v) { parent[v] = v; rank[v] = z; } ll find_set(ll v) { if (v == parent[v]) return v; return parent[v] = find_set (parent[v]); } void union_sets(ll a, ll b) { a = find_set (a); b = find_set (b); if (a != b) { if (rank[a] < rank[b]) swap (a, b); parent[b] = a; if (rank[a] == rank[b]) ++rank[a]; } } void bf(){ ll n,a,b,m,q; cin>>n>>m>>q; for(ll i=1;i<=n;i++){ make_set(i); } for(ll mm=0;mm<m;mm++){ for(ll i=0;i<n;i++){ cin>>a; union_sets(a,i+1); } } for(ll i=0;i<q;i++){ cin>>a>>b; if(find_set(a)==find_set(b)){ cout<<"DA"<<endl; } else{ cout<<"NE\n"; } } } /* */ int main(){ // ll t;cin>>t;while(t--) bf(); }

Compilation message (stderr)

Main.cpp: In function 'void make_set(long long int)':
Main.cpp:13:2: error: reference to 'rank' is ambiguous
   13 |  rank[v] = z;
      |  ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~
Main.cpp: In function 'void union_sets(long long int, long long int)':
Main.cpp:26:7: error: reference to 'rank' is ambiguous
   26 |   if (rank[a] < rank[b])
      |       ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~
Main.cpp:26:17: error: reference to 'rank' is ambiguous
   26 |   if (rank[a] < rank[b])
      |                 ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~
Main.cpp:29:7: error: reference to 'rank' is ambiguous
   29 |   if (rank[a] == rank[b])
      |       ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~
Main.cpp:29:18: error: reference to 'rank' is ambiguous
   29 |   if (rank[a] == rank[b])
      |                  ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~
Main.cpp:30:6: error: reference to 'rank' is ambiguous
   30 |    ++rank[a];
      |      ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 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 Main.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
Main.cpp:8:4: note:                 'long long int rank [1001]'
    8 | ll rank[1001];
      |    ^~~~