QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212903#6824. Demonstrational Sequencesnameless_story#TL 2220ms76568kbC++231.9kb2023-10-13 22:34:252023-10-13 22:34:25

Judging History

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

  • [2023-10-13 22:34:25]
  • 评测
  • 测评结果:TL
  • 用时:2220ms
  • 内存:76568kb
  • [2023-10-13 22:34:25]
  • 提交

answer

#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
template<class T1,class T2> bool cmax(T1 &x,const T2 &y) { if (x<y) { x=y; return 1; }return 0; }
#define all(x) (x).begin(),(x).end()
const ll N=1e7+2,M=3e4+5,NN=3e5+5,Q=1<<20|5;
bool ed[N];
ll c[NN+1];
mt19937 rnd(235);
vector<int> buc[Q];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cout<<fixed<<setprecision(15);
	ll p,q,i,j;
	int T;
	cin>>p>>q>>T;
	p/=q;
	map<pair<ll,ll>,int> ans;
	for (i=0; i<N; i++) if (gcd(i,p)==1) ed[i]=1;
	p*=q;
	// assert(ed[2]);
	while (T--)
	{
		auto cal=[&]()
			{
				ll a,b,d,dmq;
				int tot=1e6,i,j;
				for (i=0; i<q; i++) buc[i].clear();
				cin>>a>>b;
				// a=2022;b= 924;
				a%=p; b%=p;
				if (ans.count({a,b})) return ans[{a,b}];
				c[0]=a;
				for (i=1; i<=NN; i++) c[i]=(c[i-1]*c[i-1]+b)%p;
				shuffle(c+5000,c+NN+1,rnd);
				// cerr<<c[0]<<' '<<c[3]<<' '<<q<<endl;
				vector<ll> occ;
				for (i=0; i<=M; i++) occ.push_back(c[i]%q);
				sort(all(occ)); occ.resize(unique(all(occ))-occ.begin());
				for (ll x:occ) buc[x].clear();
				for (i=0; i<=M; i++) buc[c[i]%q].push_back(c[i]/q);
				// cerr<<occ.size()<<endl;
				for (ll x:occ)
				{
					auto &v=buc[x];
					// if (x==1) cerr<<v[0]<<' '<<v[1]<<endl;
					sort(all(v));
					int m=unique(all(v))-v.begin();
					if (m!=v.size()&&ed[0]) return ans[{a,b}]=1;
					v.resize(m);
					// if (x==1) assert(count(all(v),0)&&count(all(v),2));
					// cerr<<x<<endl;
					for (i=0; i<m; i++)
					{
						// cerr<<i<<endl;
						for (j=i-1; j>=0; j--)
						{
							// if (x==1&&i==1&&j==0) cerr<<i<<' '<<j<<endl;
							if (v[i]-v[j]<N&&ed[v[i]-v[j]]) return ans[{a,b}]=1;
							// if (v[j]-v[i]<N&&ed[v[j]-v[i]]) return ans[{a,b}]=1;
							// if (v[i]+pq-v[j]<N&&ed[v[i]+pq-v[j]]) return ans[{a,b}]=1;
						}
						// tot-=min<int>(tot,i-1);
					}
				}
				return ans[{a,b}]=0;
			};
		cout<<cal();
	}
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 237ms
memory: 40932kb

input:

15 5 5
1 1
1 2
2 4
4 8
8 16

output:

11010

result:

ok "11010"

Test #2:

score: 0
Accepted
time: 396ms
memory: 40860kb

input:

998244352 1048576 3
2022 924
12345678 1234567
23333333 6666666

output:

001

result:

ok "001"

Test #3:

score: 0
Accepted
time: 155ms
memory: 42484kb

input:

100237 100237 10
1244422970085542683 6256585832417115176
11178595626727644735 679276059713497324
5646838801370008540 6709514788466664568
9971158657914728691 8724448042786063799
9867649407902336110 2614925263502318093
1990105069810770727 8671216841234378816
7965667786524489724 6722337513023700570
246...

output:

1111111111

result:

ok "1111111111"

Test #4:

score: 0
Accepted
time: 1962ms
memory: 40520kb

input:

1000000007 1 200
1244424352052424851 13102057264748565738
10964128241743967010 11238647915096906960
9602909082986968021 14247804011443894396
13231275623402659328 11122445945926639224
1819715673773979255 15011227386780949150
10389668459305004672 13595253579372877142
136927098471150438 141908708541553...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #5:

