QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106185 | #6305. Chinese Checker | zzpcd | Compile Error | / | / | C++17 | 5.8kb | 2023-05-16 20:14:38 | 2023-05-16 20:14:41 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-05-16 20:14:41]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-16 20:14:38]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define MN 125
typedef pair<int, int> P;
const int L[18] = {0, 13, 12, 11, 10, 1, 2, 3, 4, 5, 4, 3, 2, 1, 10, 11, 12, 13};
const int R[18] = {0, 13, 14, 15, 16, 25, 24, 23, 22, 21, 22, 23, 24, 25, 16, 15, 14, 13};
const int gx[] = {-1, 1, -1, 1, 0, 0};
const int gy[] = {-1, 1, 1, -1, 2, -2};
map <vector<int>, bool> ans;
int N;
P pos[MN];
bool vis[MN], occ[MN];
int ha[500][500];
int nxt[33][20][6];
// int prea[33][20], sufa[33][20];
// int preb[33][20], sufb[33][20];
int mia, mib, maa, mab;
int n, poi[MN];
queue<int> que;
void init() {
mia = 10000, mib = 10000;
maa = -10000, mab = -10000;
memset(h, 0, sizeof h);
for(int i = 1; i <= 17; i++) {
for(int x = L[i]; x <= R[i]; x += 2) {
pos[++N] = P(i, x);
ha[i][x] = N;
mia = min(mia, i - x);
maa = max(maa, i - x);
mib = min(mib, i + x);
mab = max(mab, i + x);
}
}
// cerr << mia << " " << maa << "\n";
// cerr << mib << " " << mab << "\n";
}
void build(int x, int id) {
vector<int> tmp(n);
int N = 0;
for(int i = 1; i <= n; i++) {
if(i == id) continue;
if(x && x < poi[i]) assert(N >= n), tmp[N++] = x, x = 0;
assert(N >= n);
tmp[N++] = poi[i];
}
if(x)
assert(N >= n), tmp[N++] = x;
ans[tmp] = 1;
}
void move(int& x, int& y, int dir) {
x = x + gx[dir], y = y + gy[dir];
return;
}
void solve() {
ans.clear();
scanf("%d", &n);
memset(occ, 0, sizeof occ);
for(int i = 1; i <= n; i++) {
P tmp;
auto& [x, y] = tmp;
scanf("%d%d", &x, &y);
y = (y - 1 << 1) + L[x];
// cerr << x << " " << y << " z\n";
poi[i] = ha[x][y];
occ[poi[i]] = 1;
}
sort(poi + 1, poi + 1 + n);
for(int i = 1; i <= n; i++) {
memset(vis, 0, sizeof vis);
for(int j = 1; j <= 17; j++) {
for(int k = R[j], lst = -1; k >= L[j]; k -= 2) {
if(ha[j][k] != poi[i] && occ[ha[j][k]]) lst = ha[j][k];
nxt[j][k][4] = lst;
}
for(int k = L[j], lst = -1; k <= R[j]; k += 2) {
if(ha[j][k] != poi[i] && occ[ha[j][k]]) lst = ha[j][k];
nxt[j][k][5] = lst;
}
}
for(int j = mia, k, y; j <= maa; j += 2) {
k = 1;
// cerr << k << " " << k - j << " " << j << " zz\n";
while(k - j < 0 || !ha[k][k - j]) ++k;
// cerr << k << " " << k - j << " " << j << "\n";
for(int lst = -1; ha[k][k - j]; k++){
// cerr << k << " " << k - j << " " << j << " x\n";
if(ha[k][k - j] != poi[i] && occ[ha[k][k - j]]) lst = ha[k][k - j];
nxt[k][k - j][0] = lst;
// cerr << "yyy\n";
}
k = 120;
// cerr << k << " " << k - j << " " << j << " y\n";
while(!ha[k][k - j]) --k;
// cerr << k << " " << k - j << " " << j << "\n";
for(int lst = -1; ha[k][k - j]; k--){
if(ha[k][k - j] != poi[i] && occ[ha[k][k - j]]) lst = ha[k][k - j];
nxt[k][k - j][1] = lst;
}
}
// std::cerr << "xxxxx" << endl;
for(int j = mib, k, y; j <= mab; j += 2) {
k = 1;
// cerr << k << " " << j - k << " " << j << "\n";
while(!ha[k][j - k]) ++k;
// cerr << k << " " << j - k << " " << j << "\n";
for(int lst = -1; ha[k][j - k]; k++){
if(ha[k][j - k] != poi[i] && occ[ha[k][j - k]]) lst = ha[k][j - k];
nxt[k][j - k][2] = lst;
}
k = 120;
while(j - k < 0 || !ha[k][j - k]) --k;
// cerr << k << " " << j - k << " " << j << "\n";
for(int lst = -1; ha[k][j - k]; k--){
if(ha[k][j - k] != poi[i] && occ[ha[k][j - k]]) lst = ha[k][j - k];
nxt[k][j - k][3] = lst;
}
}
vis[poi[i]] = 1;
que.push(poi[i]);
// cerr << poi[i] << "\n";
// std::cerr << "xxxx" << endl;
while(!que.empty()) {
int v = que.front();
auto [x, y] = pos[v];
que.pop();
build(v, i);
// cerr << i << " : \n";
// cerr << x << " " << y << "\n";
for(int u = 0; u < 6; u++) {
int nx = x, ny = y;
move(nx, ny, u);
// cerr << x << " " << y << " " << nx << " " << ny << " " << u << " u\n";
// cerr << nxt[nx][ny][u] << "\n";
if(ny < 1 || !ha[nx][ny] || nxt[nx][ny][u] == -1) continue;
// cerr << "zzz\n";
auto [mx, my] = pos[nxt[nx][ny][u]];
int ox = 2 * mx - x, oy = 2 * my - y;
// cerr << mx << " " << my << "\n";
if(ox < 1 || oy < 1 || !ha[ox][oy]) continue;
move(mx, my, u);
int z = nxt[mx][my][u];
// cerr << ox << " " << oy << " zz\n";
// cerr << z << "\n";
// if(z != -1) cerr << pos[z].first << " " << pos[z].second << "\n";
if(z == -1 || pos[z].second < min(y, oy) || pos[z].second > max(y, oy)) {
// cerr << " ????\n";
if(!vis[ha[ox][oy]]) {
vis[ha[ox][oy]] = 1;
que.push(ha[ox][oy]);
}
}
}
// cerr << "xzzz\n";
}
}
printf("%d\n", ans.size() - 1);
}
int main() {
int TT = 1;
init();
scanf("%d", &TT);
while(TT--) {
solve();
}
}
Details
answer.code: In function ‘void init()’: answer.code:23:12: error: ‘h’ was not declared in this scope 23 | memset(h, 0, sizeof h); | ^ answer.code: In function ‘void solve()’: answer.code:156:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::map<std::vector<int>, bool>::size_type’ {aka ‘long unsigned int’} [-Wformat=] 156 | printf("%d\n", ans.size() - 1); | ~^ ~~~~~~~~~~~~~~ | | | | int std::map<std::vector<int>, bool>::size_type {aka long unsigned int} | %ld answer.code:56:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 56 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 61 | scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:161:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 161 | scanf("%d", &TT); | ~~~~~^~~~~~~~~~~