#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.emplace_back(l);
cur += (l - 1) / 2;
} else {
e.emplace_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.emplace_back(x);
} else if(!o.empty()){
int x = o.back() - 1;
o.pop_back(); e.emplace_back(x);
}
} if(cnt >= cur) cout << "N";
else cout << "Y";
} cout << "\n";
}
int main(){
int test; cin >> test;
while(test--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
856 KB |
Output is correct |
2 |
Correct |
6 ms |
604 KB |
Output is correct |
3 |
Correct |
15 ms |
604 KB |
Output is correct |
4 |
Correct |
6 ms |
928 KB |
Output is correct |
5 |
Correct |
6 ms |
588 KB |
Output is correct |
6 |
Correct |
7 ms |
876 KB |
Output is correct |
7 |
Correct |
7 ms |
492 KB |
Output is correct |
8 |
Correct |
16 ms |
604 KB |
Output is correct |
9 |
Correct |
6 ms |
860 KB |
Output is correct |
10 |
Correct |
8 ms |
604 KB |
Output is correct |
11 |
Correct |
18 ms |
600 KB |
Output is correct |
12 |
Correct |
6 ms |
808 KB |
Output is correct |
13 |
Correct |
7 ms |
604 KB |
Output is correct |
14 |
Correct |
18 ms |
604 KB |
Output is correct |
15 |
Correct |
14 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
860 KB |
Output is correct |
2 |
Correct |
7 ms |
628 KB |
Output is correct |
3 |
Correct |
16 ms |
604 KB |
Output is correct |
4 |
Correct |
6 ms |
816 KB |
Output is correct |
5 |
Correct |
7 ms |
604 KB |
Output is correct |
6 |
Correct |
5 ms |
860 KB |
Output is correct |
7 |
Correct |
7 ms |
604 KB |
Output is correct |
8 |
Incorrect |
17 ms |
744 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
864 KB |
Output is correct |
2 |
Correct |
7 ms |
604 KB |
Output is correct |
3 |
Correct |
7 ms |
604 KB |
Output is correct |
4 |
Correct |
9 ms |
604 KB |
Output is correct |
5 |
Correct |
11 ms |
600 KB |
Output is correct |
6 |
Correct |
12 ms |
604 KB |
Output is correct |
7 |
Correct |
14 ms |
604 KB |
Output is correct |
8 |
Correct |
17 ms |
604 KB |
Output is correct |
9 |
Correct |
13 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
856 KB |
Output is correct |
2 |
Correct |
6 ms |
604 KB |
Output is correct |
3 |
Correct |
15 ms |
604 KB |
Output is correct |
4 |
Correct |
6 ms |
928 KB |
Output is correct |
5 |
Correct |
6 ms |
588 KB |
Output is correct |
6 |
Correct |
7 ms |
876 KB |
Output is correct |
7 |
Correct |
7 ms |
492 KB |
Output is correct |
8 |
Correct |
16 ms |
604 KB |
Output is correct |
9 |
Correct |
6 ms |
860 KB |
Output is correct |
10 |
Correct |
8 ms |
604 KB |
Output is correct |
11 |
Correct |
18 ms |
600 KB |
Output is correct |
12 |
Correct |
6 ms |
808 KB |
Output is correct |
13 |
Correct |
7 ms |
604 KB |
Output is correct |
14 |
Correct |
18 ms |
604 KB |
Output is correct |
15 |
Correct |
14 ms |
604 KB |
Output is correct |
16 |
Correct |
6 ms |
860 KB |
Output is correct |
17 |
Correct |
7 ms |
628 KB |
Output is correct |
18 |
Correct |
16 ms |
604 KB |
Output is correct |
19 |
Correct |
6 ms |
816 KB |
Output is correct |
20 |
Correct |
7 ms |
604 KB |
Output is correct |
21 |
Correct |
5 ms |
860 KB |
Output is correct |
22 |
Correct |
7 ms |
604 KB |
Output is correct |
23 |
Incorrect |
17 ms |
744 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |