QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394897 | #1361. Ant Typing | Omar_Alaa03# | WA | 6ms | 3768kb | C++20 | 1.3kb | 2024-04-20 21:27:51 | 2024-04-20 21:27:53 |
Judging History
answer
/**
* author: RUBY
* LIVE LOVE LAUGH <3
**/
#include <bits/stdc++.h>
#define el '\n'
typedef long long ll;
#define crispy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
bool vis[10];
int main() {
crispy
int t = 1;
//cin >> t;
while (t--) {
string s;
cin>>s;
string st = "";
for (int i = 0; i < s.size(); ++i) {
if(!vis[s[i]-'0']){
vis[s[i]-'0'] = 1;
st+=s[i];
}
}map<char,int>mp;
for (int i = 0; i < st.size(); ++i) {
mp[st[i]] = i;
}
char cur = st[0];
ll ans =0;
for (int i = 0; i < s.size(); ++i) {
ans += (abs(mp[s[i]]-mp[cur]) +1);
cur = s[i];
}
reverse(s.begin(),s.end());
memset(vis,0,sizeof vis);
for (int i = 0; i < s.size(); ++i) {
if(!vis[s[i]-'0']){
vis[s[i]-'0'] = 1;
st+=s[i];
}
}
for (int i = 0; i < st.size(); ++i) {
mp[st[i]] = i;
}
cur = st[0];
ll ac =0;
for (int i = 0; i < s.size(); ++i) {
ac += (abs(mp[s[i]]-mp[cur]) +1);
cur = s[i];
}
cout<<min(ac,ans)<<el;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
6
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 6ms
memory: 3768kb
input:
352836512461179399826927828445163785261417666171453483576899676763764928341261962358737253818463814858565221466575498899898835568743316628247174676952381449147193191788177911797527361649543158616436321694172452689147288835568666918784929695569394655833978219612584637258492511247969998253315177569943...
output:
394616
result:
wrong answer 1st lines differ - expected: '392933', found: '394616'