score: 0
Accepted
time: 112ms
memory: 40504kb

input:

1 1 200
1244422970079336291 4707347560601392081
16633665001192110076 15773758607538398243
11070497290011093392 11929979209055974561
8355738147346006300 6479245221430563815
10109334084151275293 11867087657669754231
17442584295523326999 11181890936205849132
9065910826445511105 4364106058213150008
3158...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #6:

score: 0
Accepted
time: 1645ms
memory: 56776kb

input:

1829276567 1223 200
1244422970077270675 3806627635127557106
13984072790700162529 11560843058580181248
18218320506679528544 11095342096011758221
4400021764111680243 2513593206800052431
18199847053143773541 12194057128449124778
13449463383710867755 15111229049249507634
9142159878193341647 851735763810...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #7:

score: 0
Accepted
time: 1597ms
memory: 69724kb

input:

1916775961 43781 200
1244422991562533611 2581648536462341184
10846740824576506379 9993690399888017205
8345302117372117052 12258730889585496219
6487130277971010241 11996418174856728756
8151541988194450093 17962020692109166031
5265702935744667861 3426174342122309619
3337825504340444832 108442264083652...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #8:

score: 0
Accepted
time: 1597ms
memory: 70476kb

input:

1992104689 44633 200
1244423004569553187 708151091329533332
9122468538725959348 6266937734283537059
17378118143373524488 14143033550582754474
9766586826768167785 1594616520143492866
734438740803221400 11158266026263179425
460036223567287536 4242791159789103332
17830443150457246178 422414602667113372...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #9:

score: 0
Accepted
time: 1071ms
memory: 72016kb

input:

200474 100237 200
1244422970085542683 6256585832417115176
11178595626727644735 679276059713497324
15646838801370008540 16709514788466664568
9971158657914728691 8724448042786063799
9867649407902336110 2614925263502318093
1990105069810770727 8671216841234378816
17965667786524489724 6722337513023700570...

output:

00000000111111010001100001000000010001111000110000000010001010010000100001001001010100100011010000100000100110100000000000001000000010000000000000000000000100010000010000001000000010000000010110000000

result:

ok "000000001111110100011000010000...0001000000010000000010110000000"

Test #10:

score: 0
Accepted
time: 1598ms
memory: 40788kb

input:

200474 2 200
1244422970290369323 10652099068730767710
8319150041957358027 4252860857770083514
2283720720491098640 10687885864933740120
2825325290598596007 6440406404796000441
6950945943062257465 15095351257240999518
2718104921152369583 1084988046635922392
16727496739401426409 4394616015239803414
169...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #11:

score: 0
Accepted
time: 1658ms
memory: 70664kb

input:

4263743276 45077 200
1623855933086673195 1394720197804715148
594107206097182228 18010286562889463890
9232604372259259000 11733065843529966425
5391787691872768215 17960957873981251752
3586770739608645055 9993896394458670052
13988642877924042007 4434275232993882359
17191799348415529968 309677586807292...

output:

00000000000000000001000000000100000000000000000000000000000000000000000000000000000000000010010000000000000000100000000000000000000000100000000000000010000001000000000000100000000000000000000000000000

result:

ok "000000000000000000010000000001...0100000000000000000000000000000"

Test #12:

score: 0
Accepted
time: 1579ms
memory: 70420kb

input:

2243653896 79427 200
7085613735056938731 7108859055092139649
5695922196596095831 16949890178661708151
990145800953174351 16245094806650297114
14882674693247816808 11363366359950489284
7394995576056186215 2589960776998221148
8800920093793606635 1967301338500188756
8024931924200017420 2272503502062228...

output:

00000000010000000000000100000000000000010000000000000000000000000000010000000000001100001000000000000000000000000000000001001000000000000000000000000000000000000000000000010000000000000000000000000000

result:

ok "000000000100000000000001000000...0010000000000000000000000000000"

Test #13:

score: 0
Accepted
time: 1706ms
memory: 76568kb

input:

2890356642 644881 200
3338746092145011427 2383740701170010876
2950669909698463161 11412658585846770980
9581681182959202729 12394854403860355917
11974501157757355058 11637902927865695413
17106521716400010010 10095864596609543535
17286559350838320107 9093692469284348154
7890467507278881429 33121849106...

output:

00000000000100000000000000000000000000000000000010000000100000000000001000000000000000001000000000000000000000000000010000000100101000001100000010000000000000000000000000000000000000000000100000000000

