QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673495#9225. Fibonacci Fusionucup-team191#Compile Error//C++171.6kb2024-10-24 22:59:542024-10-24 22:59:54

Judging History

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

  • [2024-10-24 22:59:54]
  • 评测
  • [2024-10-24 22:59:54]
  • 提交

answer

#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define PB push_back

using namespace std;

const int N = 1e7 + 500;

int MOD[3] = {(int)1e9 + 7, (int)1e9 + 9, 998244353};

int F[3][N];

void precompute() {
	for(int j = 0;j < 3;j++) {
		F[j][0] = 0;
		F[j][1] = 1;
		for(int i = 2;i < N;i++) {
			F[j][i] = F[j][i - 1] + F[j][i - 2];
			if(F[j][i] >= MOD[j]) F[j][i] -= MOD[j];
		}
	}
}

int n;

bool cmp(const string &A, const string &B) {
	if(A.size() != B.size()) return A.size() < B.size();
	return A < B;
}

int ja[3];

void calc(const string &s) {
	ja[0] = 0, ja[1] = 0, ja[2] = 0;
	for(const char &c : s) {
		for(int j = 0;j < 3;j++) {
			ja[j] = (10LL * ja[j] + (c - '0')) % MOD[j];
		}
	}
}

map < array<int, 3>, int > cnt; 



inline int sub(int A, int B, int j) {
	if(A - B >= 0) return A - B;
	return A - B + MOD[j];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	precompute();
	cin >> n;
	vector < string > svi;
	for(int i = 0;i < n;i++) {
		string s; cin >> s;
		svi.PB(s);
	}
	sort(svi.begin(), svi.end(), cmp);
	long long ans = 0;
	for(const string &s : svi) {
		calc(s);
		long double dulj = (long double)s.size();
		dulj *= 4.78518086;
		int lo = max(0, (int)(dulj - 5));
		int hi = (int)(dulj + 6);
		array<int,3> tmp;
		for(int j = lo;j <= hi;j++) {
			tmp[0] = sub(F[0][j], ja[0], 0);
			tmp[1] = sub(F[1][j], ja[1], 1);
			tmp[2] = sub(F[2][j], ja[2], 2);
			ans += cnt[tmp];
		}
		tmp[0] = ja[0];
		tmp[1] = ja[1];
		tmp[2] = ja[2];
		cnt[tmp]++;
	}
	cout << ans << endl;
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:73:30: error: aggregate ‘std::array<int, 3> tmp’ has incomplete type and cannot be defined
   73 |                 array<int,3> tmp;
      |                              ^~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/string:51,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_pair.h: In instantiation of ‘struct std::pair<const std::array<int, 3>, int>’:
/usr/include/c++/13/ext/aligned_buffer.h:56:65:   required from ‘struct __gnu_cxx::__aligned_membuf<std::pair<const std::array<int, 3>, int> >’
/usr/include/c++/13/bits/stl_tree.h:231:41:   required from ‘struct std::_Rb_tree_node<std::pair<const std::array<int, 3>, int> >’
/usr/include/c++/13/bits/stl_tree.h:1936:21:   required from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_erase(_Link_type) [with _Key = std::array<int, 3>; _Val = std::pair<const std::array<int, 3>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::array<int, 3>, int> >; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; _Link_type = std::_Rb_tree_node<std::pair<const std::array<int, 3>, int> >*]’
/usr/include/c++/13/bits/stl_tree.h:986:9:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::~_Rb_tree() [with _Key = std::array<int, 3>; _Val = std::pair<const std::array<int, 3>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::array<int, 3>, int> >; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >]’
/usr/include/c++/13/bits/stl_map.h:197:7:   required from here
/usr/include/c++/13/bits/stl_pair.h:193:11: error: ‘std::pair<_T1, _T2>::first’ has incomplete type
  193 |       _T1 first;                 ///< The first member
      |           ^~~~~
In file included from /usr/include/c++/13/bits/memory_resource.h:47,
                 from /usr/include/c++/13/string:58:
/usr/include/c++/13/tuple:2005:45: note: declaration of ‘struct std::array<int, 3>’
 2005 |   template<typename _Tp, size_t _Nm> struct array;
      |                                             ^~~~~
In file included from /usr/include/c++/13/bits/char_traits.h:50,
                 from /usr/include/c++/13/string:42:
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::is_copy_assignable<const std::array<int, 3> >’:
/usr/include/c++/13/type_traits:161:35:   required by substitution of ‘template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, true>, typename std::enable_if<(bool)(_Bn::value), void>::type ...> std::__detail::__and_fn(int) [with _Bn = {std::is_copy_assignable<const std::array<int, 3> >, std::is_copy_assignable<int>}]’
/usr/include/c++/13/type_traits:177:42:   required from ‘struct std::__and_<std::is_copy_assignable<const std::array<int, 3> >, std::is_copy_assignable<int> >’
/usr/include/c++/13/bits/stl_pair.h:727:7:   required from ‘struct std::pair<const std::array<int, 3>, int>’
/usr/include/c++/13/ext/aligned_buffer.h:56:65:   required from ‘struct __gnu_cxx::__aligned_membuf<std::pair<const std::array<int, 3>, int> >’
/usr/include/c++/13/bits/stl_tree.h:231:41:   required from ‘struct std::_Rb_tree_node<std::pair<const std::array<int, 3>, int> >’
/usr/include/c++/13/bits/stl_tree.h:1936:21:   required from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_erase(_Link_type) [with _Key = std::array<int, 3>; _Val = std::pair<const std::array<int, 3>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::array<int, 3>, int> >; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; _Link_type = std::_Rb_tree_node<std::pair<const std::array<int, 3>, int> >*]’
/usr/include/c++/13/bits/stl_tree.h:986:9:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::~_Rb_tree() [with _Key = std::array<int, 3>; _Val = std::pair<const std::array<int, 3>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::array<int, 3>, int> >; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >]’
/usr/include/c++/13/bits/stl_map.h:197:7:   required from here
/usr/include/c++/13/type_traits:1167:52: error: static assertion failed: template argument must be a complete class or an unbounded array
 1167 |       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/type_traits:1167:52: note: ‘std::__is_complete_or_unbounded<__type_identity<const array<int, 3> > >((std::__type_identity<const std::array<int, 3> >(), std::__type_identity<const std::array<int, 3> >()))’ evaluates to false
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::is_move_assignable<const std::array<int, 3> >’:
/usr/include/c++/13/type_traits:161:35...