답안 #807423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807423 2023-08-04T17:10:47 Z farhan132 Monster Game (JOI21_monster) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#include "monster.h"

using namespace std;

typedef int ll;

#define pb push_back
#define mem(a , b) memset(a, b ,sizeof(a))

const ll N = 1005;
ll dp[N][N];
ll cnt[N];

bool comp(ll a, ll b){
	if(cnt[a] != cnt[b]) return cnt[a] < cnt[b];
	if(dp[a][b] == a) return 1;
	return 0;
}

vector < ll > make_brute(vector < ll > p){
   ll n = p.size();
   for(ll i = 0; i < n; i++) cnt[p[i]] = 0;
   for(ll i = 0; i < n; i++){
   	for(ll j = 0; j < i; j++){
   	  bool ch = Query(p[i] , p[j]);
   	  if(ch) dp[p[i]][p[j]] = dp[p[j]][p[i]] = p[i] , cnt[p[i]]++;
   	  else  dp[p[i]][p[j]] = dp[p[j]][p[i]] = p[j] , cnt[p[j]]++;
   	}
   }

   sort(p.begin() , p.end() , comp);
   return p;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type, less <ll>, rb_tree_tag , tree_order_statistics_node_update >


std::vector<int> Solve(int n) {
  
  mem(dp, 0); 
  mem(cnt, 0);
  vector < ll > ans(n , 0);
  vector < ll > p;
  
  p = merge(0 , n-1);
  vector < ll > tp = p;
  vector < ll > t(n , 0);
  for(ll i = 0; i < p.size() - 1; i++){
  	t[i] = Query(p[i] , p[i + 1]);
  	if(i%2 == 0){
  		if(!t[i]) swap(tp[i] , tp[i + 1]);
  	}
  	cout << t[i] << ' ';
  }
  cout << '\n';
  for(auto u : p) cout << u << ' ';
  	cout << '\n';
  for(ll i = 0; i < p.size()-1; i++){
  	if(!t[i]){
  		bool ok = 0;
  		if(i != 0) ok = t[i - 1];
  		if(!t[i + 1] && !ok) swap(p[i] , p[i + 1]);
  	}
  }
  for(auto u : tp) cout << u << ' ';
  	cout << '\n';
  //p = tp;

  for(ll i = 0; i < n; i++) ans[p[i]] = i;



  return ans;
}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:53:20: error: no matching function for call to 'merge(int, int)'
   53 |   p = merge(0 , n-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from monster.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4944:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter)'
 4944 |     merge(_InputIterator1 __first1, _InputIterator1 __last1,
      |     ^~~~~
/usr/include/c++/10/bits/stl_algo.h:4944:5: note:   template argument deduction/substitution failed:
monster.cpp:53:20: note:   candidate expects 5 arguments, 2 provided
   53 |   p = merge(0 , n-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from monster.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4995:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter, class _Compare> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare)'
 4995 |     merge(_InputIterator1 __first1, _InputIterator1 __last1,
      |     ^~~~~
/usr/include/c++/10/bits/stl_algo.h:4995:5: note:   template argument deduction/substitution failed:
monster.cpp:53:20: note:   candidate expects 6 arguments, 2 provided
   53 |   p = merge(0 , n-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from monster.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:412:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator, _Compare)'
  412 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
      | ^~~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:412:1: note:   template argument deduction/substitution failed:
monster.cpp:53:20: note:   candidate expects 7 arguments, 2 provided
   53 |   p = merge(0 , n-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from monster.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:417:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator)'
  417 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
      | ^~~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:417:1: note:   template argument deduction/substitution failed:
monster.cpp:53:20: note:   candidate expects 6 arguments, 2 provided
   53 |   p = merge(0 , n-1);
      |                    ^
monster.cpp:56:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for(ll i = 0; i < p.size() - 1; i++){
      |                 ~~^~~~~~~~~~~~~~
monster.cpp:66:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(ll i = 0; i < p.size()-1; i++){
      |                 ~~^~~~~~~~~~~~