Submission #1789509


Source Code Expand

#include <string>
#include <iostream>

using namespace std;

string return_string(string str);
int string_aaa(string str);

int main()
{
	int Q;
	string str_in;
	int l,r;

	cin >> str_in;
	cin >> Q;
	for(int i=0;i<Q;i++)
	{
		cin >> l >> r;
		l = l-1;
		r = r-1;
		string substring = str_in.substr(l,r-l+1);
		string ans = return_string(substring);
		if(ans.empty())
		{
			cout << "Yes" << endl;
		}
		else if(!ans.empty())
		{
			cout << "No" << endl;
		}
	}

	return 0;

}

int string_aaa(string str)
{
	for(int i=0;i<str.size()-1;i++)
	{
		if(str[i] == str[i+1])
		{	
			return i;
		}
	}
	return -1;
}

string return_string(string str)
{
	int index;
	string str_tmp = str;
	while(index = string_aaa(str_tmp), index != -1)
	{
		//cout << index << endl;
		if( str_tmp[index] != 'z')
		{
			str_tmp.insert(str_tmp.begin()+index,str_tmp[index]+1);
			str_tmp.erase(str_tmp.begin()+index+1);
			str_tmp.erase(str_tmp.begin()+index+1);
			//cout << str_tmp << endl;
		}else if( str_tmp[index] == 'z')
		{
			//cout << str_tmp << endl;
			str_tmp.erase(str_tmp.begin()+index);
			str_tmp.erase(str_tmp.begin()+index);
		}
	}
	return str_tmp;
}

Submission Info

Submission Time
Task C - Robot and String
User okechan08
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1214 Byte
Status RE
Exec Time 2107 ms
Memory 1908 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1300
Status
RE × 3
AC × 2
TLE × 16
RE × 49
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt
Case Name Status Exec Time Memory
0_00.txt RE 98 ms 256 KB
0_01.txt RE 97 ms 256 KB
0_02.txt RE 99 ms 256 KB
1_00.txt AC 211 ms 512 KB
1_01.txt AC 207 ms 512 KB
1_02.txt TLE 2103 ms 1908 KB
1_03.txt TLE 2103 ms 1156 KB
1_04.txt TLE 2103 ms 1536 KB
1_05.txt RE 1359 ms 1156 KB
1_06.txt RE 231 ms 900 KB
1_07.txt RE 138 ms 900 KB
1_08.txt RE 200 ms 900 KB
1_09.txt TLE 2103 ms 1156 KB
1_10.txt TLE 2103 ms 1516 KB
1_11.txt RE 1447 ms 1028 KB
1_12.txt TLE 2103 ms 1284 KB
1_13.txt RE 730 ms 1028 KB
1_14.txt TLE 2103 ms 1532 KB
1_15.txt RE 111 ms 900 KB
1_16.txt RE 2023 ms 1068 KB
1_17.txt RE 197 ms 900 KB
1_18.txt TLE 2103 ms 1532 KB
1_19.txt RE 117 ms 900 KB
1_20.txt RE 116 ms 900 KB
1_21.txt RE 112 ms 900 KB
1_22.txt RE 165 ms 900 KB
1_23.txt TLE 2103 ms 1520 KB
1_24.txt RE 126 ms 900 KB
1_25.txt RE 111 ms 900 KB
1_26.txt TLE 2103 ms 1536 KB
1_27.txt TLE 2107 ms 1412 KB
1_28.txt RE 114 ms 900 KB
1_29.txt RE 241 ms 1028 KB
1_30.txt RE 809 ms 1156 KB
1_31.txt RE 293 ms 1028 KB
1_32.txt RE 124 ms 900 KB
1_33.txt RE 111 ms 900 KB
1_34.txt RE 1711 ms 1156 KB
1_35.txt RE 112 ms 900 KB
1_36.txt TLE 2103 ms 1712 KB
1_37.txt TLE 2103 ms 1524 KB
1_38.txt RE 111 ms 900 KB
1_39.txt RE 112 ms 900 KB
1_40.txt RE 113 ms 900 KB
1_41.txt RE 886 ms 1284 KB
1_42.txt RE 112 ms 900 KB
1_43.txt RE 115 ms 900 KB
1_44.txt RE 153 ms 900 KB
1_45.txt RE 774 ms 1284 KB
1_46.txt RE 112 ms 900 KB
1_47.txt RE 112 ms 900 KB
1_48.txt RE 382 ms 1028 KB
1_49.txt RE 1359 ms 1156 KB
1_50.txt RE 380 ms 1028 KB
1_51.txt RE 1405 ms 1028 KB
1_52.txt RE 137 ms 900 KB
1_53.txt TLE 2103 ms 1284 KB
1_54.txt RE 559 ms 1156 KB
1_55.txt TLE 2103 ms 1156 KB
1_56.txt RE 121 ms 900 KB
1_57.txt TLE 2103 ms 1524 KB
1_58.txt RE 195 ms 900 KB
1_59.txt RE 186 ms 900 KB
1_60.txt RE 186 ms 900 KB
1_61.txt RE 165 ms 900 KB
1_62.txt RE 143 ms 900 KB
1_63.txt RE 898 ms 1284 KB