-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
45 lines (42 loc) · 1.14 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
45 lines (42 loc) · 1.14 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
diff --git a/CodeJam/Main.cpp b/examples/2022/KS_A/A/Main.cpp
index 2150379..8c1f640 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2022/KS_A/A/Main.cpp
@@ -1,5 +1,5 @@
-// #define DEFAULT_VAL_MODE //remove comment on this line, to activate default value trigger
-#define DEFAULT_VAL_TRIGGER result.sz == 0
+#define DEFAULT_VAL_MODE //remove comment on this line, to activate default value trigger
+#define DEFAULT_VAL_TRIGGER result == -1
#define DEFAULT_VAL "IMPOSSIBLE"
// #define IA_MODE //remove comment on this line, to activate interactive problem mode
#define IA_ERROR_CODE -1
@@ -1570,11 +1570,32 @@ void init(){
cin >> T;
}
+str I, P;
+
void readInput(){
+ cin >> I >> P;
}
// write to COMM_TYPE result
void calcFunction() {
+ result = 0;
+
+ ll iptr=0, pptr=0;
+ while(iptr < I.sz){
+ if(I[iptr]==P[pptr]){
+ iptr++;
+ pptr++;
+ } else {
+ pptr++;
+ result++;
+ if(pptr>=P.sz){
+ result = -1;
+ break;
+ }
+ }
+ }
+ if(result >= 0)
+ result += P.sz - pptr;
}
} // namespace task