QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#847171 | #5737. Remorse | LaVuna47# | AC ✓ | 2ms | 4168kb | C++20 | 2.2kb | 2025-01-07 18:24:48 | 2025-01-07 18:24:49 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#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
map<string, int> A;
void gen(const string& s, int cost)
{
if(cost > 30)
{
return ;
}
if(s.empty())
gen(s+'-', cost+3), gen(s+'.',cost+1);
else
{
A[s]=cost;
gen(s+'-', cost+4), gen(s+'.',cost+2);
}
}
int solve()
{
string s;
getline(cin, s);
string t;
for(auto item: s)
{
if(item>='a'&&item<='z')t+=item;
else if(item>='A'&&item<='Z')t += char(item-'A'+'a');
}
vector<int> C(26);
for(auto item: t)C[item-'a'] += 1;
vector<pair<int, char>> a(26);
FOR(i,0,26) a[i]={C[i], char(i+'a')};
sort(rall(a));
gen("",0);
auto AVec=vector<pair<int,string>>();
for(auto [key, val]: A)
AVec.pb({val, key});
sort(all(AVec));
vector<int> co(26,0);
FOR(i,0,26)
{
co[a[i].y-'a']=AVec[i].x;
}
ll res=(sz(t)-1) * 3;
for(auto ch: t) res += co[ch-'a'];
cout<<res<<'\n';
return 1;
}
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
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3952kb
input:
ICPC
output:
17
result:
ok single line: '17'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3948kb
input:
A
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 4168kb
input:
The quick brown dog jumps over the lazy fox.
output:
335
result:
ok single line: '335'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3908kb
input:
Now is the time for all good men to come to the aid of their country. Fourscore and seven years ago our forefathers brought to this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.
output:
1607
result:
ok single line: '1607'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3908kb
input:
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for th...
output:
179819
result:
ok single line: '179819'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3972kb
input:
QZciVKAgzAHHDgABJMhJvnKIwdSNqnnLPHnIAtGmsKUAxLBrzdLmsingreHuegdzTCnEMXLNFAILkhIuPvLzMefxpJIFNduQBnJAhsAkTRripMtFsfQaBxpyKnpvGEcgjClfxiuMLKuKwvfpbUwkeRsiEkcywOnsGmybWoWihMwhaRlAXOdoaZcsQSXfQfghItUnsEjvJhHAYEYSHRwidLDjIgKgkCkNaIXlylXOTAsUXeJwVMbiVHHvrQOmdlNjEFMvKCzlFCvtwwYZQoVjkoqSUZqCGIbMeCwNWOpuHHYG...
output:
347243
result:
ok single line: '347243'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
QbeEZdbSySOxwJrwsfzRlqnxuFvdFLukHwFtCUbFkbrOarmSeREicvBYfnUA
output:
549
result:
ok single line: '549'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
iMOMNqgkeWjFejBWIifAthLQOUkDwjvWwqIFRHvTupZmbmaMlGfqEKnQEQdRWNQfXgCDGsLKhjaLEcOrnZdHeeRxlaBiLBCnFKyJVmZbkRkkMePkWDczHEpTOkDQgHVyNVZEoqTTOBkLovaOeiqmuKtYBAPizRgMFDCVPthTCiLPItNkMpPCnffsvcwlxMnOxmBFbkHoNLCkuIqiTeaRSyvbycMCcZVzujKBDqwMGciKiTyrMjRsDrNDEDRBOrQwOUDiGCYdKKbGznSEpYMzwgZiyVzAWXKzNOjTUVamYoUR...
output:
21965
result:
ok single line: '21965'