QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244316#7687. Randias Permutation Taskucup-team2432#Compile Error//C++201.8kb2023-11-08 23:08:412023-11-08 23:08:41

Judging History

你现在查看的是最新测评结果

  • [2023-11-08 23:08:41]
  • 评测
  • [2023-11-08 23:08:41]
  • 提交

answer

#include<bits/stdc++.h>

using LL = long long;
const LL inf = 1e9;
const LL P[2] = {1000000007,1000000009};
const LL K = 7653524;

std::array<LL,2> hash(const std::vector<LL> &vec) {
	std::array<LL,2> res = {0,0},unit = {1,1};
	int n = vec.size() - 1;
	for (int i = n-1; i >= 0; --i) {
		for (int j = 0; j < 2; ++j) {
			res[j] = (res[j] + unit[j] * vec[i]) % P[j];
			unit[j] = unit[j] * K % P[j];
		}
	}
	return res;
}

void solve() {

	std::mt19937 rnd(std::random_device{}());

	int n,m;std::cin >> n >> m;
	std::vector pmt(m,std::vector<LL>(n+1));
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < n; ++j) {
			std::cin >> pmt[i][j];
		}
	}
	std::shuffle(pmt.begin(),pmt.end(),rnd);
	std::map<std::array<LL,2>,int> mp;
	std::priority_queue<std::pair<int,std::vector<LL>>,std::vector<std::pair<int,std::vector<LL>>>,std::greater<>> q;
	for (int i = 0; i < m; ++i) {
		pmt[i][n] = i;
		q.emplace(i+1,pmt[i]);
	}
	LL ans = 0;
	while (!q.empty()) {
		auto [point,vec] = q.top();q.pop();
		auto hsh = hash(vec);
		if (!mp.count(hsh)) {
			mp[hsh] = vec.back();
			ans ++;
		} else {
			if (mp[hsh]+10 < vec.back()) {
				continue;
			}
		}
		if (point == m) continue;
		q.emplace(point+1,vec);
		std::vector<int> now(n);
		for (int i = 0; i < n; ++i) {
			now[i] = vec[pmt[point][i] - 1];
		}
		now[n] = point;
		q.emplace(point+1,now);
	}
	std::cout << ans % P[0];
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

//    clock_t st = clock();
//    std::cout << std::fixed << std::setprecision(12);

//    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);

	int T = 1;
//	std::cin >> T;
	while (T --) {
		solve();
	}

//    std::cout << (double)(clock()-st)/CLOCKS_PER_SEC;

	return 0;
}

詳細信息

In file included from /usr/include/c++/11/ext/alloc_traits.h:34,
                 from /usr/include/c++/11/bits/basic_string.h:40,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/alloc_traits.h: In instantiation of ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, std::vector<long long int> >; _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::pair<int, std::vector<long long int> > >]’:
/usr/include/c++/11/bits/vector.tcc:115:30:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; _Alloc = std::allocator<std::pair<int, std::vector<long long int> > >; std::vector<_Tp, _Alloc>::reference = std::pair<int, std::vector<long long int> >&]’
/usr/include/c++/11/bits/stl_queue.h:658:18:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; _Sequence = std::vector<std::pair<int, std::vector<long long int> > >; _Compare = std::greater<void>]’
answer.code:57:12:   required from here
/usr/include/c++/11/bits/alloc_traits.h:518:28: error: no matching function for call to ‘construct_at(std::pair<int, std::vector<long long int> >*&, int, std::vector<int>&)’
  518 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_iterator.h:85,
                 from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_construct.h:94:5: note: candidate: ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)’
   94 |     construct_at(_Tp* __location, _Args&&... __args)
      |     ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_construct.h:94:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/stl_construct.h: In substitution of ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = std::pair<int, std::vector<long long int> >; _Args = {int, std::vector<int, std::allocator<int> >&}]’:
/usr/include/c++/11/bits/alloc_traits.h:518:21:   required from ‘static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, std::vector<long long int> >; _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::pair<int, std::vector<long long int> > >]’
/usr/include/c++/11/bits/vector.tcc:115:30:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; _Alloc = std::allocator<std::pair<int, std::vector<long long int> > >; std::vector<_Tp, _Alloc>::reference = std::pair<int, std::vector<long long int> >&]’
/usr/include/c++/11/bits/stl_queue.h:658:18:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int, std::vector<int, std::allocator<int> >&}; _Tp = std::pair<int, std::vector<long long int> >; _Sequence = std::vector<std::pair<int, std::vector<long long int> > >; _Compare = std::greater<void>]’
answer.code:57:12:   required from here
/usr/include/c++/11/bits/stl_construct.h:96:17: error: no matching function for call to ‘std::pair<int, std::vector<long long int> >::pair(int, std::vector<int>&)’
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...