QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876450 | #7705. Make Your Own Morse Code Palindrome | WeaRD276 | Compile Error | / | / | C++20 | 3.7kb | 2025-01-30 21:26:06 | 2025-01-30 21:26:06 |
Judging History
This is the latest submission verdict.
- [2025-01-30 21:26:06]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-01-30 21:26:06]
- Submitted
answer
/A tree without skin will surely die.
//A man without face is invincible.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
std::map<char, std::string> MC = {
{'A', ".-"}, {'B', "-..."}, {'C', "-.-."}, {'D', "-.."}, {'E', "."},
{'F', "..-."}, {'G', "--."}, {'H', "...."}, {'I', ".."}, {'J', ".---"},
{'K', "-.-"}, {'L', ".-.."}, {'M', "--"}, {'N', "-."}, {'O', "---"},
{'P', ".--."}, {'Q', "--.-"}, {'R', ".-."}, {'S', "..."}, {'T', "-"},
{'U', "..-"}, {'V', "...-"}, {'W', ".--"}, {'X', "-..-"}, {'Y', "-.--"},
{'Z', "--.."}, {'0', "-----"},{'1', ".----"},{'2', "..---"},{'3', "...--"},
{'4', "....-"}, {'5', "....."}, {'6', "-...."}, {'7', "--..."}, {'8', "---.."},
{'9', "----."}
};
vector<pair<char, std::string>> MCVec;
std::map<string, char> MCC;
bool f(const string& need, int p, string& res)
{
if(p==sz(need))
{
return true;
}
for(auto [ch, ms]: MCVec)
{
if(p+sz(ms) <= sz(need) && need.substr(p, sz(ms)) == ms)
{
res.pb(ch);
if(f(need,p+sz(ms), res))
{
return true;
}
res.pop_back();
}
}
return false;
}
int solve()
{
string s;
if(!(getline(cin, s)))return 1;
string ss;
for (char ch: s)
{
if (isalpha(ch))
ss += toupper(ch);
else if (isdigit(ch))
ss += ch;
}
s = ss;
MCC=std::map<string, char>{};
for(auto [k, val]: MC) MCC[val]=k;
MCVec=vector<pair<char, std::string>>(all(MC));
sort(all(MCVec), [](const pair<char, std::string>& e1, const pair<char, std::string>& e2) -> bool{
return sz(e1.y) > sz(e2.y);
});
string ms;
for(auto item: s) ms += MC[item];
// ----..-.-..-- [.] -...-.
// ..-.-- -----
string res=string(10000, '?');
//cout<<ms<<'\n';
FOR(i,sz(ms)/2,sz(ms)+1)
{
bool ok=true;
int j,k;
for(j=i,k=i; j < sz(ms); ++j, --k)
{
if(ms[j] != ms[k]) ok=false;
}
if(ok)
{
string t=ms.substr(0,k+1);
//cout<<t<<'\n';
reverse(all(t));
string cur_res;
if(f(t,0, cur_res))
{
if(sz(cur_res) < sz(res))
res=cur_res;
}
}
}
FOR(i,sz(ms)/2,sz(ms)+1)
{
bool ok=true;
int j,k;
for(j=i+1,k=i; j < sz(ms); ++j, --k)
{
if(ms[j] != ms[k]) ok=false;
}
if(ok)
{
string t=ms.substr(0,k+1);
reverse(all(t));
string cur_res;
if(f(t,0, cur_res))
{
if(sz(cur_res) < sz(res))
res=cur_res;
}
}
}
cout<<sz(res)<<" "<<res<<'\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
详细
answer.code:1:1: error: expected unqualified-id before ‘/’ token 1 | /A tree without skin will surely die. | ^ In file included from /usr/include/c++/14/ext/typelist.h:46, from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:45, from answer.code:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: ‘constexpr const bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration ‘template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)’ 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: ‘nullptr_t’ is not a member of ‘std’ 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/utility:69, from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:46, from /usr/include/c++/14/ext/pb_ds/tag_and_trait.hpp:46, from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:46: /usr/include/c++/14/type_traits:666:33: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:45: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: ‘nullptr_t’ declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: ‘size_t’ declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1438:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: ‘size_t’ declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1440:26: error: ‘std::size_t’ has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: ‘_Size’ was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: ‘size_t’ declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1446 | : public integral_constant<std::s...