QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#66471 | #5015. 树 | Dual | 3 | 34ms | 7736kb | C++ | 2.5kb | 2022-12-08 16:45:47 | 2022-12-08 16:45:50 |
Judging History
answer
#include<bits/stdc++.h>
int ask(int u,std::vector<int>v);
void answer(int u,int v);
const int N = 1e3 + 5;
typedef std::vector<int> Set_nd;
typedef std::pair<Set_nd,int> psi;
#define fi first
#define se second
#define mkp make_pair
int n;
inline int find_rt(Set_nd S)
{
int res = 1e9,k = -1;
for(auto it : S)
{
Set_nd tmp;
for(auto j : S)
if(j != it) tmp.push_back(j);
int val = ask(it,tmp);
if(val < res) res = val,k = it;
}
assert(k != -1);
return k;
}
inline Set_nd find_neighbor(Set_nd S,int rt)
{
Set_nd res,self;self.push_back(rt);
for(auto it : S)
if(it != rt && ask(it,self) == 1) res.push_back(it);
return res;
}
inline void Merge(Set_nd &a,const int &b)
{
a.push_back(b);
}
inline void Add_nd(std::vector<psi> &Sets,int v,int rt)
{
int siz = Sets.size();
Set_nd Srt;Srt.push_back(rt);
int vrt = ask(v,Srt);
int now = -1,nowSrt = 0,nowSv = 0; // sum (S,rt)
int nowsiz = 0;
for(int i = (int)log2(siz);i >= 0;i--)
{
if(now + (1 << i) >= siz) continue;
// now + 1,now + (1 << i)
int nxt = now + (1 << i);
int nxtSv = nowSv;
Set_nd nowS;
for(int j = now + 1;j <= nxt;j++)
Merge(nowS,Sets[j].fi[0]);
nxtSv += ask(v,nowS);
int nxtSrt = nowSrt;
for(int j = now + 1;j <= nxt;j++)
nxtSrt += Sets[j].se;
int nxtsiz = nowsiz;
for(int j = now + 1;j <= nxt;j++)
nxtsiz += Sets[j].fi.size();
if(nxtSv == nxtSrt + nxtsiz * vrt)
{
now = nxt;
nowSv = nxtSv;
nowsiz = nxtsiz;
nowSrt = nxtSrt;
}
}
assert(now + 1 < siz);
// printf("now:%d\n",now + 1);
Sets[now + 1].fi.push_back(v);
Sets[now + 1].se += vrt;
}
void Divide(Set_nd S)
{
if(S.size() < 2) return;
int rt = find_rt(S);
std::vector<int> nei = find_neighbor(S,rt);
for(auto it : nei) answer(rt,it);
std::vector<psi> Sets;
// printf("rt:%d\n",rt);
// for(auto it : nei) printf("%d ",it);
// printf("\n");
for(auto it : nei) { Sets.push_back(mkp(Set_nd(1,it),1));}
static int deled[N];
for(int i = 1;i <= n;i++) deled[i] = 0;
deled[rt] = 1;
for(auto it : nei) deled[it] = 1;
for(auto it : S) if(!deled[it]) Add_nd(Sets,it,rt);
for(auto it : Sets) Divide(it.fi);
}
void Brute(int n)
{
for(int i = 1;i <= n;i++)
for(int j = i + 1;j <= n;j++)
if(ask(i,Set_nd(1,j)) == 1) answer(i,j);
}
void solver(int _n,int A,int B)
{
n = _n;
if(A >= n * (n - 1) / 2 && B >= n * (n - 1) / 2)
{
Brute(n);
return;
}
Set_nd init;
for(int i = 1;i <= n;i++) init.push_back(i);
Divide(init);
}
詳細信息
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 34ms
memory: 7596kb
input:
1000 500000 500000 1 2 2 3 2 4 2 5 2 6 3 7 2 8 5 9 5 10 9 11 2 12 9 13 4 14 5 15 12 16 5 17 4 18 4 19 13 20 9 21 19 22 7 23 6 24 14 25 2 26 10 27 14 28 21 29 17 30 8 31 15 32 9 33 22 34 24 35 20 36 6 37 12 38 19 39 31 40 35 41 25 42 11 43 8 44 9 45 12 46 26 47 10 48 6 49 27 50 39 51 33 52 6 53 43 54...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #2:
score: 0
Accepted
time: 33ms
memory: 7488kb
input:
1000 500000 500000 1 2 1 3 1 4 4 5 1 6 2 7 1 8 2 9 3 10 4 11 5 12 11 13 9 14 13 15 10 16 10 17 8 18 9 19 13 20 19 21 17 22 19 23 23 24 24 25 22 26 18 27 21 28 22 29 26 30 24 31 30 32 23 33 28 34 29 35 32 36 36 37 32 38 35 39 34 40 40 41 40 42 42 43 42 44 40 45 40 46 40 47 46 48 39 49 49 50 48 51 50 ...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #3:
score: 0
Accepted
time: 26ms
memory: 7556kb
input:
1000 500000 500000 498 209 498 647 498 776 498 8 498 382 498 181 498 644 498 331 498 516 498 197 498 630 498 693 498 577 498 572 498 393 498 638 498 94 498 847 498 273 498 535 498 703 498 176 498 605 498 214 498 610 498 416 498 928 498 470 498 753 498 182 498 294 498 514 498 831 498 386 498 935 498 ...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #4:
score: 0
Accepted
time: 29ms
memory: 7596kb
input:
1000 500000 500000 1 2 1 3 1 4 1 5 4 6 4 7 7 8 4 9 3 10 5 11 4 12 9 13 12 14 7 15 14 16 9 17 16 18 9 19 13 20 17 21 17 22 18 23 23 24 23 25 18 26 22 27 18 28 25 29 21 30 29 31 31 32 28 33 32 34 26 35 31 36 27 37 29 38 30 39 33 40 38 41 41 42 42 43 43 44 35 45 41 46 43 47 43 48 47 49 45 50 46 51 42 5...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #5:
score: 0
Accepted
time: 24ms
memory: 7528kb
input:
1000 500000 500000 1 2 1 3 1 4 1 5 2 6 1 7 1 8 1 9 1 10 1 11 1 12 2 13 1 14 2 15 2 16 2 17 1 18 2 19 2 20 2 21 2 22 1 23 1 24 1 25 2 26 2 27 2 28 2 29 2 30 1 31 2 32 1 33 2 34 1 35 1 36 1 37 1 38 2 39 1 40 1 41 1 42 2 43 2 44 1 45 1 46 2 47 1 48 2 49 1 50 2 51 2 52 1 53 1 54 1 55 1 56 1 57 2 58 1 59...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #6:
score: 0
Accepted
time: 26ms
memory: 7440kb
input:
1000 500000 500000 775 723 775 587 775 405 775 383 775 154 775 567 775 561 775 114 775 894 775 79 775 229 775 388 775 165 775 240 775 358 775 287 775 560 775 578 775 220 775 222 775 214 775 86 775 94 775 997 775 531 775 476 775 68 775 838 775 135 775 851 775 478 775 588 775 136 775 689 775 396 775 8...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #7:
score: 0
Accepted
time: 30ms
memory: 7736kb
input:
1000 500000 500000 1 2 1 3 3 4 4 5 4 6 5 7 7 8 8 9 8 10 10 11 10 12 12 13 12 14 13 15 15 16 16 17 16 18 17 19 18 20 20 21 21 22 21 23 23 24 24 25 25 26 25 27 27 28 27 29 29 30 29 31 30 32 31 33 33 34 34 35 34 36 36 37 37 38 38 39 39 40 40 41 41 42 41 43 43 44 44 45 44 46 45 47 47 48 48 49 49 50 50 5...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #8:
score: 0
Accepted
time: 26ms
memory: 7600kb
input:
1000 500000 500000 862 253 862 745 862 416 862 256 862 515 862 821 862 379 862 494 862 820 862 496 862 648 862 766 862 629 862 106 862 926 862 166 862 729 862 989 862 212 862 522 862 787 862 711 862 962 862 969 862 698 862 750 862 585 862 130 862 831 862 760 862 764 862 314 862 972 862 346 862 275 8...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #9:
score: 0
Accepted
time: 24ms
memory: 7540kb
input:
1000 500000 500000 1 2 2 3 3 4 4 5 5 6 6 7 4 8 4 9 5 10 8 11 8 12 3 13 7 14 6 15 6 16 9 17 2 18 1 19 8 20 9 21 8 22 7 23 7 24 5 25 2 26 2 27 3 28 5 29 4 30 9 31 5 32 8 33 1 34 3 35 10 36 7 37 9 38 9 39 9 40 2 41 4 42 6 43 8 44 4 45 10 46 4 47 8 48 9 49 7 50 2 51 5 52 9 53 8 54 1 55 9 56 9 57 9 58 5 ...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Test #10:
score: 0
Accepted
time: 31ms
memory: 7444kb
input:
1000 500000 500000 164 875 164 558 164 722 164 171 164 780 164 498 164 795 164 332 164 1000 164 553 164 354 164 479 164 109 164 802 164 706 164 236 164 958 164 607 164 757 164 197 164 11 164 507 164 572 164 357 164 314 164 653 164 15 164 814 164 9 164 468 164 398 164 232 164 753 164 591 164 478 164 ...
output:
areawavesuitbannerresortfatplasterdeclarationthesearejustrandomwords
result:
ok Orz..Orz..Orz..Orz..Orz
Subtask #2:
score: 0
Dangerous Syscalls
Test #11:
score: 0
Dangerous Syscalls
input:
100 3000 40000 66 95 66 60 66 93 66 69 66 82 66 24 66 64 66 84 66 42 66 22 66 67 66 54 66 90 66 26 66 41 66 18 66 43 66 68 66 36 66 88 66 33 66 29 66 79 66 6 66 48 66 47 66 8 66 38 66 61 69 97 64 30 38 86 88 14 18 10 54 81 88 25 29 2 18 21 95 46 42 80 93 91 61 62 68 35 47 23 69 17 93 28 18 31 61 70 ...
output:
Unauthorized output
result:
Subtask #3:
score: 0
Wrong Answer
Test #111:
score: 0
Wrong Answer
time: 29ms
memory: 7652kb
input:
1000 50000 3000000 126 207 937 126 615 937 837 615 500 837 588 500 505 588 353 505 60 353 904 60 656 904 685 656 460 685 614 460 551 614 537 551 858 537 596 858 9 596 738 9 918 738 322 918 940 322 859 940 113 859 110 113 312 110 995 312 443 995 246 443 257 246 238 257 999 238 885 999 976 885 330 976...
output:
The sum is too large
result:
wrong answer Wrong Answer
Subtask #4:
score: 0
Wrong Answer
Test #211:
score: 0
Wrong Answer
time: 10ms
memory: 7656kb
input:
990 8500 300000 1 2 1 3 1 4 1 5 2 6 2 7 2 8 3 9 3 10 3 11 4 12 4 13 4 14 5 15 5 16 5 17 6 18 6 19 6 20 7 21 7 22 7 23 8 24 8 25 8 26 9 27 9 28 9 29 10 30 10 31 10 32 11 33 11 34 11 35 12 36 12 37 12 38 13 39 13 40 13 41 14 42 14 43 14 44 15 45 15 46 15 47 16 48 16 49 16 50 17 51 17 52 17 53 18 54 18...
output:
The sum is too large
result:
wrong answer Wrong Answer