QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#703569#9537. Chinese Chessucup-team5657#Compile Error//C++205.4kb2024-11-02 17:59:102024-11-02 17:59:29

Judging History

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

  • [2024-11-02 17:59:29]
  • 评测
  • [2024-11-02 17:59:10]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;
using ull = unsigned long long;
const int inf = 0x3f3f3f3f;
const ll inf64 = 0x3f3f3f3f3f3f3f3fll;
int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(unsigned x) { printf("%u ", x); } void outln(unsigned x) { printf("%u\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
void out(ull x) { printf("%llu ", x); } void outln(ull x) { printf("%llu\n", x); }
template<typename T, typename U> void chkmax(T &a, const U &b) { if(b > a) a = b; } 
template<typename T, typename U> void chkmin(T &a, const U &b) { if(b < a) a = b; } 
bitset<540> F[90][90], msk[6];
int vis[90][90];
vector<pii> mov[6];
bool check(int x, int y) { return 0 <= x && x <= 9 && 0 <= y && y <= 8; }
void bfs(int x, int y, int t) {
	queue<pii> q; q.emplace(x, y);
	while(!q.empty()) {
		auto [x, y] = q.front(); q.pop();
		for(auto &[dx, dy] : mov[t]) {
			int nx = x + dx, ny = y + dy; 
			if(check(nx, ny) && !(t == 5 && !dx && x <= 4) && vis[nx][ny] > vis[x][y]) {
				vis[nx][ny] = vis[x][y] + 1;
				q.emplace(nx, ny);
			}
		}
	}
}
int flg;
int dfs(bitset<540> st, int L) { bitset<540> tmp;
	if(st.count() == 1) return 0;
	_rep(t,0,5) if((st & msk[t]).count() == st.count()) return 0;
	if(L >= 3) return inf;
	vector<pii> S;
	_rep(i,0,89) {
		int mx = 0, m2x = 0; 
		_rep(j,0,89) {
			if(tmp = st & F[i][j]; tmp.count() != st.count()) 
				chkmax(mx, tmp.count());
			else { m2x = 1; break; }
		}
		if(!m2x) S.emplace_back(mx, i);
	}
	sort(S.begin(), S.end());
	int mn = inf;
	for(int i = 0; i < min(70, int(S.size())); ++i) { int u = S[i].second, mx = 0;
		if(L <= 2) {
			int w;
			vector<pii> v; _rep(j,0,89) if(tmp = st & F[u][j], w = tmp.count(); w) v.emplace_back(w, j);
			sort(v.begin(), v.end(), greater<pii>());
			_rep(j,0,min(40, int(v.size()) - 1)) {
				chkmax(mx, dfs(st & F[u][v[j].second], L + 1));
				if(mx >= 3 - L - 1) break;
			}
		} else {
			_rep(j,0,89) {
				tmp = st & F[u][j]; int v = tmp.count(); if(v) {
					_rep(t,0,5) {
						int a = (tmp & msk[t]).count();
						if(a && a < v) mx = 100000000;
					}
				}
			}
		}
		chkmin(mn, mx); if(!mn) break;
	}
	return mn + 1;
}
int ans ;
void DOIT(bitset<540> st, int L) { bitset<540> tmp;
	_rep(t,0,5) {
		int cnt = 0;
		_rep(i,t * 90, (t + 1) * 90 - 1) cnt += st[i];
		if(cnt == st.count()) {
			printf("! ");
			if(t == 0) puts("J");
			if(t == 1) puts("M");
			if(t == 2) puts("S");
			if(t == 3) puts("X");
			if(t == 4) puts("C");
			if(t == 5) puts("B");
			fflush(stdout);
			exit(0);
		}
	}
	vector<pii> S;
	_rep(i,0,89) {
		int mx = 0, m2x = 0; 
		_rep(j,0,89) {
			if(tmp = st & F[i][j]; tmp.count() != st.count()) 
				chkmax(mx, tmp.count());
			else { m2x = 1; break; }
		}
		if(!m2x) S.emplace_back(mx, i);
	}
	sort(S.begin(), S.end());
	int mn = inf;
	for(int i = 0; i < min(70, int(S.size())); ++i) { int u = S[i].second, mx = 0;
		if(L <= 2) {
			int w;
			vector<pii> v; _rep(j,0,89) if(tmp = st & F[u][j], w = tmp.count(); w) v.emplace_back(w, j);
			sort(v.begin(), v.end(), greater<pii>());
			_rep(j,0,min(40, int(v.size()) - 1)) {
				chkmax(mx, dfs(st & F[u][v[j].second], L + 1));
				if(mx >= 3 - L - 1) break;
			}
		} else {
			_rep(j,0,89) {
				tmp = st & F[u][j]; int v = tmp.count(); if(v) {
					_rep(t,0,5) {
						int a = (tmp & msk[t]).count();
						if(a && a < v) mx = 100000000;
					}
				}
			}
		}
		if(mx == ans - L - 1) {
			printf("? %d %d\n", S[i].second / 9, S[i].second % 9); fflush(stdout);
			int u = in();
			DOIT(st & F[S[i].second][u == -1 ? 89 : u], L + 1); 
		}
	}
}
int main() { 
	mov[0] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; //J
	mov[1] = {{1, 2}, {-1, 2}, {1, -2}, {-1, -2}, {2, 1}, {-2, 1}, {2, -1}, {-2, -1}}; //M
	mov[2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; //S
	mov[3] = {{2, 2}, {-2, 2}, {2, -2}, {-2, -2}}; //X
	_rep(i,-9,9) if(i) mov[4].emplace_back(i, 0), mov[4].emplace_back(0, i); //C
	mov[5] = {{1, 0}, {0, 1}, {0, -1}}; //B
	_rep(t,0,5) _rep(i,0,9) _rep(j,0,8) {
		_rep(x,0,9) _rep(y,0,8) vis[x][y] = 89;
		vis[i][j] = 0, bfs(i, j, t);
		_rep(x,0,9) _rep(y,0,8) F[x * 9 + y][vis[x][y]][t * 90 + i * 9 + j] = 1;
	}
	_rep(t,0,5) _rep(j,t * 90,(t + 1) * 90 - 1) msk[t][j] = 1;
	bitset<540> st;
	// st.set();
	int n = in();
	_rep(i,1,n) {
		int x = in(), y = in(), z = x * 9 + y;
		_rep(j,0,5) st[j * 90 + z] = 1;
	}
	outln(ans = dfs(st, 0));
	DOIT(st, 0);
	return 0;
}

/* 
a list of keywords
clear empty push_back pop_back push pop top front back
emplace_back emplace push_front pop_front insert erase
find count set reset bitset map vector string multiset
first second iterator prev next deque multimap reverse
sort begin end list modify query init check calc prime
putchar getchar puts scanf printf max min swap replace
make_pair make_tuple numeric_limits auto function null
*/

Details

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/gthr.h:148,
                 from /usr/include/c++/13/ext/atomicity.h:35,
                 from /usr/include/c++/13/bits/ios_base.h:39,
                 from /usr/include/c++/13/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  102 | __gthrw(pthread_once)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  103 | __gthrw(pthread_getspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  104 | __gthrw(pthread_setspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  106 | __gthrw(pthread_create)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  107 | __gthrw(pthread_join)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  108 | __gthrw(pthread_equal)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  109 | __gthrw(pthread_self)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  110 | __gthrw(pthread_detach)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  112 | __gthrw(pthread_cancel)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  114 | __gthrw(sched_yield)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  116 | __gthrw(pthread_mutex_lock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  117 | __gthrw(pthread_mutex_trylock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  119 | __gthrw(pthread_mutex_timedlock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:121:1: error: attribute value ‘t...