QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#410091 | #7179. Fischer's Chess Guessing Game | ec1117 | TL | 0ms | 3772kb | C++14 | 2.6kb | 2024-05-13 12:29:28 | 2024-05-13 12:29:28 |
Judging History
answer
//https://qoj.ac/contest/1356/problem/7179
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define For(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define Rof(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
cerr << h; if (sizeof...(t)) cerr << ", ";
DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
set<vi> totStates;
map<int, char> M = {{0,'R'}, {1,'B'}, {2,'N'}, {3,'K'}, {4,'Q'}};
string ts(vi v) {
string ret = "";
trav(x,v) {
ret += M[x];
}
return ret;
}
int diffs(vi a, vi b) {
int cnt = 0;
For(i,8)if(a[i]==b[i]) cnt++;
return cnt;
}
void solve() {
vector<vi> cur;
trav(x,totStates)cur.pb(x);
For(i,6) {
if(sz(cur)==0) {
dbg("ERR");
return;
}
if(sz(cur)==1) {
dbg("CORRECT");
}
vi tmp = cur[rng()%sz(cur)];
cout << ts(tmp) << endl;
int x; cin>>x;
if(x==8) {
return;
}
vector<vi> news;
trav(y,cur) if(diffs(y,tmp)==x) {
news.pb(y);
}
cur = news;
}
assert(-1);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
vi v = {0,0,1,1,2,2,3,4};
while(next_permutation(all(v))) {
int L =-1, R=-1, M=-1;
For(i,8) if(v[i]==0) {
L=i;
break;
}
Rof(i,8) if(v[i]==0) {
R=i;
break;
}
For(i,8) if(v[i]==3) {
M=i;
break;
}
if(M<L || M>R) continue;
vi v2;
For(i,8)if(v[i]==1) {
v2.pb(i%2);
}
assert(sz(v2)==2);
if((v2[0]^v2[1])==0) continue;
totStates.insert(v);
}
// cout <<sz(totStates) << endl;
// trav(x,totStates) {
// cout << ts(x) << endl;
// }
assert(sz(totStates) == 960);
while(true) {
string S;
getline(cin,S);
if(S=="END") {
break;
}
solve();
getline(cin,S);
}
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
GAME 1 3 1 2 8 END
output:
RNBBNQKR BNRKNBQR RBNNKQBR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 4 (1 test case)
Test #2:
score: -100
Time Limit Exceeded
input:
GAME 1 3 1 2 8 GAME 2 3 1 0 3 8 GAME 3 3 2 1 6 8 GAME 4 2 1 2 8 GAME 5 4 3 5 8 GAME 6 1 1 0 1 8 GAME 7 2 1 1 3 1 4
output:
RNBBNQKR BNRKNBQR RBNNKQBR RKRBBQNN BRNBKRQN QRBNKBRN BBNRKQNR RNKBQRBN RKRBBNQN RBNKBQNR BBNRKRNQ RQNKNRBB RKRNBBNQ RKRBBNNQ BBRQKNNR RBNNBKQR QNBBRNKR RKRBQNBN RKBRNBQN RKBQNRNB RKRNNBBQ RKRBNQBN BNQRKNRB RQNKBBRN NBQNBRKR BRKBRQNN RKRBNNBQ RNKBRQBN NBRKRNBQ BRKBNRNQ RBBQNKRN BBNRKQRN RKNQNBBR