QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#136937 | #2198. Help BerLine | OccDreamer | WA | 2ms | 3560kb | C++14 | 1012b | 2023-08-09 14:20:06 | 2023-08-09 14:20:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10002;
int n;
int p[MAXN], col[MAXN], L[MAXN], R[MAXN];
bool mark[MAXN];
inline void construct(int c, vector<int> now){
if(c==25 || now.size()==0) return ;
for(int i=1;i<=n;++i) mark[i]=0;
for(auto i:now) mark[i]=1; int cur=0; L[0]=R[0]=0;
for(int i=1;i<=n;++i) L[i]=cur, cur=mark[i]?i:cur; cur=0;
for(int i=n;i>=1;--i) R[i]=cur, cur=mark[i]?i:cur;
reverse(now.begin(),now.end()); vector<int> nxt;
for(auto i:now){
if(!mark[i]) nxt.push_back(i);
else{
mark[L[i]]=mark[R[i]]=0; col[i]=c;
R[L[i]]=R[i], L[R[i]]=L[i]; mark[i]=0;
}
}
reverse(nxt.begin(),nxt.end());
construct(c+1,nxt);
return ;
}
inline void solve(){
cin >> n;
for(int i=1;i<=n;++i) cin >> p[i];
vector<int> now; for(int i=1;i<=n;++i) now.push_back(p[i]);
construct(1,now);
for(int i=1;i<=n;++i) cout << col[i] << ' '; cout << endl;
return ;
}
int main(){
int t; cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
5 3 1 3 2 3 1 2 3 1 1 10 6 10 4 2 7 9 5 8 3 1 10 2 4 6 9 1 8 10 5 3 7
output:
3 1 2 1 2 1 1 1 2 1 4 1 2 3 1 2 1 1 3 1 2 1 4 1 2 3 1
result:
ok 5 test case(s)
Test #2:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
50 2 2 1 2 1 2 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 1 2 2 1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