Submission #18095809
Source Code Expand
n = int(input()) s = list(map(int, input())) t = list(map(int, input())) if sum(s) % 2 != sum(t) % 2: print(-1) exit() ans = 0 j = 0 for i in range(n): if t[i] == 1: while j < n: while j < n and not s[j]: j += 1 if j >= n: print(-1) exit() if j >= i: break k = j + 1 while k < n and not s[k]: k += 1 if k >= n: print(-1) exit() ans += k - j j = k + 1 if j >= n: print(-1) exit() if j >= i: ans += j - i j += 1 while j < n: while j < n and not s[j]: j += 1 if j >= n: break k = j + 1 while k < n and not s[k]: k += 1 if k >= n: print(-1) exit() ans += k - j j = k + 1 print(ans)
Submission Info
Submission Time | |
---|---|
Task | B - Flip Digits |
User | chielo |
Language | PyPy3 (7.3.0) |
Score | 600 |
Code Size | 978 Byte |
Status | AC |
Exec Time | 159 ms |
Memory | 106388 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 66 ms | 61708 KiB |
00-sample-002.txt | AC | 53 ms | 61628 KiB |
00-sample-003.txt | AC | 50 ms | 61612 KiB |
01-001.txt | AC | 50 ms | 61496 KiB |
01-002.txt | AC | 71 ms | 69528 KiB |
01-003.txt | AC | 60 ms | 67908 KiB |
01-004.txt | AC | 94 ms | 79656 KiB |
01-005.txt | AC | 104 ms | 85628 KiB |
01-006.txt | AC | 76 ms | 75864 KiB |
01-007.txt | AC | 141 ms | 99380 KiB |
01-008.txt | AC | 116 ms | 85372 KiB |
01-009.txt | AC | 116 ms | 86908 KiB |
01-010.txt | AC | 109 ms | 83432 KiB |
01-011.txt | AC | 131 ms | 94680 KiB |
01-012.txt | AC | 67 ms | 70776 KiB |
01-013.txt | AC | 130 ms | 105980 KiB |
01-014.txt | AC | 141 ms | 106200 KiB |
01-015.txt | AC | 125 ms | 105724 KiB |
01-016.txt | AC | 125 ms | 105636 KiB |
01-017.txt | AC | 129 ms | 106024 KiB |
01-018.txt | AC | 126 ms | 106048 KiB |
01-019.txt | AC | 147 ms | 106152 KiB |
01-020.txt | AC | 159 ms | 106116 KiB |
01-021.txt | AC | 145 ms | 106360 KiB |
01-022.txt | AC | 151 ms | 106384 KiB |
01-023.txt | AC | 151 ms | 106252 KiB |
01-024.txt | AC | 137 ms | 106212 KiB |
01-025.txt | AC | 140 ms | 106236 KiB |
01-026.txt | AC | 142 ms | 106200 KiB |
01-027.txt | AC | 146 ms | 105916 KiB |
01-028.txt | AC | 142 ms | 106388 KiB |
01-029.txt | AC | 142 ms | 106100 KiB |
01-030.txt | AC | 133 ms | 106156 KiB |
01-031.txt | AC | 142 ms | 105948 KiB |