QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#671601 | #5147. Stack Sort | Repeater# | RE | 27ms | 3772kb | C++20 | 471b | 2024-10-24 13:39:17 | 2024-10-24 13:39:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
vector<int> a(n), p(n);
for(int i = 0; i < n; i++) cin >> a[i], p[a[i]] = i;
int ans = 0;
vector<int> vis(n);
for(int i = n - 1; i >= 0; i--){
if(a[i] == 1 || !vis[p[a[i] - 1]]) ans++;
vis[p[a[i]]] = 1;
}
cout << ans << "\n";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
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: 0
Accepted
time: 27ms
memory: 3596kb
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 3 2 3 2 2 5 3 3 2 3 1 2 3 4 3 3 2 2 3 3 3 3 3 5 4 3 3 2 3 2 3 3 3 2 2 4 2 4 3 2 4 2 3 4 2 3 3 2 3 3 2 3 2 3 2 3 3 3 3 3 3 2 2 3 2 2 3 3 2 2 2 3 3 3 3 3 2 2 3 3 3 3 4 3 3 3 3 3 4 3 2 3 3 2 3 3 3 3 2 4 3 3 2 1 4 2 3 2 2 3 2 2 3 3 2 2 2 3 3 2 4 4 2 3 2 2 2 3 3 3 2 4 3 2 3 3 3 3 3 4 2 2 1 2 3 4 3 3 ...
result:
ok 100000 numbers
Test #3:
score: -100
Runtime Error
input:
50000 10 3 1 2 10 6 8 5 4 7 9 10 8 3 9 2 10 4 5 1 7 6 9 6 8 4 9 5 7 1 3 2 9 6 7 9 3 8 5 2 1 4 10 7 10 1 2 6 5 3 9 4 8 10 1 10 4 3 2 9 7 8 5 6 9 1 5 3 4 9 6 7 2 8 10 4 7 2 8 3 6 9 5 10 1 9 6 4 9 1 8 5 2 3 7 10 5 1 7 8 10 3 9 6 2 4 9 4 8 6 3 9 7 5 2 1 9 9 1 7 6 2 3 8 5 4 10 5 7 2 1 4 3 6 8 9 10 10 9 7...