QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#407609 | #1361. Ant Typing | TheSleepyDevil# | WA | 1ms | 3772kb | C++14 | 2.0kb | 2024-05-09 06:52:50 | 2024-05-09 06:52:50 |
Judging History
answer
/*
Hell, 'til I reach Hell, I ain't scared
Mama checkin' in my bedroom, I ain't there
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Major ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define read(a,n) for(int i = 0 ; i<n ; i++) cin>>a[i];
#define write(a) for(auto x : a) cout<<x<<" ";
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define el "\n"
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf=4e18;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,1,0,-1,1,-1,1,-1};
const int mod=1e9+7;
const int MAX =1e6+7;
//---------------------------Function----------------------------------//
int check(vector<int>arr,string s){
map<int,int>mp;
for(int i=0;i<9;i++){
mp[arr[i]]=i;
}
int ans=0,bef=0;
for(int i=0;i<s.size();i++){
int left=abs(mp[(s[i]-'0')]-bef);
ans+=left;
ans++;
bef=mp[s[i]-'0'];
}
return ans;
}
void TestCake(){
vector<int>arr;
map<char,int>mp;
string s;cin>>s;
int n=s.size();
for(int i=n-1;i>=0;i--){
if(mp[s[i]])continue;
arr.pb(s[i]-'0');
mp[s[i]]=1;
}
int ans=check(arr,s);
cout<<ans;
}
//------------------------------Main---------------------------//
signed main(){
Major
int T = 1;
// cin >> T;
while(T--){
TestCake();
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
6
output:
9
result:
wrong answer 1st lines differ - expected: '1', found: '9'