QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#478708 | #4929. Longest Unfriendly Subsequence | rr | 0 | 37ms | 23348kb | C++14 | 1.4kb | 2024-07-15 10:27:15 | 2024-07-15 10:27:16 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t,n;
const int N=3e5+10;
int a[N];
int f[N][5];
int pre[N][10];
int b[10];
int siz[N];
struct aa{
int val,id;
int zdz,cdz;
int zdid,cdid;
};
void prt(aa x){
cout<<x.id<<" "<<x.val<<" "<<x.zdid<<" "<<x.zdz<<" "<<x.cdid<<" "<<x.cdz<<endl;
}
aa dp[10];
int main(){
cin>>t;
while(t--){
for(int i=0;i<=n;i++)
for(int j=0;j<=5;j++)
f[i][j]=1;
int maxans=1;
cin>>n;
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
b[5]=1;
for(int i=2;i<=n;i++){
for(int j=1;j<=5;j++){
if(!b[j])continue;
int x=b[j];
if(a[x]==a[i])continue;
siz[i]++;
pre[i][siz[i]]=x;
f[i][siz[i]]=1;
for(int k=0;k<=siz[x];k++){
if(a[pre[x][k]]==a[i])continue;
f[i][siz[i]]=max(f[i][siz[i]],f[x][k]+1);
// cout<<i<<" "<<siz[i]<<" "<<f[i][siz[i]]<<endl;
maxans=max(maxans,f[i][siz[i]]);
}
}
int flag=0,f2=0;
for(int j=1;j<=5;j++){
// cout<<b[j]<<" ";
if(a[b[j]]==a[i]){
b[j]=i;
flag=1;
// break;
}
if(b[j]==0){
f2=j;
}
}
// puts("");
if(!flag)b[1]=i;
sort(b+1,b+1+5);
}
for(int i=1;i<=5;i++)b[i]=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=5;j++)
pre[i][j]=siz[i]=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=5;j++)
f[i][j]=0;
cout<<maxans<<endl;
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 20ms
memory: 23348kb
input:
1 200000 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 2...
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 24ms
memory: 23288kb
input:
1 200000 1521 1638 11981 18811 20091 22081 30494 31501 42139 42282 48197 55520 57632 69584 81745 85026 90303 91482 92176 98507 108061 108743 111257 121226 127217 127449 137116 163474 169192 175764 181243 185402 191244 198775 202845 212156 217723 220058 223478 224205 227614 228398 230425 232567 24480...
output:
198858
result:
ok single line: '198858'
Test #3:
score: -3
Wrong Answer
time: 21ms
memory: 21128kb
input:
1 200000 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 222796328 2...
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 6
Accepted
time: 1ms
memory: 7772kb
input:
3 5 1 2 1 2 1 7 1 2 3 2 1 2 3 8 1 10 10 1 1 100 100 1
output:
2 6 4
result:
ok 3 lines
Test #16:
score: 0
Accepted
time: 31ms
memory: 5676kb
input:
28653 6 372076545 832760265 372076545 644300403 644300403 644300403 8 540046638 375129642 863244619 863244619 375129642 540046638 540046638 540046638 6 142783193 508154499 871683432 71368434 871683432 871683432 8 760894385 984189193 760894385 323542350 984189193 760894385 323542350 323542350 6 84093...
output:
3 4 4 6 4 4 3 4 5 4 5 4 2 4 5 5 4 3 5 5 4 4 4 5 6 4 2 3 4 3 2 3 4 3 8 4 5 5 4 6 4 5 5 5 4 6 6 4 3 3 7 5 3 7 3 4 6 6 5 4 3 3 6 3 6 4 3 4 4 7 3 4 5 4 5 1 3 6 4 4 4 4 2 3 4 2 5 3 4 2 2 3 4 3 6 3 5 3 4 5 3 3 4 4 5 3 5 4 4 6 5 6 6 4 5 4 5 5 3 4 3 4 4 2 4 4 6 5 4 3 3 2 3 5 4 5 3 3 4 7 4 5 5 2 5 2 4 4 5 4 ...
result:
ok 28653 lines
Test #17:
score: 0
Accepted
time: 24ms
memory: 5860kb
input:
27269 6 959945170 761436985 26703386 942397980 959945170 26703386 8 547832867 143323747 65089190 143323747 768500236 65089190 143323747 768500236 5 858824238 403652496 456662012 403652496 361827479 7 434065011 434065011 434065011 217272832 959441476 434065011 441896572 7 436828348 383866500 43682834...
output:
6 7 4 5 3 4 6 4 4 4 6 6 4 5 4 5 5 5 4 4 2 5 5 4 5 3 5 4 7 2 4 7 7 6 3 6 4 6 6 4 5 5 5 4 2 3 6 4 4 5 4 5 5 2 4 5 4 5 5 4 5 7 5 3 4 4 6 4 6 3 4 6 3 5 5 5 5 3 6 6 4 2 5 5 7 5 4 6 4 5 3 3 3 4 5 3 5 4 4 4 4 4 5 5 3 5 5 8 5 4 4 3 3 4 6 3 7 6 2 8 5 4 5 5 3 4 4 6 3 5 5 3 6 6 5 5 5 6 7 5 6 4 4 5 5 3 2 6 6 4 ...
result:
ok 27269 lines
Test #18:
score: -6
Wrong Answer
time: 37ms
memory: 9772kb
input:
24412 6 37652408 37652408 731951637 684367047 944732733 37652408 6 699823488 800701256 800701256 168169055 800701256 699823488 7 198445595 198445595 25271422 198445595 61301798 198445595 432743062 6 942430095 168670839 942430095 570524923 942430095 570524923 6 500326576 65482727 500326576 809311072 ...
output:
4 4 5 4 4 5 5 5 4 4 6 3 4 5 6 3 5 5 6 5 5 4 6 6 7 5 6 6 5 4 7 4 5 2 5 4 4 6 5 6 6 4 6 5 4 6 6 4 5 7 5 6 5 4 4 5 6 5 4 3 5 5 4 3 5 5 5 6 2 3 5 4 3 5 5 6 3 4 6 5 5 6 5 6 5 4 3 7 6 5 4 3 5 3 6 5 6 4 5 5 7 5 5 4 5 4 7 6 6 4 4 3 4 4 4 4 5 5 4 5 5 2 5 5 5 4 4 6 6 3 6 4 4 6 6 6 5 3 4 4 4 5 4 5 3 4 4 4 7 6 ...
result:
wrong answer 1st lines differ - expected: '5', found: '4'
Subtask #3:
score: 0
Wrong Answer
Test #19:
score: 8
Accepted
time: 1ms
memory: 7708kb
input:
1 500 537076440 691668159 871942500 537076440 537076440 691668159 871942500 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 871942500 537076440 691668159 871942500 537076440 537076440 6916...
output:
361
result:
ok single line: '361'
Test #20:
score: 0
Accepted
time: 0ms
memory: 7864kb
input:
1 500 584142119 101442702 335815880 584142119 101442702 335815880 584142119 101442702 335815880 584142119 101442702 335815880 584142119 101442702 101442702 335815880 335815880 584142119 584142119 101442702 101442702 335815880 584142119 101442702 335815880 584142119 101442702 335815880 584142119 1014...
output:
394
result:
ok single line: '394'
Test #21:
score: 0
Accepted
time: 0ms
memory: 5764kb
input:
1 500 296341737 806184542 989331127 989331127 296341737 806184542 455929030 296341737 806184542 806184542 806184542 989331127 296341737 806184542 989331127 296341737 806184542 989331127 296341737 806184542 989331127 296341737 806184542 806184542 989331127 296341737 296341737 296341737 806184542 9893...
output:
339
result:
ok single line: '339'
Test #22:
score: 0
Accepted
time: 0ms
memory: 7900kb
input:
1 500 361183277 863317163 788070566 361183277 361183277 863317163 788070566 361183277 632739493 788070566 788070566 361183277 863317163 788070566 361183277 863317163 788070566 361183277 863317163 788070566 361183277 863317163 788070566 361183277 863317163 788070566 361183277 863317163 788070566 3611...
output:
353
result:
ok single line: '353'
Test #23:
score: -8
Wrong Answer
time: 0ms
memory: 7752kb
input:
1 500 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 575516781 360892412 146618517 5755...
output:
422
result:
wrong answer 1st lines differ - expected: '423', found: '422'
Subtask #4:
score: 0
Wrong Answer
Test #79:
score: 10
Accepted
time: 14ms
memory: 21216kb
input:
1 200000 1 3 3 2 2 3 3 1 2 3 1 1 3 3 3 2 1 1 2 3 2 1 3 3 3 1 2 2 1 3 1 2 1 2 3 2 3 3 2 2 3 2 3 2 3 1 1 1 1 1 3 1 3 2 3 3 3 3 1 3 2 1 3 2 3 2 3 1 1 1 1 3 3 2 3 2 1 2 2 3 2 3 2 2 2 2 2 2 3 2 1 2 2 1 1 3 2 1 2 1 1 3 3 3 2 1 2 2 2 1 3 3 2 3 2 1 3 3 2 2 1 3 1 3 2 1 2 3 2 1 2 3 2 2 3 2 1 2 1 1 1 1 1 1 1 3...
output:
66691
result:
ok single line: '66691'
Test #80:
score: -10
Wrong Answer
time: 9ms
memory: 20076kb
input:
1 200000 2 2 3 3 3 2 1 2 1 1 1 3 3 2 3 3 1 3 2 3 3 3 2 1 2 2 2 2 1 1 2 2 1 3 1 3 1 3 3 1 2 1 1 2 1 1 2 1 1 1 1 2 2 1 3 2 3 3 2 3 2 3 1 1 1 1 2 3 1 2 1 1 2 3 2 3 3 2 1 2 1 1 3 3 3 1 2 3 1 3 1 3 1 1 2 1 3 2 1 1 3 2 1 1 3 2 3 2 3 2 1 3 2 2 2 1 2 2 1 3 3 1 3 1 2 3 1 1 2 2 2 1 3 1 1 3 3 2 3 2 1 3 1 1 1 3...
output:
66402
result:
wrong answer 1st lines differ - expected: '66403', found: '66402'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #3:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%