90592024-02-13 14:16:21Qkrisi2016. ápriliscpp17Time limit exceeded on test 22.098s1824 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}};
set<char> PossibleMoves = {'F', 'L', 'R'};

void run(string* moves, size_t N, set<pair<ll, ll>>* endings)
{
	int direction = 1;
	ll X = 0;
	ll Y = 0;
	for(size_t i = 0;i<N;i++)
	{
		switch(moves->at(i))
		{
			case 'F':
				X += pairs[direction].first;
				Y += pairs[direction].second;
				break;
			case 'R':
				if(++direction == 5)
					direction = 1;
				break;
			case 'L':
				if(--direction == 0)
					direction = 4;
				break;
		}
	}
	endings->insert({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;

	
	for(size_t i = 0;i<N;i++)
	{
		char original = moves[i];
		PossibleMoves.erase(original);
		for(char c : PossibleMoves)
		{
			moves[i] = c;
			run(&moves, N, &endings);
		}
		PossibleMoves.insert(original);
		moves[i] = original;
	}

	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 - Time limit exceeded
Memory: 1708KiB
Time: 2.098s

Program's output:
Expected output:
34389
Checker output:

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: