-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
77 lines (73 loc) · 2.47 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
77 lines (73 loc) · 2.47 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
diff --git a/CodeJam/Main.cpp b/examples/2020/KS_B/C/Main.cpp
index 2150379..9973c21 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2020/KS_B/C/Main.cpp
@@ -4,8 +4,8 @@
// #define IA_MODE //remove comment on this line, to activate interactive problem mode
#define IA_ERROR_CODE -1
#define IA_COMM_LOG //add comment on this line, to deactivate the interactive communication error log
-// #define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
-#define COMM_TYPE ll
+#define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
+#define COMM_TYPE cell
// The maintained and empty code template can be found at:
// https://github.com/demmerichs/CodeJamTemplate
@@ -67,10 +67,10 @@ typedef std::stringstream sstr;
#define INF std::numeric_limits<long long>::max()
#define EPS 1e-15L
#define PI 3.14159265358979323846264338328L
-#define MOD 1000000007LL
-#define MOD_IS_PRIME //add commment on this line, when MOD is changed to non-prime number
+#define MOD 1000000000LL
+// #define MOD_IS_PRIME //add commment on this line, when MOD is changed to non-prime number
#define DIR_NAMES "ENWS"
-v(cell) DIRECTIONS = {cell(1, 0), cell(0, 1), cell(-1, 0), cell(0, -1)};
+v(cell) DIRECTIONS = {cell(1, 0), cell(0, -1), cell(-1, 0), cell(0, 1)};
d(char, ll) DIR_IDX = {{'E', 0}, {'N', 1}, {'W', 2}, {'S', 3}};
#pragma endregion constants
#pragma region small conveniance functions
@@ -1570,11 +1570,47 @@ void init(){
cin >> T;
}
+str prog;
+
void readInput(){
+ cin >> prog;
+}
+
+cell recur(ll &prog_idx){
+ cell answer(0, 0);
+ while(prog_idx < prog.sz){
+ switch(prog[prog_idx]){
+ case ')':
+ return answer;
+ case 'E':
+ case 'W':
+ case 'N':
+ case 'S':
+ answer += DIRECTIONS[DIR_IDX[prog[prog_idx]]];
+ break;
+ default:
+ ll count = prog[prog_idx]-'0';
+ prog_idx+=2;
+ answer += recur(prog_idx) * count;
+ break;
+ }
+ prog_idx++;
+ lg(answer);
+ answer.real(mint(answer.x).value);
+ answer.imag(mint(answer.y).value);
+ lg(prog_idx);
+ lg(answer);
+ }
+ return answer;
}
// write to COMM_TYPE result
void calcFunction() {
+ result = cell(1,1);
+ ll prog_idx = 0;
+ result += recur(prog_idx);
+ lg(prog_idx);
+ lg(prog.sz);
}
} // namespace task