QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224174#7179. Fischer's Chess Guessing GameuroskCompile Error//C++142.9kb2023-10-23 00:19:082023-10-23 00:19:08

Judging History

你现在查看的是最新测评结果

  • [2023-10-23 00:19:08]
  • 评测
  • [2023-10-23 00:19:08]
  • 提交

answer

#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;

#define maxn 1005
map<ll,char> mp;
string kod[maxn];
ll sad = 0;
bool test = 0;
ll F(ll x,ll y){
    string a = kod[x];
    string b = kod[y];
    ll ans = 0;
    for(ll i = 0;i<8;i++) ans+=(a[i]==b[i]);
    return ans;
}
void reshi(vector<ll> v){
    //dbg(si(v));
    if(si(v)==1){
        return;
    }
    ll xopt = -1,maxi = llinf;
    for(ll x : v){
        vector<vector<ll> > cur(9);
        for(ll y : v){
            cur[g[x][y]].pb(y);
        }
        ll curmax = 0;
        for(vector<ll> s : cur) curmax = max(curmax,si(s));
        if(curmax<maxi){
            xopt = x;
        }
    }
    cout<<kod[xopt]<<endl;
    ll cnt = 0;
    if(!test) cin >> cnt;
    else cnt = F(sad,xopt);
    vector<vector<ll> > cur(9);
    for(ll y : v){
        cur[F(xopt,y)].pb(y);
    }
    reshi(cur[cnt]);
}
void tc(){
    vector<ll> v;
    for(ll i = 0;i<960;i++) v.pb(i);
    reshi(v);
}
map<string,bool> was;
int main(){
	int t; t = 1;
	mp[0] = mp[1] = 'B';
	mp[2] = mp[3] = 'N';
	mp[4] = mp[5] = 'R';
	mp[6] = 'Q';
	mp[7] = 'K';
	vector<vector<ll> > v;
	v.pb({});
	for(ll i = 0;i<960;i++) v[0].pb(i);
	ll tsz = 0;
	vector<ll> p(8);
	iota(all(p),0);
	do{
        ll b1 = -1,b2 = -1;
        ll r1 = -1,r2 = -1;
        ll k = -1;
        string cur = "";
        for(ll i = 0;i<8;i++){
            if(mp[p[i]]=='B'){
                if(b1==-1) b1 = i;
                else b2 = i;
            }else if(mp[p[i]]=='R'){
                if(r1==-1) r1 = i;
                else r2 = i;
            }else if(mp[p[i]]=='K'){
                k = i;
            }
            cur+=mp[p[i]];
        }
        if(was[cur]) continue;
        was[cur] = 1;
        bool ok = 1;
        ok&=((k>=r1)&&(k<=r2));
        ok&=((b1&1)!=(b2&1));
        if(ok) kod[tsz++] = cur;
	}while(next_permutation(all(p)));
	for(ll i = 0;i<960;i++) for(ll j = 0;j<960;j++) g[i][j] = F(i,j);
	while(1){
        //here;
        string s; cin >> s;
        if(s=="END") return 0;
        cin >> t;
        if(test){
            string curs;
            cin >> curs;
            for(ll i = 0;i<960;i++) if(kod[i]==curs) sad = i;
        }
		tc();
	}
	return (0-0);
}

详细

answer.code: In function ‘void reshi(std::vector<int>)’:
answer.code:7:15: warning: overflow in conversion from ‘long long int’ to ‘int’ changes value from ‘100000000000000000’ to ‘1569325056’ [-Woverflow]
    7 | #define llinf 100000000000000000LL // 10^17
      |               ^~~~~~~~~~~~~~~~~~~~
answer.code:41:25: note: in expansion of macro ‘llinf’
   41 |     ll xopt = -1,maxi = llinf;
      |                         ^~~~~
answer.code:45:17: error: ‘g’ was not declared in this scope
   45 |             cur[g[x][y]].pb(y);
      |                 ^
answer.code: In function ‘int main()’:
answer.code:106:57: error: ‘g’ was not declared in this scope
  106 |         for(ll i = 0;i<960;i++) for(ll j = 0;j<960;j++) g[i][j] = F(i,j);
      |                                                         ^