提出 #73708388


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T, U, V;
  int u=0, v=0;
  cin >> S >> T;
  if(S == T) cout << "0" << endl;
  else{
    for(int i=0; i<S.size(); i++){
      if(S[i] != 'A'){
        if(u == 0){
          u = 1;
          U = S[i];
        }
        else U = U + S[i];
      }
    }
    for(int i=0; i<T.size(); i++){
      if(T[i] != 'A'){
        if(v == 0){
          v = 1;
          V = S[i];
        }
        else V = V + S[i];
      }
    }
    if(u == 0){
      if(v == 0){
        int k;
        k = S.size() - T.size();
        cout << abs(k) << endl;
      }
      else cout << "-1" << endl;
    }
    else{
      if(v == 0) cout << "-1" << endl;
      else{
        if(U == V){
          int k=0, sa=0, ta=0, sb=0, tb=0;
          for(int i=0; i<U.size(); i++){
            for(int j=sb; j<S.size(); j++){
              if(S[j] == U[i]){
                sb++;
                break;
              }
              else{
                sa++;
                sb++;
              }
            }
            for(int j=tb; j<T.size(); j++){
              if(T[j] == U[i]){
                tb++;
                break;
              }
              else{
                ta++;
                tb++;
              }
            }
            k += abs(sa - ta);
            sa = 0;
            ta = 0;
          }
          cout << k << endl;
        }
        else cout << "-1" << endl;
      }
    }
  }
}

提出情報

提出日時
問題 C - Insert and Erase A
ユーザ Yuutyan
言語 C++23 (GCC 15.2.0)
得点 0
コード長 1520 Byte
結果 WA
実行時間 > 2000 ms
メモリ 5008 KiB

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0; i<S.size(); i++){
      |                  ~^~~~~~~~~
./Main.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0; i<T.size(); i++){
      |                  ~^~~~~~~~~
./Main.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |           for(int i=0; i<U.size(); i++){
      |                        ~^~~~~~~~~
./Main.cpp:41:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for(int j=sb; j<S.size(); j++){
      |                           ~^~~~~~~~~
./Main.cpp:51:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int j=tb; j<T.size(); j++){
      |                           ~^~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 300
結果
AC × 1
WA × 3
AC × 17
WA × 14
TLE × 2
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt, 04_handmade_08.txt, 04_handmade_09.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt WA 1 ms 3472 KiB
00_sample_01.txt WA 1 ms 3448 KiB
00_sample_02.txt AC 1 ms 3436 KiB
00_sample_03.txt WA 1 ms 3488 KiB
01_random_00.txt AC 110 ms 4000 KiB
01_random_01.txt AC 990 ms 4312 KiB
01_random_02.txt TLE > 2000 ms 4852 KiB
02_random2_00.txt AC 6 ms 3904 KiB
02_random2_01.txt WA 14 ms 4344 KiB
02_random2_02.txt WA 1756 ms 4816 KiB
02_random2_03.txt WA 1261 ms 4920 KiB
02_random2_04.txt WA 547 ms 4444 KiB
02_random2_05.txt WA 84 ms 4132 KiB
02_random2_06.txt WA 934 ms 4844 KiB
02_random2_07.txt WA 23 ms 3936 KiB
02_random2_08.txt WA 118 ms 4180 KiB
02_random2_09.txt WA 290 ms 4212 KiB
02_random2_10.txt WA 1183 ms 4696 KiB
02_random2_11.txt WA 1777 ms 4688 KiB
03_random3_00.txt TLE > 2000 ms 5008 KiB
03_random3_01.txt AC 247 ms 4144 KiB
03_random3_02.txt AC 1032 ms 4508 KiB
03_random3_03.txt AC 454 ms 4344 KiB
04_handmade_00.txt AC 1 ms 3404 KiB
04_handmade_01.txt AC 1 ms 3516 KiB
04_handmade_02.txt AC 1 ms 3404 KiB
04_handmade_03.txt AC 1 ms 3392 KiB
04_handmade_04.txt AC 8 ms 4284 KiB
04_handmade_05.txt AC 1593 ms 4764 KiB
04_handmade_06.txt AC 1602 ms 4740 KiB
04_handmade_07.txt AC 8 ms 4372 KiB
04_handmade_08.txt AC 5 ms 3804 KiB
04_handmade_09.txt AC 5 ms 3904 KiB