QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417568 | #1833. Deleting | Harry27182 | WA | 2ms | 12104kb | C++14 | 2.0kb | 2024-05-22 19:46:16 | 2024-05-22 19:46:16 |
Judging History
answer
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int n,ok[4005][4005],x;pair<int,int>p[4000005],st[4005];ull num[64];
struct Bitset
{
ull val[75];
int get(int x){return (val[x/64]>>(x&63))&1;}
void upd(int x){val[x/64]^=(1llu<<(x&63));}
int _Find_first()
{
for(int i=0;i<=n/64;i++)
{
if(!val[i])continue;
return __builtin_ctzll(val[i])+i*64;
}
return n+1;
}
int _Find_next(int x)
{
int p=x/64,q=x&63;
if(val[p]&num[q])return __builtin_ctzll(val[p]&num[q])+p*64;
for(int i=p+1;i<=n/64;i++)
{
if(!val[i])continue;
return __builtin_ctzll(val[i])+i*64;
}
return n+1;
}
}L[4005],R[4005],nL[4005],nR[4005];
Bitset operator &(Bitset x,Bitset y)
{
Bitset res;
for(int i=0;i<=n/64;i++)res.val[i]=x.val[i]&y.val[i];
return res;
}
void insert(int l,int r)
{
if(l-1>=1&&r+1<=n&&ok[l-1][r+1]&&!L[l-1].get(r+1))
{
L[l-1].upd(r+1);R[r+1].upd(l-1);nL[l-1].upd(r+1);nR[r+1].upd(l-1);
insert(l-1,r+1);
}
Bitset now=R[l-1]&nR[r];int top=0;
for(int i=now._Find_first();i<=n;i=now._Find_next(i))
{
L[i].upd(r);R[r].upd(i);nL[i].upd(r);nR[r].upd(i);
st[++top]={i,r};
}
for(int i=1;i<=top;i++)insert(st[i].first,st[i].second);
now=L[r+1]&nL[l];top=0;
for(int i=now._Find_first();i<=n;i=now._Find_next(i))
{
L[l].upd(i);R[i].upd(l);nL[l].upd(i);nR[i].upd(l);
st[++top]={l,i};
}
for(int i=1;i<=top;i++)insert(st[i].first,st[i].second);
}
int solve(int l,int r)
{
ok[l][r]=1;
if((l+1==r||L[l+1].get(r-1))&&(!L[l].get(r)))
{
L[l].upd(r);R[r].upd(l);nL[l].upd(r);nR[r].upd(l);
insert(l,r);
}
return L[1].get(n);
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin>>n;
for(int i=0;i<64;i++)
{
for(int j=i+1;j<64;j++)num[i]|=(1llu<<j);
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)nL[i].upd(j),nR[i].upd(j);
}
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j+=2)cin>>x,p[x]={i,j};
}
for(int i=1;i<=(n/2)*(n/2);i++)
{
if(solve(p[i].first,p[i].second)){cout<<i;return 0;}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 9888kb
input:
2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 9760kb
input:
6 2 1 3 4 5 6 7 8 9
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 11948kb
input:
10 20 21 2 11 25 3 24 18 8 6 17 7 5 22 4 23 14 15 1 19 16 12 10 13 9
output:
14
result:
ok 1 number(s): "14"
Test #4:
score: 0
Accepted
time: 1ms
memory: 11864kb
input:
16 49 48 18 41 52 64 4 6 22 20 32 50 56 36 9 3 1 27 58 51 35 40 61 43 38 12 7 34 8 59 39 25 46 16 44 29 15 17 24 10 47 2 57 62 14 5 23 33 30 45 19 60 63 28 13 54 55 26 53 31 11 42 21 37
output:
30
result:
ok 1 number(s): "30"
Test #5:
score: 0
Accepted
time: 1ms
memory: 9916kb
input:
20 91 19 90 92 5 41 15 50 18 36 97 8 23 74 53 67 83 40 26 4 16 31 82 80 28 49 6 21 58 63 70 34 27 89 68 20 55 100 35 77 52 24 11 87 94 13 66 1 32 54 86 60 79 75 93 45 73 2 48 72 12 37 29 95 56 17 44 84 30 22 14 65 76 69 62 47 78 7 57 42 39 61 99 81 88 25 98 59 85 38 10 33 51 71 64 46 43 3 96 9
output:
54
result:
ok 1 number(s): "54"
Test #6:
score: 0
Accepted
time: 2ms
memory: 12104kb
input:
100 750 481 1065 911 1943 427 1633 45 1841 234 1376 1075 1603 1682 1581 1284 28 5 1567 1540 2409 1430 695 667 1246 392 1183 1090 594 1481 524 2023 354 778 584 827 1516 796 1675 1829 189 1688 706 1679 1483 1010 1209 1393 399 210 40 149 1040 351 1435 320 340 577 898 449 1896 224 2168 1456 1222 1216 19...
output:
1289
result:
ok 1 number(s): "1289"
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 10052kb
input:
100 561 1112 852 529 2112 323 265 2038 1970 1681 556 2261 887 277 1171 553 1887 48 2432 266 1304 1764 853 2205 2320 1532 571 1870 193 544 1135 874 2132 1162 102 2179 2307 2068 1990 1111 2420 2077 1779 2000 1996 2297 1981 450 1091 992 140 2474 744 537 42 1051 1086 1685 1307 1282 2387 167 31 1179 301 ...
output:
1098
result:
wrong answer 1st numbers differ - expected: '1082', found: '1098'