提出 #73714270


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int tot1,tot2,ans;
string s,t;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x<10)putchar(x+'0');
	else write(x/10),putchar(x%10+'0');
	return;
}
int main(){
	cin>>s>>t;
	while(tot1<s.size()||tot2<t.size()){
		if(tot1>=s.size()){
			s[0]='@',tot1=0;
		}
		if(tot2>=t.size()){
			t[0]='@',tot2=0;
		}
		if(s[tot1]==t[tot2]){
			tot1++,tot2++;
			continue;
		}
		if(s[tot1]!='A'&&t[tot2]!='A'){
			write(-1);
			return 0;
		}
		if(s[tot1]=='A'){
			s.erase(tot1,1);
			ans++;
		}
		if(t[tot2]=='A'){
			t.erase(tot2,1);
			ans++;
		}
	}
	write(ans);
	return 0;
}

提出情報

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

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         while(tot1<s.size()||tot2<t.size()){
      |               ~~~~^~~~~~~~~
./Main.cpp:20:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         while(tot1<s.size()||tot2<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(tot1>=s.size()){
      |                    ~~~~^~~~~~~~~~
./Main.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 if(tot2>=t.size()){
      |                    ~~~~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 300
結果
AC × 4
AC × 18
TLE × 15
セット名 テストケース
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 3448 KiB
00_sample_01.txt AC 1 ms 3368 KiB
00_sample_02.txt AC 1 ms 3448 KiB
00_sample_03.txt AC 1 ms 3448 KiB
01_random_00.txt AC 3 ms 3752 KiB
01_random_01.txt AC 5 ms 3664 KiB
01_random_02.txt AC 9 ms 4452 KiB
02_random2_00.txt AC 7 ms 3976 KiB
02_random2_01.txt TLE > 2000 ms 4300 KiB
02_random2_02.txt TLE > 2000 ms 4452 KiB
02_random2_03.txt TLE > 2000 ms 4340 KiB
02_random2_04.txt TLE > 2000 ms 4016 KiB
02_random2_05.txt TLE > 2000 ms 4064 KiB
02_random2_06.txt TLE > 2000 ms 4032 KiB
02_random2_07.txt TLE > 2000 ms 3920 KiB
02_random2_08.txt TLE > 2000 ms 4196 KiB
02_random2_09.txt TLE > 2000 ms 4252 KiB
02_random2_10.txt AC 1519 ms 4108 KiB
02_random2_11.txt AC 1843 ms 4428 KiB
03_random3_00.txt AC 882 ms 4348 KiB
03_random3_01.txt TLE > 2000 ms 3876 KiB
03_random3_02.txt TLE > 2000 ms 4244 KiB
03_random3_03.txt AC 858 ms 4244 KiB
04_handmade_00.txt AC 1 ms 3328 KiB
04_handmade_01.txt AC 1 ms 3332 KiB
04_handmade_02.txt AC 1 ms 3468 KiB
04_handmade_03.txt AC 1 ms 3348 KiB
04_handmade_04.txt AC 10 ms 4436 KiB
04_handmade_05.txt TLE > 2000 ms 4324 KiB
04_handmade_06.txt TLE > 2000 ms 4440 KiB
04_handmade_07.txt AC 10 ms 4376 KiB
04_handmade_08.txt TLE > 2000 ms 3896 KiB
04_handmade_09.txt TLE > 2000 ms 3888 KiB