QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#332668 | #6305. Chinese Checker | MesSimonFallon | WA | 7ms | 3660kb | C++14 | 2.0kb | 2024-02-19 15:41:29 | 2024-02-19 15:41:29 |
Judging History
answer
#include <bits/stdc++.h>
#define forn(i,n) for(int i=0; i < n; ++i)
#define for1(i,n) for(int i=1; i <= n; ++i)
#define fore(i,l,r) for(int i=l; i <= r; ++i)
#define pb push_back
#define el '\n'
#define fi first
#define se second
#define sz(v) int(v.size())
#define D(v) cout << #v << " : " << v << el;
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
vi st{ 4, 4, 4, 4, 0, 1, 2, 3, 4, 4, 4, 4, 4, 5, 6, 7, 8 };
vi an{ 1, 2, 3, 4, 13, 12, 11, 10, 9, 10, 11, 12, 13, 4, 3, 2, 1 };
vii pos;
typedef array<int, 3> i3;
set<i3> dp;
int g[30][30];
bool check(int i, int j){
if(i < 0 || i >= sz(st)) return 0;
return st[i] <= j && j < st[i] + an[i];
}
vector<ii> dir{
{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {-1, -1}
};
void dfs(i3 cur){
if(dp.count(cur)) return;
dp.insert(cur);
auto [idx, i, j] = cur;
// D(idx); D(i); D(j); cout << el;
for(auto&[di, dj]: dir){
int ni = i, nj = j, iters = 0;
bool melo = 0;
while(++iters){
ni += di, nj += dj;
if(!check(ni, nj)) break;
if(g[ni][nj]){
melo = 1; break;
}
}
if(melo){
forn(it, iters){
ni += di, nj += dj;
if(!check(ni, nj) || (g[ni][nj] && it < iters-1)){
melo = 0; break;
}
}
// D(iters); D(check(ni, nj));D(g[ni][nj]);
if(melo && !g[ni][nj]){
dfs({idx, ni, nj});
}
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
while(t--){
int n; cin >> n;
pos.resize(n);
forn(i, n){
int r, c; cin >> r >> c;
--r, --c;
pos[i] = {r, st[r] + c};
g[r][st[r]+c] = i+1;
}
forn(i, n){
g[pos[i].fi][pos[i].se] = 0;
i3 cur{i+1, pos[i].fi, pos[i].se};
dfs(cur);
g[pos[i].fi][pos[i].se] = i+1;
}
cout << sz(dp) - n << el;
dp.clear();
forn(i, 30) forn(j, 30) g[i][j] = 0;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
5 1 1 1 2 1 1 2 1 2 9 4 9 6 10 1 1 2 1 2 2 3 1 3 2 3 3 4 1 4 2 4 3 4 4 10 1 1 2 1 2 2 5 7 3 2 3 3 4 1 4 2 4 3 4 4
output:
0 1 2 6 13
result:
ok 5 number(s): "0 1 2 6 13"
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3660kb
input:
100 81 1 1 16 1 11 4 13 8 12 3 12 12 11 1 4 2 9 5 8 10 5 5 9 7 3 2 14 1 7 11 13 7 10 2 8 3 9 8 10 6 12 10 6 7 11 2 7 3 13 12 8 6 17 1 10 5 5 12 13 9 13 1 9 4 5 10 11 8 13 4 5 4 9 1 7 8 5 6 13 13 5 1 9 3 8 8 8 5 13 2 13 5 11 3 9 2 6 4 3 3 8 2 13 11 8 7 5 7 6 10 11 9 10 3 11 10 6 3 7 1 4 4 15 2 7 2 3 ...
output:
186 371 204 476 375 227 142 38 320 87 1 122 111 54 26 134 394 293 10 204 90 181 245 16 102 215 284 419 184 88 210 271 26 6 103 183 385 289 48 162 251 48 10 120 78 174 31 142 342 137 196 313 0 109 70 63 21 5 66 150 192 26 384 165 215 4 50 0 257 119 100 413 0 330 76 106 54 315 62 28 406 372 6 179 91 2...
result:
wrong answer 1st numbers differ - expected: '190', found: '186'