QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#462452#8815. Space Stationucup-team159TL 0ms0kbC++235.8kb2024-07-03 19:42:592024-07-03 19:42:59

Judging History

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

  • [2024-07-30 16:51:06]
  • hack成功,自动添加数据
  • (/hack/760)
  • [2024-07-03 19:42:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-07-03 19:42:59]
  • 提交

answer

#line 1 "C.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 2 "/home/sigma/comp/library/misc/rand.hpp"

/*
	xorshift64
	決定的にしたければ x の初期値を適当に固定
*/
#line 9 "/home/sigma/comp/library/misc/rand.hpp"
using ull = unsigned long long;
ull xorshift() {
	static ull x = ull(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) * 10150724397891781847ULL;
	x ^= x<<7;
	return x ^= x>>9;
}

// [0,n)
ull rng(ull n){
	return xorshift()%n;
}
// [l,r] 閉区間!!
ull rng(ull l, ull r){
	return l + xorshift() % (r-l+1);
}

// 確率pでtrue
double gen_bool(double p){
	if(p <= 0) return false;
	if(p >= 1) return true;
	return xorshift() < ULLONG_MAX * p;
}
#line 6 "C.cpp"

struct Op{
	char c;
	int i;
};

void solve(VV<int> A, VV<int> B){
	int N = si(A);
	V<Op> ops;
	auto doit = [&](Op op){
		ops.eb(op);
		int i = op.i;
		if(op.c == 'r'){
			rotate(A[i].begin(), A[i].begin()+1, A[i].end());
		}else{
			int v = A[N-1][i] ^ 1;
			for(int j=N-1;j>0;j--) A[j][i] = A[j-1][i];
			A[0][i] = v;
		}
	};
	{
		// shuffle
		int K = rng(3);
		while(K--){
			char c = rng(2) ? 'r' : 'c';
			int i = rng(N);
			doit({c,i});
		}
	}
	VV<int> tar(N,V<int>(N));
	rep1(j,N-1){
		rep1(i,N-1) tar[i][j] = B[i][j];
		tar[0][j] = B[N-1-(j-1)][0];
	}
	
	rep1(j,N-1){
		V<bool> done(N);
		rep(i,N) if(A[i][0] == tar[i][j]){
			done[i] = true;
			doit({'r',i});
		}
		rep(_,N) doit({'c',0});
		rep(i,N) if(!done[i]){
			doit({'r',i});
		}
	}
	rep(_,N-1){
		doit({'r',0});
		doit({'c',0});
	}
	rep1(j,N-1){
		if(A[0][0] == B[0][j]){
			doit({'r',0});
		}else{
			rep(_,N) doit({'c',0});
			doit({'r',0});
		}
	}
	if(A[N-1][0] != B[N-1][0]){
		rep(_,N) doit({'c',0});
	}
	// show(A); show(B);
	show(si(ops));
	if(A[0][0] != B[0][0]) return;
	if(si(ops) > 1000) return;

	assert(A == B);

	cout << si(ops) << endl;
	for(Op op: ops){
		cout << (op.c == 'r' ? "row" : "column") << " " << op.i+1 << endl;
	}
	exit(0);
}

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

	if(false){
		int N = 20;
		cout << N << endl;
		rep(i,N){
			rep(j,N) cout << rng(2);
			cout << endl;
		}
		cout << endl;
		rep(i,N){
			rep(j,N) cout << rng(2);
			cout << endl;
		}
		exit(0);
	}

	int N; cin >> N;
	VV<int> A(N,V<int>(N));
	{
		rep(i,N){
			string s; cin >> s;
			rep(j,N) A[i][j] = s[j] - '0';
		}
	}
	VV<int> B(N,V<int>(N));
	{
		rep(i,N){
			string s; cin >> s;
			rep(j,N) B[i][j] = s[j] - '0';
		}
	}

	// solve(A,B); return 0;

	while(true) solve(A,B);
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3 3
2 3 4

output:


result: