QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350569#8330. Count off 3ucup-team159AC ✓426ms3924kbC++239.4kb2024-03-10 20:30:282024-03-10 20:30:30

Judging History

你现在查看的是测评时间为 2024-03-10 20:30:30 的历史记录

  • [2024-10-13 18:47:01]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:AC
  • 用时:394ms
  • 内存:3940kb
  • [2024-04-17 10:54:25]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:405ms
  • 内存:3944kb
  • [2024-04-17 10:54:24]
  • hack成功,自动添加数据
  • (/hack/598)
  • [2024-04-16 16:08:55]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:404ms
  • 内存:3984kb
  • [2024-04-16 16:08:54]
  • hack成功,自动添加数据
  • (/hack/597)
  • [2024-03-10 20:30:30]
  • 评测
  • 测评结果:100
  • 用时:426ms
  • 内存:3924kb
  • [2024-03-10 20:30:28]
  • 提交

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 "/mnt/c/Users/tsigm/Documents/Cprogram/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);
}


template<class T>
T rnd(T l,T r){	//[l,r)
	using D = uniform_int_distribution<T>;
	static random_device rd;
	static mt19937 gen(rd());
	return D(l,r-1)(gen);
}
template<class T>
T rnd(T n){	//[0,n)
	return rnd(T(0),n);
}
#line 5 "C.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;}
};
using mint = ModInt<1000000007>;

V<mint> fact,ifact,invs;
// a,b >= 0 のみ
mint Choose(int a,int b){
	if(b<0 || a<b) return 0;
	return fact[a] * ifact[b] * ifact[a-b];
}

/*
// b >= 0 の範囲で、 Choose(a,b) = a(a-1)..(a-b+1) / b!
mint Choose(int a,int b){
	if(b<0 || a<b) return 0;
	return fact[a] * ifact[b] * ifact[a-b];
}
*/

void InitFact(int N){	//[0,N]
	N++;
	fact.resize(N);
	ifact.resize(N);
	invs.resize(N);
	fact[0] = 1;
	rep1(i,N-1) fact[i] = fact[i-1] * i;
	ifact[N-1] = fact[N-1].inv();
	for(int i=N-2;i>=0;i--) ifact[i] = ifact[i+1] * (i+1);
	rep1(i,N-1) invs[i] = fact[i-1] * ifact[i];
}

mint solve(string s){
	int N = si(s);
	reverse(all(s));
	if(s[0] == '1'){
		bool done = false;
		rep(i,N){
			if(s[i] == '0'){
				s[i] = '1'; done = true; break;
			}
			s[i] = '0';
		}
		if(!done){
			s += '1';
			N++;
		}
	}
	show(s);
	// s = 001101010001
	// x = 1****0010001
	// p0 = 1s0+1s2+1s4, p1 = 1s1+1s3+1s5
	// q0 = 1s0+4s2+2s4, q1 = 2s1+1s3+4s5
	// r0 = 1s0+2s2+4s4, r1 = 3s1+6s3+5s5
	// off[i] += A[i][j] * s_j

	VV<int> A = {
		{1,0,1,0,1,0},
		{0,1,0,1,0,1},
		{1,0,4,0,2,0},
		{0,2,0,1,0,4},
		{1,0,2,0,4,0},
		{0,3,0,6,0,5}
	};
	V<int> off(6);
	rep(j,N) if(j == 0 || s[j] == '1'){
		rep(i,6) off[i] += A[i][j%6];
	}
	rep(i,6) off[i] %= 7;
	auto dp0 = Vec<mint>(7,7,7);
	auto dp1 = Vec<mint>(8,8,8);	// 7:*
	auto buf = Vec<mint>(7,7,7);
	dp0[0][0][0] = dp1[0][0][0] = 1;
	mint ans = 0;
	rep1(j,N-1){
		if(s[j] == '1'){
			show("--------------"); show(j);
			rep(i,6) off[i] = (off[i]-A[i][j%6]+7)%7;
			show(off);
			{
				// dp1 accumulate
				rep(p,8) rep(q,8) rep(r,8) if(p==7 or q==7 or r==7) dp1[p][q][r] = 0;
				rep(p,7) rep(q,7) rep(r,7){
					dp1[p][q][7] -= dp1[p][q][r];
					dp1[p][7][r] -= dp1[p][q][r];
					dp1[p][7][7] += dp1[p][q][r];
					dp1[7][q][r] -= dp1[p][q][r];
					dp1[7][q][7] += dp1[p][q][r];
					dp1[7][7][r] += dp1[p][q][r];
					dp1[7][7][7] -= dp1[p][q][r];
				}
			}
			// x[0] = 1
			// x[1,j-1] = *
			// x[j] = 0
			// x[j+1..] = s[j+1..]
			VV<int> pbads(7);
			rep(p0,7){
				rep(p1,7){
					if((p0+off[0] + p1+off[1])%7 == 0 or
					   (p0+off[0] - p1-off[1])%7 == 0) pbads[p0].pb(p1);
				}
				pbads[p0].pb(7);
			}
			VV<int> qbads(7);
			rep(q0,7){
				rep(q1,7){
					if((q0+off[2] + q1+off[3])%7 == 0 or
					   (q0+off[2] - q1-off[3])%7 == 0) qbads[q0].pb(q1);
				}
				qbads[q0].pb(7);
			}
			VV<int> rbads(7);
			rep(r0,7){
				rep(r1,7){
					if((r0+off[4] + r1+off[5])%7 == 0 or
					   (r0+off[4] - r1-off[5])%7 == 0) rbads[r0].pb(r1);
				}
				rbads[r0].pb(7);
			}

			rep(p0,7) rep(q0,7) rep(r0,7){
				mint tmp = 0;
				for(int p1: pbads[p0]) for(int q1: qbads[q0]) for(int r1: rbads[r0]){
					tmp -= dp1[p1][q1][r1];
				}
				ans += dp0[p0][q0][r0] * tmp;
				// rep(p1,7) rep(q1,7) rep(r1,7){
				// 	if(binary_search(all(pbads[p0]),p1)) continue;
				// 	if(binary_search(all(qbads[q0]),q1)) continue;
				// 	if(binary_search(all(rbads[r0]),r1)) continue;
				// 	ans += dp0[p0][q0][r0] * dp1[p1][q1][r1];
				// }
			}
		}
		// j -> *
		if(j%2 == 0){
			buf = dp0;
			rep(p,7) rep(q,7) rep(r,7) dp0[(p+A[0][j%6])%7][(q+A[2][j%6])%7][(r+A[4][j%6])%7] += buf[p][q][r];
		}else{
			buf = dp1;
			rep(p,7) rep(q,7) rep(r,7) dp1[(p+A[1][j%6])%7][(q+A[3][j%6])%7][(r+A[5][j%6])%7] += buf[p][q][r];
		}
	}
	return ans;
}

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

	int T; cin >> T;
	while(T--){
		string s; cin >> s;
		cout << solve(s) << endl;
	}
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3620kb

input:

5
1
1010
110101
1000111000
101101001000

output:

1
2
15
114
514

result:

ok 5 number(s): "1 2 15 114 514"

Test #2:

score: 0
Accepted
time: 4ms
memory: 3588kb

input:

10
1
11
1000
10111011
1000110100101001
11101110000001000011010011011000
110011000111110001101010101100100011010010101000011111001101011
11010111011101000010101111011111011011100001001101010011101011111111011011111101110110010011001101000001000111100010010111000010
10000000000000000000000000000000000...

output:

1
1
2
45
6591
814196699
193088128
849103726
497125329
363076920

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 57ms
memory: 3896kb

input:

10
1
101
100101000
111111001111011001111100111
100001101010101000101110010111010010001101101110011111000001010001111100101010000
111001010100100100110011110111000111001001001001000100000011000110011000110101010010100000100101110101000011000011100010011001011000101110100111000110011011010111011111011...

output:

1
2
64
27062688
486363229
184013394
580592021
118930214
772664718
344619804

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 157ms
memory: 3896kb

input:

10
1
1011
1101001010001110
1000010101110010000010010000000000001010111001001001110011001101
1001100101110111001000100100110111110001110010111011010101010111011101111101111100010000001100001001011100111100010110011010000010000000001100111011000001110011010000100000110101010011111100010111111100011011...

output:

1
3
10053
860833891
537931408
329471109
368911735
157523156
595487313
534701861

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 225ms
memory: 3636kb

input:

10
1
11111
1010110010010000111001001
10011010100100001000110000111101101000111100001000000101010001100111111010001000101000000011100101000101100111100001001101100
11000100100010011101010101001011100010001100001010110011110101001101011000110001000111101010010000110111010001100100100111001000001000010...

output:

1
10
4692555
763463648
464152115
115362567
880780461
578723006
560068977
423846910

result:

ok 10 numbers

Test #6:

score: 0
Accepted
time: 273ms
memory: 3688kb

input:

10
1
101011
100100110100111100001101000101011100
1011011000011001101101010110000111011001001100110101111100110000100100101010000000110110010001110011101011000001011001000010001011101110110100110010111111000101101010110000101010101011001111100111011001101111011101
101000000111000010111000110000011000...

output:

1
13
955673880
266148454
368723690
496979115
190983211
772121423
932555320
843716403

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 299ms
memory: 3736kb

input:

10
1
1101101
1100111111001000111100000010000111000000010101001
110111101101011000111101100110010011011100101110101111110011001111001101001000011001110011110101001110010110011110011001111010010101010011010011101101111010111000001110110111011011101000100001000001101110010111100110001110011101110111100...

output:

1
29
912933242
912560788
607401363
477602366
394403189
275067439
592568023
75193370

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 308ms
memory: 3924kb

input:

10
1
10000010
100101110110100111100000100011111111010001100010100001100110001
111111000010011010111011111110000010101101011110100001101011110000001111001110001111110101000000010000001011000101101011010111011101111110101001000110011101010000111001011111100100010000010110110101010001110100111110110001...

output:

1
32
959140870
614330473
849221876
787816311
359958989
239371459
534701861
254356877

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 337ms
memory: 3852kb

input:

10
1
111110011
111101001101011110100011110000100110011101010111111110100001111001101000100101101
11011010000110101011111110110011101010100100110001001111111011010000101111110001001011000011010101001000101110000100011011100101010110010101000101010111101100101110111100011011011000101101001001001100111...

output:

1
99
286317277
694681686
723919544
789291149
680541846
694957099
453387561
757810824

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 364ms
memory: 3692kb

input:

10
1
1001001110
10110010111110100100111100111101101010111110111011001110000111101011011010110011110000000001110100
11000101011111110110100101100100100000010110001011100010101111111000000111000101100110111110101010111110010110111111110010110010001100000000111000101100010001110010001011111110101011111...

output:

1
120
987933828
449323095
435643580
557750562
122442298
758115947
388795572
87146822

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 366ms
memory: 3724kb

input:

10
1
11010010100
100110110000100111011101001111000000000110111100011110111011110100001010101000000000100000101100100101110101011100111000
110111100000010010111000111011111100010100100111101001001101111010011011100100001010100010100011110111111100101011100111111011011000000111001111000101111010110111...

output:

1
325
391030697
323231960
401473132
822267612
841573845
283856764
804647498
76347459

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 373ms
memory: 3916kb

input:

10
1
111111110011
100111010001010010111100011101110011110100101101010111001110101111000111010001111110000001000011010111010001001000011101100011100010010100010000
11001011101100010011111001010110110000110110011001011001000001001110010100100000000101100010001011010010001101000101110000111100100000001...

