-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
66 lines (62 loc) · 1.85 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
66 lines (62 loc) · 1.85 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
diff --git a/CodeJam/Main.cpp b/examples/2022/Qualification/E/Main.cpp
index 2150379..11b6dbd 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2022/Qualification/E/Main.cpp
@@ -1,9 +1,9 @@
// #define DEFAULT_VAL_MODE //remove comment on this line, to activate default value trigger
#define DEFAULT_VAL_TRIGGER result.sz == 0
#define DEFAULT_VAL "IMPOSSIBLE"
-// #define IA_MODE //remove comment on this line, to activate interactive problem mode
+#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 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
@@ -1570,11 +1570,49 @@ void init(){
cin >> T;
}
+ll N, K;
+v(ll) Pi;
+
void readInput(){
+ N = in();
+ K = in();
+ Pi.cl;
+ Pi.resize(N, -1);
}
// write to COMM_TYPE result
void calcFunction() {
+ ll r = in();
+ ll p = in();
+
+ random_device rd;
+ mt19937 rng(rd());
+ uniform_int_distribution<int> uni(0, N-1);
+ ll avg_estimate = 0;
+ forn(i, K/2){
+ ll cur_room = uni(rng);
+ out("T " + to_string(cur_room+1));
+ r = in();
+ p = in();
+ Pi[r-1] = p;
+ avg_estimate += p;
+
+ out("W");
+ r = in();
+ p = in();
+ Pi[r-1] = p;
+ }
+
+ ll counts_observed = 0;
+ ll sum_observed = 0;
+ forn(i, Pi.sz){
+ if(Pi[i]>0){
+ counts_observed++;
+ sum_observed += Pi[i];
+ }
+ }
+ ll estimate = (sum_observed + avg_estimate * 2 * (N-counts_observed) / K)/2;
+ out("E " + to_string(estimate));
}
} // namespace task