提出 #58183120


ソースコード 拡げる

//yukicoder@cpp17

#include <iostream>
#include <iomanip>

#include <algorithm>

#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <random>

#include <bitset>

#include <complex>

#include <utility>

#include <numeric>

#include <functional>


using namespace std;
using ll = long long;
using P = pair<ll,ll>;


const ll MOD = 998244353;
const ll MODx = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62LL)-1;
const double EPS = (1e-10);


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};


template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }
 
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

/* comment outed because can cause bugs
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
*/
int main(){
  string s;cin>>s;
  vector<int> A(26);
  for(int i = 0; 26 > i; i++){
    A[s[i]-'A'] = i;
  }
  int ans = 0;
  for(int i = 1; 26 > i; i++){
    ans += abs(A[i]-A[i-1]);
  }
  cout << ans << endl;
  return 0;
}

提出情報

提出日時
問題 B - 1D Keyboard
ユーザ CleyL
言語 C++ 20 (gcc 12.2)
得点 200
コード長 1710 Byte
結果 AC
実行時間 1 ms
メモリ 3640 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 2
AC × 28
セット名 テストケース
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 3508 KiB
00_sample_01.txt AC 1 ms 3508 KiB
01_random_00.txt AC 1 ms 3484 KiB
01_random_01.txt AC 1 ms 3356 KiB
01_random_02.txt AC 1 ms 3436 KiB
01_random_03.txt AC 1 ms 3460 KiB
01_random_04.txt AC 1 ms 3480 KiB
01_random_05.txt AC 1 ms 3448 KiB
01_random_06.txt AC 1 ms 3504 KiB
01_random_07.txt AC 1 ms 3480 KiB
01_random_08.txt AC 1 ms 3556 KiB
01_random_09.txt AC 1 ms 3512 KiB
01_random_10.txt AC 1 ms 3356 KiB
01_random_11.txt AC 1 ms 3520 KiB
01_random_12.txt AC 1 ms 3484 KiB
01_random_13.txt AC 1 ms 3504 KiB
01_random_14.txt AC 1 ms 3356 KiB
01_random_15.txt AC 1 ms 3352 KiB
01_random_16.txt AC 1 ms 3640 KiB
01_random_17.txt AC 1 ms 3640 KiB
01_random_18.txt AC 1 ms 3508 KiB
02_hand_00.txt AC 1 ms 3552 KiB
02_hand_01.txt AC 1 ms 3524 KiB
02_hand_02.txt AC 1 ms 3452 KiB
02_hand_03.txt AC 1 ms 3456 KiB
02_hand_04.txt AC 1 ms 3480 KiB
02_hand_05.txt AC 1 ms 3428 KiB
02_hand_06.txt AC 1 ms 3456 KiB