提出 #58199241
ソースコード 拡げる
#if !__INCLUDE_LEVEL__
#include __FILE__
int main(){
string S;cin>>S;
int ans=0;
int now=0;
for(char c='A'; c<'A'+26; c+=1){
rep(i,0,26){
if(S[i]==c){
if(c!='A')
ans += abs(now-i);
// cout<<abs(now-i)<<endl;
now=i;
break;
}
}
}
cout<<ans<<endl;
return 0;
}
#else
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(13); } }init;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define rep(i, x, limit) for (int i = (int)x; i < (int)limit; i++)
#define REP(i, x, limit) for (int i = (int)x; i <= (int)limit; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define YES cout << "YES" << el
#define NO cout << "NO" << el
#define eps (1e-10)
#define Equals(a,b) (fabs((a) - (b)) < eps )
const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
//配列の要素を空白区切りで出力 第二引数をtrueにすると改行区切り
template<class T> inline void print_vec(const vector<T>& v, bool split_line=false) {
if(v.empty()){
cout << "This vector is empty." << el;
return;
}
for (int i = 0; i < v.size(); i++) {
if(v[i]==inf || v[i]==infl) cout << 'x' << " \n"[split_line || i+1==(int)v.size()];
else cout << v[i] << " \n"[split_line || i+1==(int)v.size()];
}
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
#endif
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - 1D Keyboard |
| ユーザ | naok_000 |
| 言語 | C++ 23 (gcc 12.2) |
| 得点 | 200 |
| コード長 | 2216 Byte |
| 結果 | AC |
| 実行時間 | 1 ms |
| メモリ | 3616 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 02_hand_00.txt, 02_hand_01.txt, 02_hand_02.txt, 02_hand_03.txt, 02_hand_04.txt, 02_hand_05.txt, 02_hand_06.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3600 KiB |
| 00_sample_01.txt | AC | 1 ms | 3488 KiB |
| 01_random_00.txt | AC | 1 ms | 3532 KiB |
| 01_random_01.txt | AC | 1 ms | 3524 KiB |
| 01_random_02.txt | AC | 1 ms | 3468 KiB |
| 01_random_03.txt | AC | 1 ms | 3408 KiB |
| 01_random_04.txt | AC | 1 ms | 3444 KiB |
| 01_random_05.txt | AC | 1 ms | 3476 KiB |
| 01_random_06.txt | AC | 1 ms | 3536 KiB |
| 01_random_07.txt | AC | 1 ms | 3532 KiB |
| 01_random_08.txt | AC | 1 ms | 3548 KiB |
| 01_random_09.txt | AC | 1 ms | 3544 KiB |
| 01_random_10.txt | AC | 1 ms | 3568 KiB |
| 01_random_11.txt | AC | 1 ms | 3532 KiB |
| 01_random_12.txt | AC | 1 ms | 3616 KiB |
| 01_random_13.txt | AC | 1 ms | 3548 KiB |
| 01_random_14.txt | AC | 1 ms | 3460 KiB |
| 01_random_15.txt | AC | 1 ms | 3472 KiB |
| 01_random_16.txt | AC | 1 ms | 3440 KiB |
| 01_random_17.txt | AC | 1 ms | 3596 KiB |
| 01_random_18.txt | AC | 1 ms | 3548 KiB |
| 02_hand_00.txt | AC | 1 ms | 3536 KiB |
| 02_hand_01.txt | AC | 1 ms | 3540 KiB |
| 02_hand_02.txt | AC | 1 ms | 3548 KiB |
| 02_hand_03.txt | AC | 1 ms | 3548 KiB |
| 02_hand_04.txt | AC | 1 ms | 3596 KiB |
| 02_hand_05.txt | AC | 1 ms | 3436 KiB |
| 02_hand_06.txt | AC | 1 ms | 3532 KiB |