Submission #59838888
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;#define int long longsigned main() {int N, K;cin >> N >> K;string S;cin >> S;vector<pair<int, int>> blocks;int start = -1;for (int i = 0; i < N; ++i) {if (S[i] == '1') {if (start == -1) start = i;} else {if (start != -1) {
#include<bits/stdc++.h> using namespace std; #define int long long signed main() { int N, K; cin >> N >> K; string S; cin >> S; vector<pair<int, int>> blocks; int start = -1; for (int i = 0; i < N; ++i) { if (S[i] == '1') { if (start == -1) start = i; } else { if (start != -1) { blocks.emplace_back(start, i - 1); start = -1; } } } if (start != -1) { blocks.emplace_back(start, N - 1); } auto [kst, kend] = blocks[K - 2]; auto [k_start, k_end] = blocks[K - 1]; string ans(N, '0'); for (int i = 0; i <= kend; ++i) { ans[i] = S[i]; } for (int i = kend + 1; i <= kend + (k_end - k_start + 1); ++i) { ans[i] = '1'; } for (int i = k_end + 1; i < N; ++i) { ans[i] = S[i]; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Move Segment |
User | benzyl |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 956 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 8224 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
min.txt | AC | 1 ms | 3468 KB |
random_01.txt | AC | 10 ms | 8224 KB |
random_02.txt | AC | 10 ms | 8216 KB |
random_03.txt | AC | 8 ms | 4192 KB |
random_04.txt | AC | 7 ms | 4216 KB |
random_05.txt | AC | 8 ms | 4176 KB |
random_06.txt | AC | 8 ms | 4436 KB |
random_07.txt | AC | 2 ms | 3624 KB |
random_08.txt | AC | 7 ms | 4196 KB |
random_09.txt | AC | 3 ms | 3676 KB |
random_10.txt | AC | 8 ms | 4572 KB |
random_11.txt | AC | 7 ms | 4236 KB |
random_12.txt | AC | 8 ms | 4140 KB |
random_13.txt | AC | 1 ms | 3580 KB |
random_14.txt | AC | 8 ms | 4380 KB |
random_15.txt | AC | 2 ms | 3540 KB |
random_16.txt | AC | 8 ms | 4148 KB |
random_17.txt | AC | 8 ms | 4200 KB |
random_18.txt | AC | 9 ms | 4440 KB |
random_19.txt | AC | 7 ms | 4336 KB |
random_20.txt | AC | 7 ms | 4112 KB |
random_21.txt | AC | 3 ms | 3664 KB |
random_22.txt | AC | 8 ms | 4432 KB |
random_23.txt | AC | 3 ms | 3652 KB |
random_24.txt | AC | 8 ms | 4176 KB |
random_25.txt | AC | 6 ms | 3976 KB |
sample_01.txt | AC | 1 ms | 3532 KB |
sample_02.txt | AC | 1 ms | 3464 KB |