QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#777758 | #5544. Grid Game | SdND2DNzA9 | WA | 1ms | 3828kb | C++14 | 1.2kb | 2024-11-24 08:26:05 | 2024-11-24 08:26:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m; cin >> n >> m;
vector <vector<int>> a(n, vector<int>(m, 0));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> a[i][j];
int sum = 0;
auto in = [&](int i, int j) -> bool {
if (i < 0 || j < 0 || i >= n || j >= m) return false;
if (a[i][j] == -1) return false;
return true;
};
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
bool corner = 1;
if (a[i][j] == -1) continue;
if (a[i][j] == 0) continue;
if (in(i + 1, j)) corner = 0;
if (in(i, j + 1)) corner = 0;
/// corner --> NIM
if (corner) sum ^= a[i][j];
/// not corner --> MISERE NIM
if (!corner) {
if (a[i][j] == 1) sum ^= 0;
else sum ^= a[i][j];
}
}
if (sum == 0) cout << "second\n";
else cout << "first\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;// cin >> t;
while (t--) {
solve();
}
}
/**
5 6
0 0 0 0 0 0
0 3 3 0 0 0
0 0 3 -1 0 0
0 0 3 3 3 3
0 0 -1 -1 -1 -1
**/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
5 6 0 0 0 0 0 0 0 3 3 0 0 0 0 0 3 -1 0 0 0 0 3 3 3 3 0 0 -1 -1 -1 -1
output:
first
result:
ok single line: 'first'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
2 2 1 1 2 -1
output:
first
result:
ok single line: 'first'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
1 1 -1
output:
second
result:
ok single line: 'second'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
1 1 0
output:
second
result:
ok single line: 'second'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3624kb
input:
1 500 612866757 -1 170099640 81369597 686362045 -1 881896501 976801805 719620154 608593304 966389969 328378946 507635545 802692138 300403679 836364030 549500574 415279944 930818720 415608262 520761434 936617110 -1 -1 267207033 722184019 877398796 32901337 371918751 425945951 1383354 93894469 2476850...
output:
first
result:
wrong answer 1st lines differ - expected: 'second', found: 'first'