69702023-12-22 17:46:22MagyarKendeSZLGTáblajátékcpp17Partially correct 38/503ms3832 KiB
#include <iostream>
#include <string>

using namespace std;

#define speed cin.tie(0); ios::sync_with_stdio(0)

string to_bin(int n) {
	if (n) {
		int pos = 31;
		while (!((n >> pos) & 1)) {
			pos--;
		}
		string s;
		while (pos >= 0) {
			s += to_string((n >> pos--) & 1);
		}
		return s;
	}
	return "0";
}

int main()
{
	speed;
	
	unsigned K, x = 0, y = 0;
	cin >> K;

	while (K--) {
		char move;
		cin >> move;
		if (move == '0') {
			x++;
			y = (y + 1) * 2 - 2;
		}
		else if (move == '1') {
			x++;
			y = (y + 1) * 2 - 1;
		}
		else if (move == '2') {
			x--;
			y = (y + 1) / 2 + ((y + 1) & 1) - 1;
		}
		else if (move == '3') y--;
		else if (move == '4') y++;
	}

	cout << x << '\n' << to_bin(y);
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms1704 KiB
2Accepted0/03ms1924 KiB
3Accepted3/33ms2136 KiB
4Accepted3/33ms2344 KiB
5Accepted3/33ms2500 KiB
6Partially correct1/33ms2580 KiB
7Accepted3/33ms2712 KiB
8Accepted3/33ms2928 KiB
9Accepted3/33ms3024 KiB
10Partially correct1/33ms3132 KiB
11Accepted3/33ms3344 KiB
12Partially correct1/33ms3672 KiB
13Accepted4/43ms3824 KiB
14Partially correct1/43ms3684 KiB
15Accepted4/43ms3680 KiB
16Partially correct1/43ms3832 KiB
17Accepted4/43ms3832 KiB