QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691110#5147. Stack Sortlir_nutWA 29ms3952kbC++14849b2024-10-31 09:56:052024-10-31 09:56:05

Judging History

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

  • [2024-10-31 09:56:05]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:3952kb
  • [2024-10-31 09:56:05]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <set>
#include <stack>

#define test
#ifndef test
    freopen("in.in", stdin);
#endif

#define rint register int
#define ll long long
#define P pair<char, int> 
const int N = 5e5 + 50;

using namespace std;
int arr[N];
bool dic[N];
void solution(){
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++) dic[i] = false;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp; scanf("%d", &tmp);
        if(!dic[tmp + 1]) ans++;
        dic[tmp] = true;
    } 
    printf("%d", ans);
}

int main(){
    test
    int t = 1;
    scanf("%d", &t);
    while (t--){
        solution();
        if(t) printf("\n");
    }
}

詳細信息

Test #1:

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

input:

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

output:

3
1
4

result:

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

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 3952kb

input:

100000
4
3 4 2 1
5
5 4 1 3 2
4
3 1 4 2
4
4 2 1 3
4
1 3 2 4
4
4 2 3 1
4
3 2 1 4
5
1 2 3 4 5
5
5 2 3 1 4
5
1 3 5 4 2
5
4 3 2 1 5
5
3 4 2 1 5
5
5 4 3 2 1
4
3 4 2 1
5
4 2 5 1 3
5
4 1 5 2 3
4
3 4 1 2
4
2 1 3 4
5
4 3 2 5 1
4
4 2 1 3
5
3 1 5 2 4
4
4 1 2 3
5
1 5 2 4 3
5
4 1 3 5 2
5
4 2 3 5 1
5
1 2 3 4 5
5
4...

output:

2
2
2
1
2
1
1
5
3
3
2
3
1
1
3
4
2
2
2
1
3
2
3
3
3
5
4
2
3
1
3
1
3
3
2
1
2
4
1
4
3
2
4
1
2
4
1
2
3
1
3
3
1
3
2
3
1
3
3
3
2
2
2
2
1
3
1
1
3
3
1
1
2
3
2
2
2
3
1
1
2
3
3
3
4
3
3
2
3
3
4
2
1
3
2
1
2
3
2
3
2
4
2
3
1
0
4
1
2
1
1
2
2
1
3
3
1
1
2
2
3
2
4
4
1
2
1
2
1
3
2
2
1
4
3
1
3
3
3
2
3
4
2
2
0
2
3
4
2
3
...

result:

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