QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219561 | #7145. Chessboard game | ckiseki# | WA | 0ms | 3756kb | C++20 | 1.8kb | 2023-10-19 16:18:15 | 2023-10-19 16:18:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++f)
cerr << (f ? ", " : "") << *L++;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define orange(...) safe
#define debug(...) safe
#endif
// const int maxn = 20;
// int a[maxn][maxn];
const int maxn = 200025;
map<pair<int,int>, int> mp;
int r[maxn], c[maxn];
int DP(int a, int b) {
if (a == 0)
return !r[b];
if (b == 0)
return !c[a];
if (auto it = mp.find({a, b}); it != mp.end())
return it->second;
int ans = !(DP(a - 1, b) || DP(a, b - 1));
return mp[{a, b}] = ans;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
// mt19937 rng(92130);
int n, m, q;
cin >> n >> m >> q;
{
string s;
cin >> s;
for (int i = 1; i <= n; i++) {
r[i] = s[i - 1];
}
}
{
string s;
cin >> s;
for (int i = 1; i <= m; i++) {
c[i] = s[i - 1];
}
}
while (q--) {
int x, y;
cin >> x >> y;
int z = max(0, min(x, y) - 2);
int ans = DP(x - z, y - z);
cout << (!ans ? "Yes\n" : "No\n");
}
/*
for (int i = 0; i < maxn; i++) {
a[i][0] = rng() % 9 >= 0;
}
for (int i = 0; i < maxn; i++) {
a[0][i] = rng() % 9 >= 0;
}
for (int i = 1; i < maxn; i++) {
for (int j = 1; j < maxn; j++) {
a[i][j] = !(a[i-1][j] || a[i][j-1]);
}
}
for (int i = 0; i < maxn; i++) {
orange(a[i], a[i] + maxn);
}
*/
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
2 2 4 10 11 1 1 1 2 2 1 2 2
output:
No Yes Yes No
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3756kb
input:
5 4 10 00001 0100 3 1 1 3 2 2 1 1 3 1 2 2 3 4 3 2 5 1 3 4
output:
No No No No No No Yes Yes Yes Yes
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'