Submission #416348

# Submission time Handle Problem Language Result Execution time Memory
416348 2021-06-02T10:34:30 Z model_code Parking Problem (innopolis2021_final_A) C++17
54 / 100
30 ms 860 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() - 1;
				--need;
				even.pop_back();
				if (x > 5) {
					odd.push_back(x);
				}
			} else if (!odd.empty()) {
				int x = odd.back() - 1;
				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 720 KB Output is correct
2 Correct 11 ms 484 KB Output is correct
3 Correct 26 ms 596 KB Output is correct
4 Correct 13 ms 856 KB Output is correct
5 Correct 11 ms 464 KB Output is correct
6 Correct 12 ms 860 KB Output is correct
7 Correct 13 ms 460 KB Output is correct
8 Correct 27 ms 660 KB Output is correct
9 Correct 10 ms 716 KB Output is correct
10 Correct 13 ms 460 KB Output is correct
11 Correct 30 ms 652 KB Output is correct
12 Correct 11 ms 796 KB Output is correct
13 Correct 13 ms 584 KB Output is correct
14 Correct 30 ms 672 KB Output is correct
15 Correct 23 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 780 KB Output is correct
2 Correct 11 ms 464 KB Output is correct
3 Correct 26 ms 660 KB Output is correct
4 Correct 11 ms 764 KB Output is correct
5 Correct 11 ms 508 KB Output is correct
6 Correct 8 ms 720 KB Output is correct
7 Correct 14 ms 508 KB Output is correct
8 Incorrect 28 ms 684 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 736 KB Output is correct
2 Correct 11 ms 620 KB Output is correct
3 Correct 13 ms 660 KB Output is correct
4 Correct 13 ms 464 KB Output is correct
5 Correct 16 ms 568 KB Output is correct
6 Correct 20 ms 568 KB Output is correct
7 Correct 24 ms 548 KB Output is correct
8 Correct 27 ms 612 KB Output is correct
9 Correct 21 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 720 KB Output is correct
2 Correct 11 ms 484 KB Output is correct
3 Correct 26 ms 596 KB Output is correct
4 Correct 13 ms 856 KB Output is correct
5 Correct 11 ms 464 KB Output is correct
6 Correct 12 ms 860 KB Output is correct
7 Correct 13 ms 460 KB Output is correct
8 Correct 27 ms 660 KB Output is correct
9 Correct 10 ms 716 KB Output is correct
10 Correct 13 ms 460 KB Output is correct
11 Correct 30 ms 652 KB Output is correct
12 Correct 11 ms 796 KB Output is correct
13 Correct 13 ms 584 KB Output is correct
14 Correct 30 ms 672 KB Output is correct
15 Correct 23 ms 568 KB Output is correct
16 Correct 10 ms 780 KB Output is correct
17 Correct 11 ms 464 KB Output is correct
18 Correct 26 ms 660 KB Output is correct
19 Correct 11 ms 764 KB Output is correct
20 Correct 11 ms 508 KB Output is correct
21 Correct 8 ms 720 KB Output is correct
22 Correct 14 ms 508 KB Output is correct
23 Incorrect 28 ms 684 KB Output isn't correct
24 Halted 0 ms 0 KB -