Submission #416347

#TimeUsernameProblemLanguageResultExecution timeMemory
416347model_codeParking Problem (innopolis2021_final_A)C++17
100 / 100
35 ms932 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...