QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834842 | #9537. Chinese Chess | Ballmer Peak (Ali Safari, AmirMohammad Shahrezaei, Alireza Keshavarz) | WA | 9ms | 4224kb | C++17 | 3.8kb | 2024-12-28 04:26:41 | 2024-12-28 04:26:41 |
Judging History
answer
#ifdef safar
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#else
#include <bits/stdc++.h>
#endif
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef bitset<540> bt;
const int N = 100 + 10;
const int Sq = 4e4;
string names = "JSCMXB";
int id[N][N];
int dis[6][N][N];
bt val[N][N]; // dis pos
int tot = 90;
int n = 10, m = 9;
int pc = 6;
int bst = 4;
unordered_map<bt, pii> mem;
inline int OK(int x){
return (x + N) % N;
}
pair<int, int> Solve(bt cur, int dep){
if(mem.count(cur))
return mem[cur];
set<int> st;
rep(i, 0, 6 * tot) if(cur[i]) st.insert(i % 6);
if(st.size() <= 1) return {0, -1};
if(dep == bst) return {20, -1};
int mv = -1;
int rq = 10;
rep(q, 0, tot){
set<int> pd;
rep(i, 0, 6 * tot) if(cur[i]) pd.insert(OK(dis[i % 6][i / 6][q]));
int cst = 1;
for(auto ds : pd) cst = max(cst, 1 + Solve(cur & val[ds][q], dep + 1).F);
if(cst <= rq){
rq = cst;
mv = q;
}
if(cst >= rq) continue;
}
return mem[cur] = {rq, mv};
}
bt cur;
int Main(){
rep(i, 0, 10) rep(j, 0, 9) id[i][j] = i * 9 + j;
memset(dis, 31, sizeof dis);
rep(t, 0, 6){
rep(i, 0, n){
rep(j, 0, m){
vector<pii> dlt;
if(t == 0) dlt = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
if(t == 1) dlt = {{1, -1}, {-1, 1}, {1, 1}, {-1, -1}};
if(t == 2){
rep(i, 1, 11) dlt.pb({0, i});
rep(i, 1, 11) dlt.pb({0, -i});
rep(i, 1, 11) dlt.pb({-i, 0});
rep(i, 1, 11) dlt.pb({i, 0});
}
if(t == 3) dlt = {{1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}};
if(t == 4) dlt = {{2, -2}, {-2, 2}, {2, 2}, {-2, -2}};
if(t == 5 && i <= 4) dlt = {{1, 0}};
if(t == 5 && i > 4) dlt = {{1, 0}, {0, 1}, {0, -1}};
for(auto [dx, dy] : dlt){
int nx = dx + i;
int ny = dy + j;
if(nx < 0 || ny < 0 || nx >= n || ny >= m) continue;
dis[t][id[i][j]][id[nx][ny]] = 1;
}
}
}
rep(md, 0, tot)rep(u, 0, tot) rep(v, 0, tot){
dis[t][u][v] = min(dis[t][u][v], dis[t][u][md] + dis[t][md][v]);
}
rep(u, 0, tot) rep(v, 0, tot) if(dis[t][u][v] > tot) dis[t][u][v] = -1;
rep(u, 0, tot) rep(v, 0, tot) val[OK(dis[t][u][v])][v][u * 6 + t] = 1;
}
vector<pii> sts, tmp;
// vector<int> Q = {0, 1, tot - 2, tot - 1};
// map<vector<int>, vector<pii> > mp;
// for(auto st : sts){
// vector<int> X;
// for(auto q : Q) X.pb(dis[st.F][st.S][q]);
// mp[X].pb(st);
// }
// for(auto el : mp){
// set<int> tmp;
// for(auto [p, pos] : el.S) tmp.insert(p);
// // cerr << el.S.size() << ' ' << tmp.size() << '\n';
// if(tmp.size() > 1){
// for(auto [p, pos] : el.S) cerr << p << " at (" << pos/m << " , " << pos % m << ")\n";
// cerr << "# ";
// for(auto x : el.F) cerr << x << ' '; cerr << '\n';
// cerr << '\n';
// }
// }
int k;
cin >> k;
rep(i, 0, k){
int pos, x, y;
cin >> x >> y;
pos = x * m + y;
rep(p, 0, 6) cur[pos * 6 + p] = 1;
}
auto slv = Solve(cur, 0);
cout << slv.F << '\n';
while(true){
set<int> st;
rep(i, 0, 6 * tot) if(cur[i]) st.insert(i % 6);
if(st.size() <= 1){
cout << "! " << names[*st.begin()] << endl;
break;
}
auto slv = Solve(cur, 0);
cout << "? " << slv.S / m << ' ' << slv.S % m << endl;
int res;
cin >> res;
cur &= val[OK(res)][res];
}
return 0;
}
int main(){
ios::sync_with_stdio(0);
int tc = 1;
// cin >> tc;
while(tc --) Main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 4224kb
input:
1 9 0 6
output:
1 ? 7 6 ! J
result:
wrong answer guessed type is incorrect.