-
Notifications
You must be signed in to change notification settings - Fork 2
/
maptiles2.cpp
55 lines (49 loc) · 951 Bytes
/
maptiles2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <ctype.h>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
int main()
{
ll i, j, k;
string key;
ll lowX, highX, lowY, highY;
lowX = 0;
lowY = 0;
cin >> key;
highY = pow(2, key.size()) - 1;
highX = pow(2, key.size()) - 1;
for (auto subKey : key)
{
if (subKey == '0')
{
highY -= ((highY - lowY + 1) / 2);
highX -= ((highX - lowX + 1) / 2);
}
else if (subKey == '1')
{
highY -= ((highY - lowY + 1) / 2);
lowX += ((highX - lowX + 1) / 2);
}
else if (subKey == '2')
{
lowY += ((highY - lowY + 1) / 2);
highX -= ((highX - lowX + 1) / 2);
}
else
{
lowY += ((highY - lowY + 1) / 2);
lowX += ((highX - lowX + 1) / 2);
}
}
cout << key.size() << " " << lowX << " " << lowY << "\n";
return 0;
}