-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdcj_template.cpp
128 lines (103 loc) · 2.39 KB
/
dcj_template.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <bits/stdc++.h>
#include "message.h"
#include "baby_blocks.h" // problem library
#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
using namespace std;
namespace NMyPutAndGet {
// Put
void Put(int target, char value) {
PutChar(target, value);
}
void Put(int target, int value) {
PutInt(target, value);
}
void Put(int target, long long value) {
PutLL(target, value);
}
void Put(int target, const string& value) {
PutInt(target, value.size());
for (char x : value) {
Put(target, x);
}
}
template <typename T, typename U>
void Put(int target, const pair<T, U>& value);
template <typename T>
void Put(int target, const vector<T>& value);
template <typename T, typename U>
void Put(int target, const pair<T, U>& value) {
Put(target, value.first);
Put(target, value.second);
}
template <typename T>
void Put(int target, const vector<T>& value) {
PutInt(target, value.size());
for (const T& x : value) {
Put(target, x);
}
}
// Get
void Get(int source, char& value) {
value = GetChar(source);
}
void Get(int source, int& value) {
value = GetInt(source);
}
void Get(int source, long long& value) {
value = GetLL(source);
}
void Get(int source, string& value) {
value.resize(GetInt(source));
for (char& x : value) {
Get(source, x);
}
}
template <typename T, typename U>
void Get(int source, pair<T, U>& value);
template <typename T>
void Get(int source, vector<T>& value);
template <typename T, typename U>
void Get(int source, pair<T, U>& value) {
Get(source, value.first);
Get(source, value.second);
}
template <typename T>
void Get(int source, vector<T>& value) {
value.resize(GetInt(source));
for (T& x : value) {
Get(source, x);
}
}
template <typename T>
T Get(int source) {
T value;
Get(source, value);
return value;
}
} // namespace NMyPutAndGet
using namespace NMyPutAndGet;
inline int GetLeft(int id) {
return 1ll * GetNumberOfBlocks() * (id - 1) / (NumberOfNodes() - 1);
}
inline int GetRight(int id) {
return 1ll * GetNumberOfBlocks() * id / (NumberOfNodes() - 1);
}
void Rule() {
int n = NumberOfNodes();
// type your code here
}
void Obey(int id) {
int l = GetLeft(id);
int r = GetRight(id);
// type your code here
}
int main() {
if (MyNodeId() == 0) {
Rule();
} else {
Obey(MyNodeId());
}
return 0;
}