-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
67 lines (63 loc) · 1.73 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
67 lines (63 loc) · 1.73 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
diff --git a/CodeJam/Main.cpp b/examples/2020/Round1A/B/Main.cpp
index 2150379..4d2a01c 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2020/Round1A/B/Main.cpp
@@ -5,7 +5,7 @@
#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 COMM_TYPE str
// The maintained and empty code template can be found at:
// https://github.com/demmerichs/CodeJamTemplate
@@ -1570,11 +1570,53 @@ void init(){
cin >> T;
}
+ll N;
+
void readInput(){
+ cin >> N;
}
// write to COMM_TYPE result
void calcFunction() {
+ ll r = log2i(N)+1;
+ ll k = N-r;
+ lassert(k>=0, "ohnooo");
+ ll counter = 0;
+
+ result.cl;
+ result += "\n";
+ sstr res;
+ bool left = true;
+ ll level = 0;
+ while(counter < N){
+ if((k>>level)&1){
+ counter += (1<<level);
+ level++;
+ if(left){
+ fore(i, 1,level){
+ res << level << " " << i << endl;
+ }
+ left = false;
+ } else {
+ forn(i, level){
+ res << level << " " << level - i << endl;
+ }
+ left = true;
+ }
+ } else {
+ counter++;
+ level++;
+ if(left){
+ res << level << " " << 1;
+ } else {
+ res << level << " " << level;
+ }
+ if(counter < N) res << endl;
+ }
+ }
+ result += res.str();
+ llog("result", result);
+ lassert(counter==N, "something went wrong");
}
} // namespace task