result:

ok "000000000001000000000000000000...0000000000000000000100000000000"

Test #14:

score: 0
Accepted
time: 1591ms
memory: 73608kb

input:

1800396632 214129 200
11981151872260927763 880061793948709214
3421011936831395463 12066611705686951714
16269052760398633712 17446962064910375058
16831508813820937321 11050585060190750711
16932844042935971401 12586068229506586939
11411308914722614205 1200292887132725511
10614703641719321462 232217329...

output:

00000000000000110011100000011001111000000010100000100000100000000000000100000000001100010100000110100000000000101000010110000000001001011100001010000010010000100000001001100000000001000001001100011001

result:

ok "000000000000001100111000000110...1100000000001000001001100011001"

Test #15:

score: 0
Accepted
time: 1713ms
memory: 73528kb

input:

3015370282 183439 200
10761746441729398571 10660863783446868085
15532810238104375115 13584557295679235643
14578065710103350759 8400985091796697052
4806777690723159905 16714839711297371203
11465540402873333574 18426053423616298971
9490365436480928555 5683725064365786074
14141155268528021944 164781404...

output:

00001000001101000100000001101010001100000011000001010000001000000010000000000000000000100000111000011001001000110110010000000010000000001000110000011001100100000001000000001010000010000000001100100010

result:

ok "000010000011010001000000011010...0001010000010000000001100100010"

Test #16:

score: 0
Accepted
time: 1758ms
memory: 69696kb

input:

3010226974 38669 200
6229984487236849875 11253164618458158674
933313251596761837 1457608186440777540
8513825683200214409 13042665712294984385
18021434368478935104 3106051298410513939
1337957873492806031 448188000892022312
13559383547127008999 16444342020353803624
4597962444641028423 1395535421245956...

output:

00010011100011010000000100001101000000000010010010001100011101000000100000100001000000000010001000000000110000000001010001000000100100000100110011000001000100101100010000100000010001010000000001100000

result:

ok "000100111000110100000001000011...0100000010001010000000001100000"

Test #17:

score: 0
Accepted
time: 1550ms
memory: 72112kb

input:

1450829397 42297 200
6464188415006582995 11847378626214233168
653828387714095807 1218528646888160694
9535608027473123576 17725435475406126307
4897155301533237423 4497784468643482629
11607442738206304415 3888984380003188830
16998045123593285245 1598115408300503068
16427243992592303185 108623216376898...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #18:

score: 0
Accepted
time: 1620ms
memory: 70604kb

input:

3993730999 49991 200
1267318159762658987 7715736912746720613
5920633216638164008 15462566246494141501
309088298903197057 5711099583701730195
3275208114722011420 17078263693717899931
6260119956203597146 3063344796794825513
9971648571282262294 5905459163695299822
10163673657705786070 19586838804521803...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #19:

score: 0
Accepted
time: 2220ms
memory: 58908kb

input:

3399695197 1597 200
12282764110292219667 10175223850747253213
914573822088598428 2054057241588998809
14020233737663310879 4931899672104815644
14585912693978503289 5764197171383996112
11319683079831828418 7598099624679204821
3689119258925368769 12599506557859798103
8159966522050345775 177314940106366...

output:

00000010011000011011010100100101100000100111100001101110001000100000101100001010000001001001001101111011011010111000100101100010100010000011100000001111001111000010001010010010111010101000011100111111

result:

ok "000000100110000110110101001001...0010010111010101000011100111111"

Test #20:

score: 0
Accepted
time: 1578ms
memory: 69192kb

input:

1385551729 37223 200
11985738725601399011 15618131115372441874
7187824000244420906 3642469162490901854
3614598898017923139 14027809809889791621
6205661285095565811 2922193180403985702
10103090459850640319 17015700717628021588
8177288862893080837 435447560914914078
197949395414949229 4001069487946731...

output:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #21:

score: -100
Time Limit Exceeded

input:

1083823682 23279 200
15684325431962405523 8433681852070775172
13474426459209495616 14174875513409449648
8910528620974308970 5706618201119690706
15123310027645592100 6520493119264402856
387169615810312407 11180278887031580439
7555818783786929613 12530167364525789491
5393562328341960198 13003070727899...

output:

00000100000000101101000000010000000001000000000000000000110000110100010000010000010110100110000001000100001000000011011000001010011000100010000111100000010000000000000110000101000000000111010000000010

result: