QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#475244#8830. Breaking Baducup-team159WA 0ms3744kbC++237.7kb2024-07-13 13:32:422024-07-13 13:32:43

Judging History

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

  • [2024-07-13 13:32:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3744kb
  • [2024-07-13 13:32:42]
  • 提交

answer

#line 1 "B.cpp"
// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")

#line 2 "/home/sigma/comp/library/template.hpp"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> bool chmax(T& x, U y){
	if(x<y){ x=y; return true; }
	return false;
}
template<class T,class U> bool chmin(T& x, U y){
	if(y<x){ x=y; return true; }
	return false;
}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class T>
V<T> Vec(size_t a) {
    return V<T>(a);
}
template<class T, class... Ts>
auto Vec(size_t a, Ts... ts) {
  return V<decltype(Vec<T>(ts...))>(a, Vec<T>(ts...));
}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

template<class D> D divFloor(D a, D b){
	return a / b - (((a ^ b) < 0 && a % b != 0) ? 1 : 0);
}
template<class D> D divCeil(D a, D b) {
	return a / b + (((a ^ b) > 0 && a % b != 0) ? 1 : 0);
}

/*
x       0  1  2  3  4  5  6  7  8  9
bsr(x) -1  0  1  1  2  2  2  2  3  3
最上位bit
*/
int bsr(int x){
	return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(uint x){
	return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(ll x){
	return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}
int bsr(ull x){
	return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}

/*
x       0  1  2  3  4  5  6  7  8  9
bsl(x) -1  0  1  0  2  0  1  0  3  0
最下位bit
*/
int bsl(int x){
	if(x==0) return -1;
	return __builtin_ctz(x);
}
int bsl(uint x){
	if(x==0) return -1;
	return __builtin_ctz(x);
}
int bsl(ll x){
	if(x==0) return -1;
	return __builtin_ctzll(x);
}
int bsl(ull x){
	if(x==0) return -1;
	return __builtin_ctzll(x);
}
#line 5 "B.cpp"
template<unsigned int mod_>
struct ModInt{	
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	template<class T> friend ModInt operator+(T a, const ModInt& b){ return (ModInt(a) += b);}
	template<class T> friend ModInt operator-(T a, const ModInt& b){ return (ModInt(a) -= b);}
	template<class T> friend ModInt operator*(T a, const ModInt& b){ return (ModInt(a) *= b);}
	template<class T> friend ModInt operator/(T a, const ModInt& b){ return (ModInt(a) /= b);}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	ModInt inv() const {		// should be prime
		return pow(mod-2);
	}
	// ll extgcd(ll a,ll b,ll &x,ll &y) const{
	// 	ll p[]={a,1,0},q[]={b,0,1};
	// 	while(*q){
	// 		ll t=*p/ *q;
	// 		rep(i,3) swap(p[i]-=t*q[i],q[i]);
	// 	}
	// 	if(p[0]<0) rep(i,3) p[i]=-p[i];
	// 	x=p[1],y=p[2];
	// 	return p[0];
	// }
	// ModInt inv() const {
	// 	ll x,y;
	// 	extgcd(v,mod,x,y);
	// 	return make(normS(x+mod));
	// }

	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	bool operator<(const ModInt& b) const { return v<b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
	// friend ostream& operator<<(ostream &o,const ModInt& x){
	// 	for(int b=1;b<=100;b++){
	// 		for(int a=-100;a<=100;a++){
	// 			if(ModInt(a)/b == x){
	// 				return o << a << "/" << b;
	// 			}
	// 		}
	// 	}
	// 	return o<<x.v;
	// }
};
using mint = ModInt<5>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	VV<mint> A(N,V<mint>(N)); rep(i,N) rep(j,N) cin >> A[i][j];
	int r = 0;
	while(r < N && r < 8){
		for(int i=r+1;i<N;i++) for(int j=r+1;j<N;j++){
			if(A[r][r] + A[i][j] != A[r][j] + A[i][r]){
				rep(k,N) swap(A[r+1][k],A[i][k]);
				rep(k,N) swap(A[k][r+1],A[k][j]);
				// r,r+1
				r += 2;
				goto found;
			}
		}
		break;
		found:{}
	}
	if(r == 8){
		cout << "YYYYY" << endl; return 0;
	}
	// [r,N) * [r,N) -> 0
	mint off = 0;
	if(r != N){
		for(int i=r;i<N;i++){
			mint x = A[i][r];
			off += x;
			rep(j,N) A[i][j] -= x;
		}
		for(int i=r;i<N;i++){
			mint x = A[r][i];
			off += x;
			rep(j,N) A[j][i] -= x;
		}
	}
	const int mask = (1<<5)-1;
	auto rot = [&](int b,int i){
		b <<= i;
		return (b | (b>>5)) & mask;
	};
	// [0,r) * [r,N)
	V<int> rs(1<<r);
	{
		rs[0] = 1;
		for(int j=r;j<N;j++){
			rep(i,r){
				rep(s,1<<r) if(!(s&1<<i)){
					rs[s|1<<i] |= rot(rs[s],A[i][j].v);
				}
			}
		}
	}
	// [r,N) * [0,r)
	V<int> ds(1<<r);
	{
		ds[0] = 1;
		for(int j=r;j<N;j++){
			rep(i,r){
				rep(s,1<<r) if(!(s&1<<i)){
					ds[s|1<<i] |= rot(ds[s], A[j][i].v);
				}
			}
		}
	}
	// [0,r) * [0,r)
	VV<int> dp(1<<r,V<int>(1<<r)); dp[0][0] = 1;
	rep(i,r) rep(j,r){
		rep(si,1<<r) rep(sj,1<<r){
			if(si&1<<i) continue;
			if(sj&1<<j) continue;
			dp[si|1<<i][sj|1<<j] |= rot(dp[si][sj],A[i][j].v);
		}
	}
	show(dp);
	const int mask2 = (1<<r)-1;
	int ans = 0;
	rep(si,1<<r) rep(sj,1<<r){
		int a = dp[si][sj], b = rs[si^mask2], c = ds[sj^mask2];
		rep(ai,5) if(a&1<<ai){
			rep(bi,5) if(b&1<<bi){
				rep(ci,5) if(c&1<<ci){
					ans |= 1<<((ai+bi+ci)%5);
				}
			}
		}
	}
	ans = rot(ans,off.v);
	rep(i,5) cout << ((ans&1<<i) ? 'Y' : 'N');
	cout << endl;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3744kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

YYYYY

result:

wrong answer 1st words differ - expected: 'YYYYN', found: 'YYYYY'