제출 #890511

#제출 시각아이디문제언어결과실행 시간메모리
890511IwantbemasterParking Problem (innopolis2021_final_A)C++17
54 / 100
18 ms1112 KiB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ff first
#define ss second
const int ForSpeed = [](){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	return 0;
}();
void solve(){
	string str; cin >> str;
	int m = (int)str.size();
	string strw; cin >> strw;
	int n = (int)strw.size();
	vector<int> e, o;
	int cur = 0;
	for(int i = 0; i < m;){
		if(str[i] == 'X'){
			i++; continue;
		} int j = i;
		while(j < m && str[j] == '.') j++;
		int l = j - i;
		if(l >= 2){
			if(l == 2) l++;
			if(l & 1){
				if(l > 5){ o.push_back(l); }
				cur += (l - 1) / 2;
			} else {
				e.push_back(l); cur += l / 2;
			}
		} i = j;
	} int cnt = 0;
	if(cnt >= cur) cout << "N";
	else cout << "Y";
	for(int i = 0; i < n; i++){ cnt++;
		if(strw[i] == 'C'){
			if(!e.empty()){
				int x = e.back() - 1;
				cur--; e.pop_back();
				if(x > 5){ o.push_back(x); }
			} else if(!o.empty()){
				int x = o.back() - 1;
				o.pop_back(); e.push_back(x);
			}
		} if(cnt >= cur) cout << "N";
		else cout << "Y";
	} cout << "\n";
}
int main(){
	int test; cin >> test;
	while(test--){
		solve();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...