QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212907 | #6824. Demonstrational Sequences | nameless_story# | WA | 2550ms | 55412kb | C++23 | 2.0kb | 2023-10-13 22:39:20 | 2023-10-13 22:39:21 |
Judging History
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=7e3+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;
int m=v.size();
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 274ms
memory: 40692kb
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: 423ms
memory: 40632kb
input:
998244352 1048576 3 2022 924 12345678 1234567 23333333 6666666
output:
001
result:
ok "001"
Test #3:
score: 0
Accepted
time: 150ms
memory: 40828kb
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: 1560ms
memory: 40452kb
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: 116ms
memory: 40628kb
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: 1478ms
memory: 43964kb
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: 1397ms
memory: 47604kb
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: 1406ms
memory: 47820kb
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: 953ms
memory: 48648kb
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: 1373ms
memory: 40524kb
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: 1566ms
memory: 47652kb
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: 1454ms
memory: 48408kb
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: 1450ms
memory: 51296kb
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: 1389ms
memory: 49472kb
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: 1479ms
memory: 49276kb
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: 1572ms
memory: 47648kb
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: 1376ms
memory: 48152kb
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: 1416ms
memory: 47816kb
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: 2044ms
memory: 44516kb
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: 1386ms
memory: 47472kb
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: 0
Accepted
time: 1774ms
memory: 47516kb
input:
1083823682 23279 200 15684325431962405523 8433681852070775172 13474426459209495616 14174875513409449648 8910528620974308970 5706618201119690706 15123310027645592100 6520493119264402856 387169615810312407 11180278887031580439 7555818783786929613 12530167364525789491 5393562328341960198 13003070727899...
output:
00000100000000101101000000010000000001000000000000000000110000110100010000010000010110100110000001000100001000000011011000001010011000100010000111100000010000000000000110000101000000000111010000000010
result:
ok "000001000000001011010000000100...0000101000000000111010000000010"
Test #22:
score: 0
Accepted
time: 1359ms
memory: 47020kb
input:
387577969 19687 200 15372426147163411219 5533655081692008550 12366647130381390567 1929712314927021928 3698590470448574409 17082153170721925025 17043770277665394548 11544205145567850411 8833626130870834697 16349640329478100713 11064619395500248796 8424182672569001542 13851977029140956580 744606090060...
output:
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
result:
ok "111111111111111111111111111111...1111111111111111111111111111111"
Test #23:
score: 0
Accepted
time: 2550ms
memory: 43976kb
input:
3873713627 821 200 15097926161850338475 12917426832373376135 3905980799756616689 14457241018068418368 18172209998508976472 14822340141588079319 13834857856171537284 8092811627217260600 1001106932892283142 11826088602133344322 12565574611432283200 4348855760755314480 14605575407312502987 176296965657...
output:
10011001001000000001101000100100000100000001110001001011011101101110000010001100101011100000010000101000010111111000101110101111110000011000100001001011000101100000000110100001000110100110001001001001
result:
ok "100110010010000000011010001001...0100001000110100110001001001001"
Test #24:
score: 0
Accepted
time: 1822ms
memory: 48300kb
input:
2021777520 661360 200 15448990377516076779 1894682813497359207 4922599530336199882 14319640974834563699 10329605818550988115 4527978983734524729 8815422014494239657 14516182262530802534 15097324708387555512 12522765761101598507 8484295737234258755 12943644486890448790 17313357466267995391 1519909507...
output:
00010000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000010000000000000000010000000000000010001001000000000010000000000000000000000
result:
ok "000100000000000100000000000000...0000000010000000000000000000000"
Test #25:
score: 0
Accepted
time: 1559ms
memory: 48760kb
input:
1458808611 121537 200 12301959097406854291 17040979541212692069 8109151868531013993 9578352332332451940 4399912382605787515 4144896932039778431 15585646174745758191 11471751162068477474 13102521344487328091 17230194456269630836 2631404103104586329 3137628700358173535 16690112367778128646 15430696922...
output:
00100100000010000000000000010000000000100000000000000000000000000000000101001000000000010000000000100001000010000101000000000000000100000000000001000000000000000000000000000010000000000000110000001000
result:
ok "001001000000100000000000000100...0000010000000000000110000001000"
Test #26:
score: 0
Accepted
time: 2204ms
memory: 48024kb
input:
1028918016 150912 200 11437220167161122003 11957365594153618951 4562131823660465785 14943420548063690592 6168895836742028285 18003015929279314973 8970760782325363774 9956774643011890103 13813446810769728541 14854656819702084923 14121676957325194608 11438577852354655419 15598215988433002420 505822436...
output:
00000000001000001000100000000000000000000000000000000100000010000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000000000000000001000000000000000000010000000000000
result:
ok "000000000010000010001000000000...0000000000000000010000000000000"
Test #27:
score: 0
Accepted
time: 1461ms
memory: 49200kb
input:
3955638000 659273 200 1541809018270831763 12435252225506364273 15813538637927478957 1269661392732180280 18200755976468154638 15331562299291664712 13847017599410591632 17162774197401758848 7244421820033633426 6321106656332489175 16151171859262761977 14898981009533086747 11156556305507205494 624741790...
output:
00000000000000000000000000000000000000000000000000000000000000000010000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000
result:
ok "000000000000000000000000000000...0000000000000000000000000000000"
Test #28:
score: 0
Accepted
time: 1550ms
memory: 49780kb
input:
4148117169 443317 200 6726735868060414235 15429717590626717962 7632224404764345485 13181278096699277493 15037429980634344550 17556680482793996319 1577417026056943313 4475190502037150518 3022903162757614279 8239097518711596720 16159478423230940905 14244085246638843116 7726617819656179405 348765853358...
output:
00000101000000100000000000000000000110100100000000000000010000000100011000000000001000000010000000000010000000000010000010000000000100010000000100000001001000100100000100000000000100010100100000000000
result:
ok "000001010000001000000000000000...0000000000100010100100000000000"
Test #29:
score: 0
Accepted
time: 1434ms
memory: 49220kb
input:
3745074312 303294 200 6154847130053399211 7666081901670843350 8372441669352281164 14860597039340508768 7429714926365835105 13673323545778730730 17811209799170882570 12225556040954985031 402729822891481921 8930426810727069876 6307000249348832614 9895848309746534191 16653476027348064386 15420231002837...
output:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
result:
ok "000000000000000000000000000000...0000000000000000000000000000000"
Test #30:
score: -100
Wrong Answer
time: 1512ms
memory: 55412kb
input:
3562804797 571787 200 5861035115335045851 7488324874273849974 11936435189281307001 10191770578884071596 8193159155317745124 12074746786315026732 1570816078908708388 16369341365959367558 4154734727612074794 9416572685323813346 2327130396162490448 17615786408483273317 16576389478255696318 167268024351...
output:
00000000000000000000100100000000000000000000000000000000100000000000000000000100101010000000000000000000000000000000000000000100010000000000000000000000000011000000000100000000100000000000000000001000
result:
wrong answer 1st words differ - expected: '000000000000000100001001000010...0000000100000001000000000001001', found: '000000000000000000001001000000...0000000100000000000000000001000'