90652024-02-13 15:12:22Qkrisi2016. ápriliscpp17Wrong answer on test 229ms6452 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const pair<int, int> pairs[4] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

pair<ll, ll> run(string* moves, size_t i, size_t N, ll X, ll Y)
{
	int direction = 0;
	while(++i < N)
	{
		switch(moves->at(i))
		{
			case 'F':
				X += pairs[direction].first;
				Y += pairs[direction].second;
				break;
			case 'R':
				if(++direction == 4)
					direction = 0;
				break;
			case 'L':
				if(--direction == -1)
					direction = 3;
				break;
		}
	}
	return {X, Y};
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string moves;
	getline(cin, moves);
	size_t N = moves.size();

	set<pair<ll, ll>> endings;
	int direction = 0;
	ll X = 0;
	ll Y = 0;

	pair<ll, ll> original_end = run(&moves, -1, N, 0, 0);
	//cout << "Original: " << original_end.first << " " << original_end.second << endl;

	
	ll X2, Y2;
	for(size_t i = 0;i<N;i++)
	{

		char original = moves[i];
		switch(original)
		{
			case 'F':
				X += pairs[direction].first;
				Y += pairs[direction].second;
				break;
			case 'R':
				if(++direction == 4)
					direction = 0;
				break;
			case 'L':
				if(--direction == -1)
					direction = 3;
				break;
		}
		ll dx = original_end.first - X;
		ll dy = original_end.second - Y;
		pair<char, char> PossibleMoves;
		switch(original)
		{
			case 'F':
				X2 = X - pairs[direction].first;
				Y2 = Y - pairs[direction].second;
				endings.insert({dy + X2, -dx + Y2});	//R
				//cout << "F -> R: " << dy + X2 << " " << -dx + Y2 << endl;
				endings.insert({-dy + X2, dx + Y2});	//L
				//cout << "F -> L: " << -dy + X2 << " " << dx + Y2 << endl;
				break;
			case 'L':
				X2 = X + pairs[direction].first;
				Y2 = Y + pairs[direction].second;
				endings.insert({-dx + X, -dy + Y});	//R
				//cout << "L -> R: " << -dx + X << " " << -dy + Y << endl;
				endings.insert({dy + X2, -dx + Y2});	//F
				//cout << "L -> F: " << dy + X2 << " " << -dx + Y2 << endl;
				//PossibleMoves = {'F', 'R'};
				break;
			case 'R':
				X2 = X + pairs[direction].first;
				Y2 = Y + pairs[direction].second;
				endings.insert({-dx + X, -dy + Y});	//L
				//cout << "R -> L: " << -dx + X << " " << -dy + Y << endl;
				endings.insert({-dy + X2, dx + Y2});	//F
				//cout << "R -> F: " << -dy + X2 << " " << dx + Y2 << endl;
				//PossibleMoves = {'L', 'F'};
				break;
		}
		/*moves[i] = PossibleMoves.first;
		run(&moves, i-1, N, X, Y, &endings);
		moves[i] = PossibleMoves.second;
		run(&moves, i-1, N, X, Y, &endings);
		moves[i] = original;*/

	}

	/*for(auto p : endings)
	{
		cout << p.first << " " << p.second << endl;
	}*/
	cout << endings.size();

	return 0;
}
1 - Accepted
Memory: 1824KiB
Time: 3ms

Program's output:
3
Expected output:
3
Checker output:
ok 1 number(s): "3"

2 - Wrong answer
Memory: 6452KiB
Time: 29ms

Program's output:
33643
Expected output:
34389
Checker output:
wrong answer 1st numbers differ - expected: '34389', found: '33643'

3 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

4 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

5 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

6 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

7 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

8 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

9 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

10 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

11 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

12 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

13 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

14 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

15 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

16 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

17 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

18 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

19 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

20 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

21 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

22 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

23 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

24 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

25 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output:

26 - Didn't run
Memory: 0KiB
Time: 0s

Program's output:
Expected output:
Checker output: