Submission #7955


Source Code Expand

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>

using namespace std;

string button[] = { "A", "B", "X", "Y" };

int main()
{
	int n;
	string command;

	cin >> n;
	cin.ignore( 1 );

	cin >> command;

	int count, min = command.length() + 10;

	for ( int l1 = 0; l1 < 4; l1++ )
	{
		for ( int l2 = 0; l2 < 4; l2++ )
		{
			for ( int r1 = 0; r1 < 4; r1++ )
			{
				for ( int r2 = 0; r2 < 4; r2++ )
				{
					string l = button[l1] + button[l2];
					string r = button[r1] + button[r2];

					count = 0;

					for ( unsigned int i = 0; i < command.length(); i++ )
					{
						if ( i + 1 < command.length() )
						{
							if ( ( command[i] == l[0] && command[i+1] == l[1] ) ||
								 ( command[i] == r[0] && command[i+1] == r[1] ) )
							{
								i++;
							}
						}
						count++;
					}

					if ( count < min )
					{
						min = count;
					}
				}
			}
		}
	}

	cout << min << endl;

	return 0;
}

Submission Info

Submission Time
Task C - コマンド入力
User torus711
Language C++ (GCC 4.4.7)
Score 100
Code Size 1183 Byte
Status AC
Exec Time 27 ms
Memory 820 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 45
Set Name Test Cases
All 00_retmax.txt, 00_retmin.txt, 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_twothree_00.txt, 02_twothree_01.txt, 02_twothree_02.txt, 02_twothree_03.txt, 02_twothree_04.txt, 02_twothree_05.txt, 02_twothree_06.txt, 02_twothree_07.txt, 02_twothree_08.txt, 02_twothree_09.txt, 02_twothree_10.txt, 02_twothree_11.txt, 02_twothree_12.txt, 02_twothree_13.txt, 02_twothree_14.txt, 02_twothree_15.txt, 02_twothree_16.txt, 02_twothree_17.txt, 02_twothree_18.txt, 02_twothree_19.txt
Case Name Status Exec Time Memory
00_retmax.txt AC 24 ms 792 KB
00_retmin.txt AC 22 ms 784 KB
00_sample_00.txt AC 21 ms 792 KB
00_sample_01.txt AC 21 ms 780 KB
00_sample_02.txt AC 21 ms 788 KB
01_rnd_00.txt AC 24 ms 784 KB
01_rnd_01.txt AC 25 ms 772 KB
01_rnd_02.txt AC 25 ms 792 KB
01_rnd_03.txt AC 25 ms 784 KB
01_rnd_04.txt AC 25 ms 788 KB
01_rnd_05.txt AC 27 ms 728 KB
01_rnd_06.txt AC 25 ms 812 KB
01_rnd_07.txt AC 25 ms 796 KB
01_rnd_08.txt AC 25 ms 780 KB
01_rnd_09.txt AC 24 ms 788 KB
01_rnd_10.txt AC 24 ms 788 KB
01_rnd_11.txt AC 25 ms 792 KB
01_rnd_12.txt AC 25 ms 784 KB
01_rnd_13.txt AC 25 ms 784 KB
01_rnd_14.txt AC 25 ms 784 KB
01_rnd_15.txt AC 25 ms 764 KB
01_rnd_16.txt AC 25 ms 788 KB
01_rnd_17.txt AC 25 ms 772 KB
01_rnd_18.txt AC 25 ms 760 KB
01_rnd_19.txt AC 25 ms 788 KB
02_twothree_00.txt AC 24 ms 788 KB
02_twothree_01.txt AC 24 ms 792 KB
02_twothree_02.txt AC 22 ms 816 KB
02_twothree_03.txt AC 23 ms 760 KB
02_twothree_04.txt AC 24 ms 788 KB
02_twothree_05.txt AC 23 ms 796 KB
02_twothree_06.txt AC 24 ms 792 KB
02_twothree_07.txt AC 24 ms 792 KB
02_twothree_08.txt AC 24 ms 792 KB
02_twothree_09.txt AC 24 ms 792 KB
02_twothree_10.txt AC 23 ms 788 KB
02_twothree_11.txt AC 23 ms 784 KB
02_twothree_12.txt AC 22 ms 788 KB
02_twothree_13.txt AC 24 ms 764 KB
02_twothree_14.txt AC 24 ms 792 KB
02_twothree_15.txt AC 24 ms 792 KB
02_twothree_16.txt AC 24 ms 732 KB
02_twothree_17.txt AC 24 ms 788 KB
02_twothree_18.txt AC 24 ms 820 KB
02_twothree_19.txt AC 24 ms 760 KB