Submission #416347

# Submission time Handle Problem Language Result Execution time Memory
416347 2021-06-02T10:34:17 Z model_code Parking Problem (innopolis2021_final_A) C++17
100 / 100
35 ms 932 KB
#include <bits/stdc++.h>

/**
 * Author: Niyaz Nigmatullin
 */

using namespace std;

void solve() {
	string parking;
	cin >> parking;
	int m = (int) parking.size();
	string waiting;
	cin >> waiting;
	int n = (int) waiting.size();
	vector<int> even, odd;
	int need = 0;
	for (int i = 0; i < m; ) {
		if (parking[i] == 'X') {
			i++;
			continue;
		}
		int j = i;
		while (j < m && parking[j] == '.') {
			++j;
		}
		int len = j - i;
		if (len >= 2) {
			if (len == 2) len++;
			if (len & 1) {
				if (len > 5) {
					odd.push_back(len);
				}
				need += (len - 1) / 2;
			} else {
				even.push_back(len);
				need += len / 2;
			}
		}
		i = j;
	}
	int have = 0;
	if (have >= need) {
		cout << "N";
	} else {
		cout << "Y";
	}
	for (int i = 0; i < n; i++) {
		have++;
		if (waiting[i] == 'C') {
			if (!even.empty()) {
				int x = even.back() - 3;
				--need;
				even.pop_back();
				if (x > 5) {
					odd.push_back(x);
				}
			} else if (!odd.empty()) {
				int x = odd.back() - 3;
				odd.pop_back();
				even.push_back(x);
			}
		}
		if (have >= need) {
			cout << "N";
		} else {
			cout << "Y";
		}
	}
	cout << "\n";
}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 764 KB Output is correct
2 Correct 11 ms 564 KB Output is correct
3 Correct 25 ms 600 KB Output is correct
4 Correct 11 ms 824 KB Output is correct
5 Correct 11 ms 524 KB Output is correct
6 Correct 12 ms 932 KB Output is correct
7 Correct 12 ms 460 KB Output is correct
8 Correct 27 ms 648 KB Output is correct
9 Correct 12 ms 712 KB Output is correct
10 Correct 16 ms 488 KB Output is correct
11 Correct 30 ms 576 KB Output is correct
12 Correct 11 ms 792 KB Output is correct
13 Correct 13 ms 544 KB Output is correct
14 Correct 28 ms 612 KB Output is correct
15 Correct 22 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 828 KB Output is correct
2 Correct 11 ms 460 KB Output is correct
3 Correct 26 ms 680 KB Output is correct
4 Correct 12 ms 760 KB Output is correct
5 Correct 12 ms 488 KB Output is correct
6 Correct 8 ms 716 KB Output is correct
7 Correct 13 ms 544 KB Output is correct
8 Correct 33 ms 756 KB Output is correct
9 Correct 12 ms 796 KB Output is correct
10 Correct 14 ms 516 KB Output is correct
11 Correct 29 ms 644 KB Output is correct
12 Correct 11 ms 764 KB Output is correct
13 Correct 13 ms 524 KB Output is correct
14 Correct 28 ms 616 KB Output is correct
15 Correct 25 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 736 KB Output is correct
2 Correct 11 ms 588 KB Output is correct
3 Correct 15 ms 588 KB Output is correct
4 Correct 19 ms 548 KB Output is correct
5 Correct 15 ms 484 KB Output is correct
6 Correct 25 ms 548 KB Output is correct
7 Correct 22 ms 588 KB Output is correct
8 Correct 35 ms 732 KB Output is correct
9 Correct 28 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 764 KB Output is correct
2 Correct 11 ms 564 KB Output is correct
3 Correct 25 ms 600 KB Output is correct
4 Correct 11 ms 824 KB Output is correct
5 Correct 11 ms 524 KB Output is correct
6 Correct 12 ms 932 KB Output is correct
7 Correct 12 ms 460 KB Output is correct
8 Correct 27 ms 648 KB Output is correct
9 Correct 12 ms 712 KB Output is correct
10 Correct 16 ms 488 KB Output is correct
11 Correct 30 ms 576 KB Output is correct
12 Correct 11 ms 792 KB Output is correct
13 Correct 13 ms 544 KB Output is correct
14 Correct 28 ms 612 KB Output is correct
15 Correct 22 ms 460 KB Output is correct
16 Correct 10 ms 828 KB Output is correct
17 Correct 11 ms 460 KB Output is correct
18 Correct 26 ms 680 KB Output is correct
19 Correct 12 ms 760 KB Output is correct
20 Correct 12 ms 488 KB Output is correct
21 Correct 8 ms 716 KB Output is correct
22 Correct 13 ms 544 KB Output is correct
23 Correct 33 ms 756 KB Output is correct
24 Correct 12 ms 796 KB Output is correct
25 Correct 14 ms 516 KB Output is correct
26 Correct 29 ms 644 KB Output is correct
27 Correct 11 ms 764 KB Output is correct
28 Correct 13 ms 524 KB Output is correct
29 Correct 28 ms 616 KB Output is correct
30 Correct 25 ms 460 KB Output is correct
31 Correct 15 ms 736 KB Output is correct
32 Correct 11 ms 588 KB Output is correct
33 Correct 15 ms 588 KB Output is correct
34 Correct 19 ms 548 KB Output is correct
35 Correct 15 ms 484 KB Output is correct
36 Correct 25 ms 548 KB Output is correct
37 Correct 22 ms 588 KB Output is correct
38 Correct 35 ms 732 KB Output is correct
39 Correct 28 ms 556 KB Output is correct
40 Correct 1 ms 216 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 316 KB Output is correct
43 Correct 4 ms 364 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 4 ms 336 KB Output is correct
46 Correct 33 ms 480 KB Output is correct
47 Correct 16 ms 732 KB Output is correct
48 Correct 13 ms 852 KB Output is correct
49 Correct 10 ms 720 KB Output is correct