QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#707377 | #1833. Deleting | ship2077 | RE | 1ms | 7940kb | C++23 | 890b | 2024-11-03 15:43:28 | 2024-11-03 15:43:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=4005;
pair<int,int>pos[M*M];
bitset<M>f[M],g[M],vis[M];int n;
void extend(int l,int r){
assert(!f[l][r]);
f[l].set(r);g[r].set(l);
if (vis[l-1][r+1]&&!f[l-1][r+1]) extend(l-1,r+1);
bitset<M>tmp=~f[l]&f[r+1];
for (int i=tmp._Find_first();i!=tmp.size();i=tmp._Find_next(i)) extend(l,i);
tmp=~g[r]&g[l-1];
vector<int>p;
for (int i=tmp._Find_first();i!=tmp.size();i=tmp._Find_next(i)) p.emplace_back(i);
reverse(p.begin(),p.end());for (auto i:p) extend(i,r);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j+=2)
{int x;cin>>x;pos[x]={i,j};}
for (int k=1;k<=(n>>1)*(n>>1);k++){
auto [l,r]=pos[k];vis[l][r]=1;
if (!f[l][r]&&(f[l+1][r-1]||l+1==r)) extend(l,r);
if (f[1][n]) return printf("%d\n",k),0;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7876kb
input:
2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
6 2 1 3 4 5 6 7 8 9
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: -100
Runtime Error
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