Submission
Status:
[PPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Frankenstein
Problemset: B.Shuffle
Language: cpp
Time: 0.063 second
Submitted On: 2026-04-12 16:03:12
#include <cstdio>
#include <unistd.h>
static char buf[1 << 22];
static int bufPos, bufLen;
static inline int gc() {
if (bufPos == bufLen) {
bufLen = (int)read(0, buf, sizeof(buf));
bufPos = 0;
if (bufLen <= 0) return -1;
}
return buf[bufPos++];
}
static inline int readInt() {
int c, x = 0;
do { c = gc(); } while (c <= ' ' && c != -1);
for (; c > ' '; c = gc()) x = x * 10 + c - '0';
return x;
}
static char obuf[1 << 20];
static int oLen;
static inline void flush() { write(1, obuf, oLen); oLen = 0; }
static inline void writeStr(const char* s, int n) {
for (int i = 0; i < n; i++) obuf[oLen++] = s[i];
}
int main() {
int T = readInt();
while (T--) {
int M = readInt();
// skip whitespace, then read M chars directly
int c;
do { c = gc(); } while (c <= ' ' && c != -1);
int xr = 0;
int parity = 0; // 0 = waiting for first block of pair, 1 = waiting for second
int gap = 0; // empties counted since first block of current pair
int processed = 1; // already consumed one char (`c`)
// process the first char we already read
if (c == '_') {
if (parity == 1) gap++;
} else {
if (parity == 0) { parity = 1; gap = 0; }
else { xr ^= (gap & 1); parity = 0; }
}
while (processed < M) {
c = gc();
if (c == '_') {
if (parity == 1) gap++;
} else if (c != -1 && c > ' ') {
if (parity == 0) { parity = 1; gap = 0; }
else { xr ^= (gap & 1); parity = 0; }
} else continue;
processed++;
}
if (xr) writeStr("YES\n", 4);
else writeStr("NO\n", 3);
}
flush();
return 0;
}