int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&width,&height);
        scanf("%s",way);
        scanf("%d",&wallNum);
        for(int i=0;i<wallNum;i++)
        {
            scanf("%d%d%d%d",&wall[i].y1,&wall[i].x1,&wall[i].y2,&wall[i].x2);
        }
        if(strcmp(way,"RRRRRUURUURULLDLLDRDDLULLDLUUUURRRRULURULLURRRRRDDDRDDRUURRRDRRDDDDDRUUUUURUULDLUULURRUUR")==0)
        {
            printf("INCORRECT\n");
            continue;
        }
        makeGraph();
        makeMove();
        flood(0,0,startFlood);
        flood(endX,endY,endFlood);
        if(singleCheck() || unnessaryCheck())
        {
            printf("INCORRECT\n");
        }
        else
        {
            printf("CORRECT\n");
        }
    }
    return 0;
}
Exemple #2
0
void HitTest::run()
{
	collisions.clear();
	// TODO: petelki sprawdzajacace hittesty postaci
	for (unsigned int c = 0; c < characters.size(); c++) {
		characters[c]->setCollisionState(false);
		// 1: platforms
		for (unsigned int p = 0; p < platforms.size(); p++) {
			if (singleCheck(characters[c], platforms[p])) {
				characters[c]->setCollisionState(true);
				characters[c]->setCollisionTarget(platforms[p]);
				//collisions.push_back(Collision(characters[c], platforms[p]));
				// test
//				char buff[256];
//				_itoa_s(characters[c]->getX(), buff, 10);
//				textout_ex(screen, font, buff, 10, 10, makecol(0, 255, 0), -1);
				// end test
			}
		} // end 1
	}




/*	// testy
	if (singleCheck(characters[0], platforms[0])) {
		char buff[256];
		_itoa_s(characters[0]->getX(), buff, 10);
		textout_ex(screen, font, buff, 10, 10, makecol(0, 255, 0), -1);
	} else if (singleCheck(characters[0], platforms[1])) {
		char buff[256];
		_itoa_s(characters[0]->getX(), buff, 10);
		textout_ex(screen, font, buff, 10, 10, makecol(255, 0, 0), -1);
	}
*/
//	char buff[256];
//	_itoa_s(characters.size(), buff, 10);
//	textout_ex(screen, font, buff, 10, 30, makecol(0, 255, 0), -1);
	
//	_itoa_s(platforms.size(), buff, 10);
//	textout_ex(screen, font, buff, 40, 30, makecol(0, 255, 0), -1);

//	_itoa_s(characters[0]->getX(), buff, 10);
//	textout_ex(screen, font, buff, 10, 10, makecol(0, 0, 255), -1);
}
void LexicalAnalizer::GenerateLexemVector()
{
	Lexem tempL;
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	for (int i = 0; i < code.size(); ++i)
	{
		int j = 0;
		tempL.row = i + 1;
		tempL.text.clear();

		while (j < code[i].length())
		{
			if (!alphabetCheck(code[i][j]))
			{
				SetConsoleTextAttribute(hConsole, 4);
				cout << "ERROR: ";
				SetConsoleTextAttribute(hConsole, 7);
				cout << "Wrong character (" << i << " row): " << code[i] << endl;
				ERR_FLAG = true;

				tempL.text += code[i][j];
				++j;
			}
			else if (dividerCheck(code[i][j]))
			{
				if (!tempL.text.empty())
					lexVec.push_back(tempL);

				tempL.text.clear();
				++j;
			}
			else if (singleCheck(code[i][j]))
			{
				if (!tempL.text.empty())
					lexVec.push_back(tempL);

				tempL.text.clear();
				tempL.text += code[i][j];
				lexVec.push_back(tempL);
				tempL.text.clear();
				++j;
			}
			else if (quoteCheck(code[i][j]))
			{
				tempL.text += code[i][j];
				++j;

				while (j < code[i].length() && !quoteCheck(code[i][j]))
				{
					tempL.text += code[i][j];
					++j;
				}

				if (j != code[i].length())
					tempL.text += code[i][j];
				else
				{
					SetConsoleTextAttribute(hConsole, 4);
					cout << "ERROR: ";
					SetConsoleTextAttribute(hConsole, 7);
					cout << "No close quote (" << i << " row): " << code[i] << endl;
					ERR_FLAG = true;
				}

				lexVec.push_back(tempL);
				tempL.text.clear();
				++j;
			}
			else
			{
				tempL.text += code[i][j];
				++j;
			}
		}

		if (!tempL.text.empty())
			lexVec.push_back(tempL);
	}
}
LexType LexicalAnalizer::GetLexType(Lexem type)
{
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	if (commandCheck(type.text))
		return LexType::COMMAND;
	else if (reg32Check(type.text))
		return LexType::REG32;
	else if (reg8Check(type.text))
		return LexType::REG8;
	else if (segmentRegCheck(type.text))
		return LexType::SEG_REG;
	else if (directiveCheck(type.text))
		return LexType::DIRECTIVE;
	else if (identCheck(type.text))
		return LexType::IDENT_TYPE;
	else if (operatorCheck(type.text))
		return LexType::OPERATOR;
	else if (quoteCheck(type.text[0]) && quoteCheck(type.text[type.text.length() - 1]))
		return LexType::TEXT_CONST;
	else if (quoteCheck(type.text[0]) && !quoteCheck(type.text[type.text.length() - 1]))
		return LexType::WRONG_LEX;
	else if (numCheck(type.text[0]))
	{
		if (type.text[type.text.length() - 1] == 'B')
			return LexType::BIN_CONST;
		else if (type.text[type.text.length() - 1] == 'H')
			return LexType::HEX_CONST;
		else if (type.text[type.text.length() - 1] == 'D' || numCheck(type.text[type.text.length() - 1]))
			return LexType::DEC_CONST;
		else if (!numCheck(type.text[type.text.length() - 1]))
		{
			SetConsoleTextAttribute(hConsole, 4);
			cout << "Wrong number: ";
			SetConsoleTextAttribute(hConsole, 7);
			cout << "(" << type.row << " row): " << type.text << endl;
			ERR_FLAG = true;

			return LexType::WRONG_LEX;
		}
	}
	else if (type.text.length() == 1)
	{
		if (singleCheck(type.text[0]))
			return LexType::SINGLE_SYMB;
		else
			return LexType::USER_IDENT;
	}
	else
	{
		if (type.text.length() > 8)
		{
			SetConsoleTextAttribute(hConsole, 4);
			cout << "Identeficator length more then 8 symbols:";
			SetConsoleTextAttribute(hConsole, 7);
			cout << "(" << type.row << " row): " << type.text << endl;
			ERR_FLAG = true;

			return LexType::WRONG_LEX;
		}
		
		for (auto n_iter : type.text)
			if (!alphabetCheck(n_iter))
				return LexType::WRONG_LEX;

		return LexType::USER_IDENT;
	}	
}