QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610494#7635. Fairy ChessericmegalovaniaCompile Error//C++202.3kb2024-10-04 16:13:262024-10-04 16:13:26

Judging History

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

  • [2024-10-04 16:13:26]
  • 评测
  • [2024-10-04 16:13:26]
  • 提交

answer

#include<bits/stdc++.h> //bf + bit mask + sg
using namespace std;

//#define ONLINE
#ifndef ONLINE
char DEBUG_BUFFER[1000];
#define debug(...) {sprintf(DEBUG_BUFFER,##__VA_ARGS__);\
cerr<<"\033[1;36m"<<DEBUG_BUFFER<<"\033[0;2m"<<"\033[0m";}
#else
#define debug(...) ;
#endif

using LL=long long;
using PII=pair<int,int>;

#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

#define FAST_IO {ios::sync_with_stdio(false);cin.tie(nullptr);}
inline int read(){static int x; cin>>x; return x;}
inline LL readLL(){static LL x; cin>>x; return x;}
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

using u64=unsigned long long;

u64 cover[6][64];
inline int pos(const int& x,const int& y){
	return x*8+y;
}
inline void upd(u64& res,const int& x,const int& y){
	if(x>=0 && x<8 && y>=0 && y<8){
		res|=1ull<<pos(x,y);
	}
}
void init(){
	int dir[8][2]={{1,2},{1,-2},{-1,2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1}};
	for(int x=0;x<8;x++) for(int y=0;y<8;y++){
		int id=pos(x,y);
		u64 knight=0;
		for(int i=0;i<8;i++){
			int dx=dir[i][0],dy=dir[i][1];
			upd(knight,x+dx,y+dy);
		}
		for(int i=-8;i<8;i++){
			//bishop
			upd(cover[0][id],x+i,y+i);
			upd(cover[0][id],x+i,y-i);
			//rook
			upd(cover[1][id],x+i,y);
			upd(cover[1][id],x,y+i);
		}
		//queen
		cover[2][id]=cover[0][id]|cover[1][id];
		//archbishop
		cover[3][id]=knight|cover[0][id];
		//chancellor
		cover[4][id]=knight|cover[1][id];
		//maharaja
		cover[5][id]=knight|cover[2][id];
//		for(int j=0;j<6;j++){
//			assert(cover[j][id]>>id&1);
//		}
	}
}

string s;
int a[12];
inline c2i(const char& c){
	if(c=='B') return 0;
	else if(c=='R') return 1;
	else if(c=='Q') return 2;
	else if(c=='A') return 3;
	else if(c=='C') return 4;
	else return 5; //'M'
}

bool dfs(const u64& cov,const u64& put,const int& u){
	if(u==12) return 0;
	for(int i=0;i<64;i++) if(!(cov&i>>1)){
		if(cover[a[u]][i]&put) continue;
		if(!dfs(cov|cover[a[u]][i],put|1ull<<i,u+1)){
			return 1;
		}
	}
	return 0;
}

int main(){
	FAST_IO;
	init();
	cin>>s;
	for(int i=0;i<12;i++) a[i]=c2i(s[i]);
	cout<<(dfs(0,0,0)?"Alice":"Bob");
	return 0;
}

/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/

Details

answer.code:68:8: error: ISO C++ forbids declaration of ‘c2i’ with no type [-fpermissive]
   68 | inline c2i(const char& c){
      |        ^~~