Submission #944665

# Submission time Handle Problem Language Result Execution time Memory
944665 2024-03-13T02:50:21 Z yhkhoo Chameleon's Love (JOI20_chameleon) C++17
Compilation error
0 ms 0 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

/* 
 * ladies and gentlemen
 * your attention please
 * the fire alarm has been activated in the building
 * we are investigating the situation
 * please remain calm and standby for further instruction
 * thank you
 * 
 * ladies and gentlemen
 * the emergency situation in the building is now under control
 * we regret any inconvenience caused
 * thank you
 */

void Solve(int N) {
    vector<int> l(N, -1), c(N, -1);
    vector<vector<int>> hm(2*N+1);
    for(int i=1; i<=2*N; i++){
        for(int j=1; j<=2*N; j++){
            if(j==i) continue;
            vector<int> s1 = {i, j};
            if(Query(s1) == 1){
                hm[i].push_back(j);
            }
        }
    }
    set<int> ad;
	vector<vector<int>> cringe(2*N+1);
    for(int i=1; i<=2*N; i++){
        if(hm[i].size() == 0) continue;
        if(hm[i].size() == 1){
			if(ad.count(i) || ad.count(hm[i].front)) continue;
            Answer(i, hm[i].front());
            hm[hm[i].front()].clear();
            ad.insert(i);
            ad.insert(hm[i].front())
        }
        else{
            for(int j=0; j<hm[i].size(); j++){
                vector<int> s2;
                for(int k=0; k<hm[i].size(); k++){
					if(k==j) continue;
					s2.push_back(hm[i][k]);
				}
				s2.push_back(i);
				if(Query(s2) == 1){
					cringe[hm[i][j]].push_back(i);
					cringe[i].push_back(hm[i][j]);
				}
			}
		}
	}
	for(int i=1; i<=2*N; i++){
		if(hm[i].size() == 3){
			for(int j=0; j<3; j++){
				if(!count(cringe[i].begin(), cringe[i].end(), hm[i][j])){
					if(ad.count(i) || ad.count(hm[i][j])) continue;
					Answer(i, hm[i][j]);
					ad.insert(i);
					ad.insert(hm[i][j]);
					// hm[hm[i][j]].clear();
				}
			}
		}
	}
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:36:42: error: no matching function for call to 'std::set<int>::count(<unresolved overloaded function type>)'
   36 |    if(ad.count(i) || ad.count(hm[i].front)) continue;
      |                                          ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from chameleon.cpp:2:
/usr/include/c++/10/bits/stl_set.h:748:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = int]'
  748 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:748:29: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const key_type&' {aka 'const int&'}
  748 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:754:2: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  754 |  count(const _Kt& __x) const
      |  ^~~~~
/usr/include/c++/10/bits/stl_set.h:754:2: note:   template argument deduction/substitution failed:
chameleon.cpp:36:42: note:   couldn't deduce template parameter '_Kt'
   36 |    if(ad.count(i) || ad.count(hm[i].front)) continue;
      |                                          ^
chameleon.cpp:40:37: error: expected ';' before '}' token
   40 |             ad.insert(hm[i].front())
      |                                     ^
      |                                     ;
   41 |         }
      |         ~                            
chameleon.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             for(int j=0; j<hm[i].size(); j++){
      |                          ~^~~~~~~~~~~~~
chameleon.cpp:45:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |                 for(int k=0; k<hm[i].size(); k++){
      |                              ~^~~~~~~~~~~~~