QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#654420#8234. Period of a StringTomorrowCompile Error//C++172.1kb2024-10-18 21:33:072024-10-18 21:33:10

Judging History

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

  • [2024-10-18 21:33:10]
  • 评测
  • [2024-10-18 21:33:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define C const
#define OP operator
#define pb push_back
#define ft first
#define sd second
#define TTT template<typename T = I>
#define BE(v) v.begin(), v.end()
#define VD void
#define I int
#define STR string
using PII = pair<I, I>;
TTT using V = vector<T>;

#define FORX(v) for(auto& x : v)
#define FOR(i, b, e)  for(auto i = b, _e = (decltype(i))e;i != _e; ++i)
#define FORR(i, b, e) for(auto i = b, _e = (decltype(i))e;i != _e; --i)
#define FUNC(T, f, ...) function<T(__VA_ARGS__)> f = [&](__VA_ARGS__)->T

TTT VD setmin(T& a, C T& b) { if (b < a)a = b; }
TTT VD setmax(T& a, C T& b) { if (a < b)a = b; }

struct Lim
{
	V<I> s;
	bool OP < (C Lim& _)C { return s.size() < _.s.size(); }
};

VD test()
{
	I n;cin >> n;
	V<V<I>> ss(n);
	V<V<I>> cnt(n, V<I>(26));
	unordered_set<Lim> lim;
	V<STR> ans(n);
	FOR(i, 0, n)
	{
		STR str;cin >> str;ss[i].resize(str.size());
		FOR(j, 0, str.size())cnt[i][ss[i][j] = str[j] - 'a']++;
	}

	FORR(i, n - 1, 0)
	{
		lim.insert({ ss[i] });

		for (auto it = --lim.end();it->s.size() >= ss[i - 1].size();it = --lim.end())
		{
			V<I> s = it->s; Lim nl;
			lim.erase(it);
			if (s.size() == 0)continue;

			I tm = s.size() / ss[i - 1].size();

			V<I> c(26);
			FORX(s)c[x]++;
			FORX(ss[i - 1])c[x] -= tm;
			FOR(j, 0, 26)
			{
				if (c[j] < 0 || c[j] > cnt[i - 1][j])
				{
					cout << "NO\n";
					return;
				}
				while (c[j]--)nl.s.pb(j);
			}
			lim.insert(nl);
		}
	}

	lim.insert({ ss[0] });
	V<I> cur(26);
	FORX(lim)
	{
		V<I> c(26);
		for (auto& y : x.s)c[y]++;
		FOR(i, 0, 26)
		{
			while (cur[i] < c[i])
			{
				++cur[i]; ans[0].pb(i + 'a');
				if (cur[i] > cnt[0][i])
				{
					cout << "NO\n";
					return;
				}
			}
		}
	}

	FOR(i, 1, n)
	{
		FOR(j, 0, ss[i].size())ans[i].pb(ans[i - 1][j % ss[i - 1].size()]);
	}
	cout << "YES\n";
	FORX(ans)cout << x << '\n';
}

I main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	if (fopen("test.in", "r"))
	{
		freopen("test.in", "r", stdin);
		freopen("test.out", "w", stdout);
	}
	I t = 1;
	cin >> t;
	while (t--)test();
	return 0;
}

Details

answer.code: In function ‘void test()’:
answer.code:35:28: error: use of deleted function ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = Lim; _Hash = std::hash<Lim>; _Pred = std::equal_to<Lim>; _Alloc = std::allocator<Lim>]’
   35 |         unordered_set<Lim> lim;
      |                            ^~~
In file included from /usr/include/c++/13/unordered_set:41,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:189,
                 from answer.code:1:
/usr/include/c++/13/bits/unordered_set.h:142:7: note: ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = Lim; _Hash = std::hash<Lim>; _Pred = std::equal_to<Lim>; _Alloc = std::allocator<Lim>]’ is implicitly deleted because the default definition would be ill-formed:
  142 |       unordered_set() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_set.h:142:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = Lim; _Value = Lim; _Alloc = std::allocator<Lim>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Lim>; _Hash = std::hash<Lim>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’
In file included from /usr/include/c++/13/bits/unordered_map.h:33,
                 from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/hashtable.h:530:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = Lim; _Value = Lim; _Alloc = std::allocator<Lim>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Lim>; _Hash = std::hash<Lim>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’ is implicitly deleted because the default definition would be ill-formed:
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = Lim; _Value = Lim; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Lim>; _Hash = std::hash<Lim>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’
In file included from /usr/include/c++/13/bits/hashtable.h:35:
/usr/include/c++/13/bits/hashtable_policy.h:1710:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = Lim; _Value = Lim; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Lim>; _Hash = std::hash<Lim>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1710 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1710:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = Lim; _Value = Lim; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<Lim>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’
/usr/include/c++/13/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<Lim>]’:
/usr/include/c++/13/bits/hashtable_policy.h:1297:7:   required from here
/usr/include/c++/13/bits/hashtable_policy.h:1214:49: error: use of deleted function ‘std::hash<Lim>::hash()’
 1214 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from /usr/include/c++/13/string_view:42,
                 from /usr/include/c++/13/bits/basic_string.h:47,
                 from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52:
/usr/include/c++/13/bits/functional_hash.h:102:12: note: ‘std::hash<Lim>::hash()’ is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |  ...