QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#861187#9982. Staircase Museumucup-team4717#WA 5ms8008kbC++14684b2025-01-18 16:26:082025-01-18 16:29:48

Judging History

This is the latest submission verdict.

  • [2025-01-18 16:29:48]
  • Judged
  • Verdict: WA
  • Time: 5ms
  • Memory: 8008kb
  • [2025-01-18 16:26:08]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
int T;
int n;
int l[N],r[N];
int f[N][2];
void sol(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld %lld",&l[i],&r[i]);
    for(int i=1;i<=n;i++){
        f[i][0]=f[i-1][0];
        f[i][1]=f[i-1][1];
        if(l[i]!=l[i-1]) f[i][0]=f[i-1][0]+1;
        if(r[i]!=r[i-1]) f[i][1]=f[i-1][1]+1;
        if(i>=3&&r[i-2]<l[i]) f[i][0]=max(f[i][0],f[i-2][1]+2);
        if(i>=3&&l[i-2]<l[i-1]&&r[i-1]<r[i]) f[i][1]=max(f[i][1],f[i-2][0]+2);
    }
    printf("%lld\n",max(f[n][0],f[n][1]));
}
signed main(){
    scanf("%lld",&T);
    while(T--) sol();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 8008kb

input:

4
3
1 2
1 3
1 3
3
1 2
2 3
3 3
3
1 1
1 3
3 3
4
1 2
2 3
3 4
4 5

output:

2
3
3
4

result:

ok 4 number(s): "2 3 3 4"

Test #2:

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

input:

1
1
1 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 7996kb

input:

9653
1
1 1
2
1 1
1 1
3
1 1
1 1
1 1
4
1 1
1 1
1 1
1 1
5
1 1
1 1
1 1
1 1
1 1
6
1 1
1 1
1 1
1 1
1 1
1 1
6
1 2
1 2
1 2
1 2
1 2
2 2
6
1 1
1 1
1 1
1 1
1 1
1 2
6
1 2
1 2
1 2
1 2
1 2
2 3
5
1 2
1 2
1 2
1 2
2 2
6
1 2
1 2
1 2
1 2
2 2
2 2
6
1 3
1 3
1 3
1 3
2 3
3 3
6
1 2
1 2
1 2
1 2
2 2
2 3
6
1 3
1 3
1 3
1 3
2 3...

output:

1
1
1
1
1
1
2
2
2
2
2
3
3
3
2
2
2
3
3
3
3
2
2
3
3
3
3
3
2
2
2
3
2
3
3
3
4
4
4
3
3
3
4
4
3
4
3
3
4
4
4
4
4
2
2
2
2
3
3
2
2
3
3
2
2
3
3
3
3
3
3
3
3
3
3
4
4
3
3
4
4
4
4
3
3
3
4
4
3
3
4
4
4
4
3
3
4
3
4
3
3
4
4
4
4
4
2
2
2
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
3
3
3
4
4
3
3
4
4
4
4
3
3
4
4
4
4
4
4
4
4
4
3
3
4
...

result:

wrong answer 20th numbers differ - expected: '2', found: '3'