QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303257#5210. Lisa's SequencesLaStataleBlue#WA 1ms3756kbC++231.8kb2024-01-11 23:42:302024-01-11 23:42:31

Judging History

你现在查看的是最新测评结果

  • [2024-01-11 23:42:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3756kb
  • [2024-01-11 23:42:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solve(int t){
    int n,k;
    cin>>n>>k;
    
    vector a(n,0);
    for(auto &i : a)cin>>i;
    
    int last=-1;
    vector succ(n,-1);
    for(int i=n-2;i>=0;i--){
        if(a[i]<a[i+1])last=2;
        if(a[i]>a[i+1])last=1;
        
        succ[i]=last;
    }
    
    int cont=2,res=0,tt=0;
    last=-1;
    bool same=(a[1]==a[0]);
    
    
    if(a[0]<a[1])last=2,t=1;
    if(a[0]>a[1])last=1,t=1;
    
    for(int i=2;i<n;i++){
        if((a[i]>=a[i-1] && last==2) || (a[i]<=a[i-1] && last==1) || last==-1){
            cont++;
            
            if(cont==k){
                res++;
                
                if(same){
                    
                    if(i+1<n && succ[i+1]==2){
                        a[i-1]=0;
                    }else{
                        a[i-1]=100'000;
                    }
                    
                }
                else if(last==2){
                    if(i+1<n && succ[i+1]==2)a[i-1]=100'000;
                    else a[i]=0;
                }else{
                    if(i+1<n && succ[i+1]==1)a[i-1]=0;
                    else a[i]=100'000;
                }
                
                cont=2;
                same=(a[i]==a[i-1]);
            }
            
            if(a[i]!=a[i-1])same=false;
        }else{
            //cout<<i<<" resetto \n";
            cont=i-t+1;
            same=(a[i]==a[i-1]);
        }
        
        if(a[i]>a[i-1])last=2,t=i;
        if(a[i]<a[i-1])last=1,t=i;
    }
    cout<<res<<"\n";
    for(auto i : a)cout<<i<<" ";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3504kb

input:

5 3
1 2 3 4 5

output:

2
1 100000 3 4 0 

result:

ok 2

Test #2:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

6 3
1 1 1 1 1 1

output:

3
1 100000 1 100000 1 100000 

result:

ok 3

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

6 4
1 1 4 4 1 1

output:

1
1 1 4 0 1 1 

result:

ok 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

6 4
4 4 4 2 2 2

output:

2
4 4 100000 2 2 100000 

result:

ok 2

Test #5:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

6 4
4 4 4 3 4 4

output:

1
4 4 100000 3 4 4 

result:

ok 1

Test #6:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

8 4
2 1 1 3 3 1 1 2

output:

2
2 1 1 100000 3 1 100000 2 

result:

ok 2

Test #7:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

10 4
1 1 1 2 2 1 1 2 2 1

output:

2
1 1 100000 2 2 100000 1 2 2 1 

result:

ok 2

Test #8:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

7 5
5 4 4 3 4 4 4

output:

0
5 4 4 3 4 4 4 

result:

ok 0

Test #9:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

10 10
1 1 1 1 1 1 1 1 1 1

output:

1
1 1 1 1 1 1 1 1 100000 1 

result:

ok 1

Test #10:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

3 3
1 2 1

output:

0
1 2 1 

result:

ok 0

Test #11:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

3 3
2 1 1

output:

1
2 1 100000 

result:

ok 1

Test #12:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

3 3
1 1 2

output:

1
1 100000 2 

result:

ok 1

Test #13:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

3 3
1 1 1

output:

1
1 100000 1 

result:

ok 1

Test #14:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

5 3
1 1 1 1 1

output:

2
1 100000 1 100000 1 

result:

ok 2

Test #15:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

6 4
5 5 5 5 5 5

output:

2
5 5 100000 5 5 100000 

result:

ok 2

Test #16:

score: -100
Wrong Answer
time: 0ms
memory: 3756kb

input:

6 4
4 4 4 2 2 4

output:

2
4 4 0 2 2 0 

result:

wrong answer Jury has better solution 1, only 2 found