-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
62 lines (58 loc) · 2.01 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
62 lines (58 loc) · 2.01 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
diff --git a/CodeJam/Main.cpp b/examples/2019/Round1C/A/Main.cpp
index 2150379..4ba4e11 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2019/Round1C/A/Main.cpp
@@ -1,11 +1,11 @@
-// #define DEFAULT_VAL_MODE //remove comment on this line, to activate default value trigger
+#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_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,43 @@ void init(){
cin >> T;
}
+ll A;
+v(str) Pi;
+
+d(char, char) winmoves = {{'R', 'P'}, {'P', 'S'}, {'S', 'R'}};
+d(s(char), char) partial_win = {{{'R', 'S'}, 'R'}, {{'S', 'P'}, 'S'}, {{'P', 'R'}, 'P'}};
+
void readInput(){
+ cin >> A;
+ Pi.resize(A);
+ forn(i, A) cin >> Pi[i];
}
// write to COMM_TYPE result
void calcFunction() {
+ result = "";
+ v(bool) still_alive(A, true);
+ while(true){
+ s(char) opp_moves;
+ forn(i, A){
+ if(!still_alive[i]) continue;
+ opp_moves.insert(Pi[i][result.sz % Pi[i].sz]);
+ }
+ if(opp_moves.sz == 3){
+ result = "";
+ break;
+ }
+ if(opp_moves.sz == 1){
+ result += winmoves[*opp_moves.bn];
+ break;
+ }
+ lassert(opp_moves.sz == 2, "something wrong with opp moves");
+ result += partial_win[opp_moves];
+ forn(i, A){
+ if(Pi[i][(result.sz-1)%Pi[i].sz]!=result[result.sz-1]) still_alive[i]=false;
+ }
+ }
+ lassert(result.sz <= 500, "too long result");
}
} // namespace task