-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
94 lines (88 loc) · 2.22 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
94 lines (88 loc) · 2.22 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff --git a/CodeJam/Main.cpp b/examples/2022/KS_A/C/Main.cpp
index 2150379..7fdbbf6 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2022/KS_A/C/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
@@ -1566,15 +1566,80 @@ using namespace std;
namespace task {
+bool contains5palindrom(ll n){
+ if((((n>>0)&1) == ((n>>4)&1)) && (((n>>1)&1) == ((n>>3)&1))){
+ lg(n);
+ lg("contains 5");
+ return true;
+ }
+ return false;
+}
+
+bool contains5or6palindrom(ll n){
+ if(contains5palindrom(n%(1<<5)) || contains5palindrom(n>>1))
+ return true;
+ if(((n>>0)&1) == ((n>>5)&1) && ((n>>1)&1) == ((n>>4)&1) && ((n>>2)&1) == ((n>>3)&1))
+ return true;
+ return false;
+}
+
+v(bool) contains5or6;
+
void init(){
cin >> T;
+ forn(i, 64){
+ contains5or6.pb(contains5or6palindrom(i));
+ }
+ lg(contains5or6);
}
+ll N;
+str S;
+
void readInput(){
+ cin >> N >> S;
}
+
// write to COMM_TYPE result
void calcFunction() {
+ result = "POSSIBLE";
+ if(N<5) return;
+
+ s(ll) poss;
+ poss.insert(0);
+ lg(poss);
+
+ forn(i, N){
+ s(ll) newposs;
+ if(S[i]=='0' || S[i]=='?'){
+ foreach(p, poss){
+ ll n = (p*2)%(1<<6);
+ if(i<5 || !contains5or6[n])
+ newposs.insert(n);
+ }
+ }
+ if(S[i]=='1' || S[i]=='?'){
+ foreach(p, poss){
+ ll n = (p*2+1)%(1<<6);
+ if(i<5 || !contains5or6[n])
+ newposs.insert(n);
+ }
+ }
+ poss = newposs;
+ lg(poss);
+ if(poss.sz == 0){
+ result = "IMPOSSIBLE";
+ break;
+ }
+ }
+ if(N==5){
+ result = "IMPOSSIBLE";
+ foreach(p, poss){
+ if(!contains5palindrom(p))
+ result = "POSSIBLE";
+ }
+ }
}
} // namespace task