output:

1
704
677678115
593427859
667002509
574438492
664907465
979953874
8529137
613727900

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 373ms
memory: 3696kb

input:

10
1
1100110101011
100111000010011100111101101100110010110000100011110101100100011001101011100011101101110111001101000001110010111001110011100101000111111000010101101100011000010100010101
1111010000010011010010011000010000000001000110111011101100111011100010110011100110011110011011110011110100011001...

output:

1
1146
832402516
402106502
689225542
416112434
991952024
938688647
880733772
630306115

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 380ms
memory: 3684kb

input:

10
1
11000000000111
110010000100100011111101001100111010110111011101101011001001010110101111111101001000000100110011110101100111010110100100010100000100000011100010101011010001100001000111000101000011010110010100000
101001000110100011110100011001010101001010011111010111111001100111111100101111110111...

output:

1
2087
659256442
942088668
754989716
908871865
566839365
111034927
696022638
206335876

result:

ok 10 numbers

Test #15:

score: 0
Accepted
time: 387ms
memory: 3696kb

input:

10
1
111100001011110
101100010011110001000011110010011010011100110010111110100111111111100101100111010101001101111001111010111011011111000111000101101010001100111010100110110000111110100100101000001101111100000101101100010110101000011001110001101
11111110001100110111110110100010111010100010010010010...

output:

1
5612
120730460
903512843
440620378
736669452
35297346
414402862
87146822
461180872

result:

ok 10 numbers

Test #16:

score: 0
Accepted
time: 388ms
memory: 3696kb

input:

10
1
1011110111101110
11111011001101100000000011011111011000101001100010000000001010011110010000100000111100101011101111111111001000110011110000011001000111000010101100001001100111100100000010101101111100100100101110101100000000011101011100010111111010000101011000110010011000
11110011001110110000001...

output:

1
9074
47298040
806126372
607928251
829797230
861514498
6535505
135611721
148853296

result:

ok 10 numbers

Test #17:

score: 0
Accepted
time: 399ms
memory: 3688kb

input:

10
1
11101111010010001
1111011100010101011101000110010001011001010101000100111100010110101010010001100101001001011111101001101100110100100100101101011001100000101011000100001011101000101000110000110100100100001001000011000111000010100011001111111011010001110111101111010011100010110001010010000100001...

output:

1
25268
485539600
497476229
129697011
91489334
354698980
228961474
875061949
618786188

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 408ms
memory: 3668kb

input:

10
1
101101011100110001
100111001100000111101000101110011011011011111101011110101111000010000101010001010110100101001001100010101100101001110110001101101100111111100001000100010010110101110010111101100110010000010001101011001110001001100111101100111010100100000000000010000100101001000110000111100100...

output:

1
38342
769759919
33866310
945890505
127750526
125262837
888967227
757810824
441419016

result:

ok 10 numbers

Test #19:

score: 0
Accepted
time: 415ms
memory: 3896kb

input:

10
1
1001100011010110111
11100110010001111111110100011111100100011011110000110100000111101100111110111010111010111001111111100111011000000101001111000010001100010001111001011000111111001111100100101101011001110011100000111011111110101000111011101101110101101101110101100000011000001001011011100001111...

output:

1
65218
438898572
348219276
776140964
704823526
170625715
198310775
477853700
897436999

result:

ok 10 numbers

Test #20:

score: 0
Accepted
time: 426ms
memory: 3636kb

input:

10
1
11010100111111001011
1000011001001001110110101001100001001101001001010010101010001110011001001000000000110001100110001110110111010100101011011001100101001110111001101101000111101100010110101100101110111101000101111010100110001011110111000110000110110111011101110010010011010001110101010110010000...

output:

1
183823
238142747
846693477
959968477
260267123
642987070
779134130
951392182
679687101

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed