QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141513 | #6534. Peg Solitaire | cy1999 | WA | 0ms | 3644kb | C++ | 1.3kb | 2023-08-17 15:41:09 | 2023-08-17 15:41:12 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int t, n, m, k, ans = 7777;
int a[6][6];
void dfs() {
//中嘞,哥
int tmp = 0;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
//对于这个点(i, j),能不能跳ww
if(i<=n-2&&a[i][j]&&a[i+1][j]&&!a[i+2][j]) {
a[i][j] = a[i+1][j] = 0;
a[i+2][j] = 1;
dfs();
a[i][j] = a[i+1][j] = 1;
a[i+2][j] = 0;
}
if(i>=3&&a[i][j]&&a[i-1][j]&&!a[i-2][j]) {
a[i][j] = a[i-1][j] = 0;
a[i-2][j] = 1;
dfs();
a[i][j] = a[i-1][j] = 1;
a[i-2][j] = 0;
}
if(j>=3&&a[i][j]&&a[i][j-1]&&!a[i][j-2]) {
a[i][j] = a[i][j-1] = 0;
a[i][j-2] = 1;
dfs();
a[i][j] = a[i][j-1] = 1;
a[i][j-2] = 0;
}
if(j<=m-2&&a[i][j]&&a[i][j+1]&&!a[i][j+2]) {
a[i][j] = a[i][j+1] = 0;
a[i][j+2] = 1;
dfs();
a[i][j] = a[i][j+1] = 1;
a[i][j+2] = 0;
}
if(a[i][j]) tmp++;
}
}
ans = min(ans, tmp);
}
int main() {
//(顿住)
scanf("%d", &t);
while(t--) {
ans = 7777;
memset(a, 0, sizeof(a));
scanf("%d%d%d", &n, &m, &k);
for(int i=1; i<=k; i++) {
int x, y; scanf("%d%d", &x, &y);
x--, y--;
a[x][y] = 1;
}
dfs();
cout<<ans<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3644kb
input:
3 3 4 5 2 2 1 2 1 4 3 4 1 1 1 3 3 1 1 1 2 1 3 2 1 1 2 1
output:
2 0 0
result:
wrong answer 2nd numbers differ - expected: '3', found: '0'