提出 #73693797


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;

int main(){
  string S,T;cin>>S>>T;
  
  int SA=0,TA=0;
  
  int i=0,j=0;
  int answer=0;
  while(1){
    //cout <<answer<<endl;
    while(i<S.size() && S.at(i)=='A'){
      SA++;
      i++;
    }
    while(j<T.size() && T.at(j)=='A'){
      TA++;
      j++;
    }
    if(i==S.size() || j==T.size()){
      if(i==S.size() && j==T.size()){
        answer+=abs(TA-SA);
        break;
      }else{
        answer=-1;
        break;
      }
    }
    // i<N && j<N
    
    if(S.at(i)==T.at(j)){
      answer+=abs(TA-SA);
      i++;
      j++;
      SA=0;
      TA=0;
      continue;
    }else{
      answer=-1;
      break;
    }
    
    
  }
  cout <<answer;
}

提出情報

提出日時
問題 C - Insert and Erase A
ユーザ delta2197
言語 C++23 (GCC 15.2.0)
得点 300
コード長 751 Byte
結果 AC
実行時間 9 ms
メモリ 4552 KiB

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:13:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(i<S.size() && S.at(i)=='A'){
      |           ~^~~~~~~~~
./Main.cpp:17:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     while(j<T.size() && T.at(j)=='A'){
      |           ~^~~~~~~~~
./Main.cpp:21:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if(i==S.size() || j==T.size()){
      |        ~^~~~~~~~~~
./Main.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if(i==S.size() || j==T.size()){
      |                       ~^~~~~~~~~~
./Main.cpp:22:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |       if(i==S.size() && j==T.size()){
      |          ~^~~~~~~~~~
./Main.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |       if(i==S.size() && j==T.size()){
      |                         ~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 4
AC × 33
セット名 テストケース
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 AC 1 ms 3444 KiB
00_sample_01.txt AC 1 ms 3580 KiB
00_sample_02.txt AC 1 ms 3608 KiB
00_sample_03.txt AC 1 ms 3588 KiB
01_random_00.txt AC 2 ms 3840 KiB
01_random_01.txt AC 4 ms 3712 KiB
01_random_02.txt AC 8 ms 4352 KiB
02_random2_00.txt AC 5 ms 3912 KiB
02_random2_01.txt AC 8 ms 4380 KiB
02_random2_02.txt AC 9 ms 4552 KiB
02_random2_03.txt AC 9 ms 4428 KiB
02_random2_04.txt AC 7 ms 4048 KiB
02_random2_05.txt AC 5 ms 4032 KiB
02_random2_06.txt AC 8 ms 3912 KiB
02_random2_07.txt AC 5 ms 3964 KiB
02_random2_08.txt AC 8 ms 4116 KiB
02_random2_09.txt AC 9 ms 4236 KiB
02_random2_10.txt AC 7 ms 4344 KiB
02_random2_11.txt AC 8 ms 4240 KiB
03_random3_00.txt AC 7 ms 4376 KiB
03_random3_01.txt AC 7 ms 3984 KiB
03_random3_02.txt AC 7 ms 4104 KiB
03_random3_03.txt AC 7 ms 4124 KiB
04_handmade_00.txt AC 1 ms 3468 KiB
04_handmade_01.txt AC 1 ms 3584 KiB
04_handmade_02.txt AC 1 ms 3584 KiB
04_handmade_03.txt AC 1 ms 3440 KiB
04_handmade_04.txt AC 8 ms 4368 KiB
04_handmade_05.txt AC 8 ms 4360 KiB
04_handmade_06.txt AC 8 ms 4372 KiB
04_handmade_07.txt AC 8 ms 4372 KiB
04_handmade_08.txt AC 4 ms 3912 KiB
04_handmade_09.txt AC 4 ms 3996 KiB