QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#332273 | #6305. Chinese Checker | MesSimonFallon | WA | 9ms | 3596kb | C++14 | 2.0kb | 2024-02-19 13:11:04 | 2024-02-19 13:11:04 |
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, 3, 2, 1, 0, 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);
i3 pre = 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] && g[ni][nj] != idx){
melo = 1; break;
}
}
if(melo){
// D("MELO"); D(iters);
melo = 1;
forn(_, iters){
ni += di, nj += dj;
if(!check(ni, nj)){
melo = 0; break;
}
}
// D(iters); D(check(ni, nj));D(g[ni][nj]);
if(melo && check(ni, nj) && g[ni][nj] == 0){
// D("SIZAS");
cur = {idx, ni, nj};
dfs(cur);
}
}
}
cur = pre;
}
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){
i3 cur{i+1, pos[i].fi, pos[i].se};
dfs(cur);
}
cout << sz(dp) - n << el;
dp.clear();
forn(i, 30) forn(j, 30) g[i][j] = 0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
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: 9ms
memory: 3596kb
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:
434 624 314 686 617 339 239 44 555 101 1 240 92 117 20 195 486 417 10 215 143 192 538 16 112 566 412 592 180 99 258 415 24 7 165 239 451 373 47 267 414 51 10 151 78 322 31 183 521 127 253 416 0 130 116 34 21 5 74 254 202 27 527 236 365 4 53 0 431 117 113 468 0 501 82 97 70 397 90 24 596 559 4 318 12...
result:
wrong answer 1st numbers differ - expected: '190', found: '434'