Task: | Mex value |
Sender: | herkar |
Submission time: | 2017-01-22 14:52:38 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.18 s | 1 | details |
#2 | RUNTIME ERROR | 0.18 s | 1 | details |
#3 | RUNTIME ERROR | 0.18 s | 1 | details |
#4 | RUNTIME ERROR | 0.18 s | 1 | details |
#5 | ACCEPTED | 0.05 s | 1 | details |
#6 | RUNTIME ERROR | 0.19 s | 1 | details |
#7 | RUNTIME ERROR | 0.18 s | 1 | details |
#8 | RUNTIME ERROR | 0.18 s | 1 | details |
#9 | RUNTIME ERROR | 0.16 s | 1 | details |
#10 | ACCEPTED | 0.04 s | 1 | details |
#11 | RUNTIME ERROR | 0.24 s | 2 | details |
#12 | RUNTIME ERROR | 0.23 s | 2 | details |
#13 | RUNTIME ERROR | 0.25 s | 2 | details |
#14 | RUNTIME ERROR | 0.20 s | 2 | details |
#15 | ACCEPTED | 0.10 s | 2 | details |
#16 | RUNTIME ERROR | 0.22 s | 2 | details |
#17 | RUNTIME ERROR | 0.23 s | 2 | details |
#18 | RUNTIME ERROR | 0.23 s | 2 | details |
#19 | RUNTIME ERROR | 0.21 s | 2 | details |
#20 | ACCEPTED | 0.07 s | 2 | details |
Code
#include <functional> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <cmath> #include <queue> #include <stack> #include <set> #include <map> using namespace std; #define rep(i,a,b) for(int i = (a); i < int(b); ++i) #define rrep(i,a,b) for(int i = (b); i --> int(a); ) #define trav(i,v) for(auto&i:v) #define all(c) (c).begin(), (c).end() #define sz(c) int((c).size()) typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; int main(){ cin.tie(0); cin.sync_with_stdio(0); int n,k; cin >> n >> k; vi v(n); trav(i,v) cin >> i; set<pii> S; map<int,int> C; function<void(int)> add = [&](int a){ if(C[a]++) return; if(S.empty()){ S.insert({a,a}); return; } auto it = S.lower_bound({a,-1}); if(it == S.begin()){ if(it->first == a+1){ pii p = *it; S.erase(it); S.insert({a,p.second}); } else S.insert({a,a}); } else if(it == S.end()) { --it; if(it->second == a-1){ pii p = *it; S.erase(it); S.insert({p.first,a}); } else S.insert({a,a}); } else { auto it2 = it--; if(it->second == a-1 && it2->first == a+1){ pii p = {it->first,it2->second}; S.erase(it),S.erase(S.upper_bound({a,-1})); S.insert(p); } else if(it->second == a-1){ pii p = {it->first,a}; S.erase(it); S.insert(p); } else if(it2->first == a+1){ pii p = {a,it2->second}; S.erase(it2); S.insert(p); } else S.insert({a,a}); } }, rem = [&](int a){ if(--C[a]) return; auto it = --S.upper_bound({a,-1}); pii p = *it; S.erase(it); if(p.first == a){ if(p.first != p.second) S.insert({a+1,p.second}); } else if(p.second == a) S.insert({p.first,a-1}); else S.insert({p.first,a-1}),S.insert({a+1,p.second}); }; rep(i,0,k) add(v[i]); rep(i,k,n+1){ pii p = *S.begin(); if(!p.first) cout << p.second+1 << " "; else cout << 0 << " "; if(i < n)add(v[i]); rem(v[i-k]); } cout << endl; }
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 9 1 0 5 7 2 8 6 3 4... |
correct output |
---|
4 10 9 1 1 1 1 1 1 1 1 4 10 3 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007fff77b02388 ***
Test 2
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 4 3 8 1 0 9 5 7 2 6... |
correct output |
---|
6 10 4 3 3 1 1 1 1 1 3 3 10 6 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007fffdc07f6c8 ***
Test 3
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 9 2 3 1 0 8 5 6 4 7... |
correct output |
---|
7 10 9 2 2 1 0 1 1 1 2 9 10 4 ... |
user output |
---|
(empty) |
Test 4
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 3 0 4 6 5 7 1 2 8 9... |
correct output |
---|
9 10 3 0 0 0 0 0 4 2 2 2 10 6 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffe62a72648 ***
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
100 10 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 ... |
correct output |
---|
10 10 10 10 10 10 10 10 10 10 ... |
user output |
---|
10 10 10 10 10 10 10 10 10 10 ... |
Test 6
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 0 5 1 9 3 4 6 7 2 8... |
correct output |
---|
8 10 0 5 1 1 1 1 1 5 2 5 10 0 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffdc522a338 ***
Test 7
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 1 2 9 3 8 0 4 7 5 6... |
correct output |
---|
6 10 1 1 1 1 2 0 0 2 3 9 10 6 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffc4d2207c8 ***
Test 8
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 5 0 6 7 1 4 8 3 9 2... |
correct output |
---|
2 10 5 0 0 0 0 0 0 0 0 1 10 9 ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffe1aed4368 ***
Test 9
Group: 1
Verdict: RUNTIME ERROR
input |
---|
100 10 1000000000 7 3 0 1 4 9 2 5 6 8... |
correct output |
---|
8 10 7 3 0 0 0 0 7 5 5 5 10 8 ... |
user output |
---|
(empty) |
Test 10
Group: 1
Verdict: ACCEPTED
input |
---|
100 10 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 ... |
correct output |
---|
10 10 10 10 10 10 10 10 10 10 ... |
user output |
---|
10 10 10 10 10 10 10 10 10 10 ... |
Test 11
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 4786 3512 3285 1919... |
correct output |
---|
9547 10000 4786 3512 3285 1919... |
user output |
---|
9547 1000000000 4786 3512 3285... |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007fff318a5468 ***
Test 12
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 7981 3955 790 45 34... |
correct output |
---|
7657 10000 7981 3955 790 45 45... |
user output |
---|
7657 1000000000 7981 3955 790 ... |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffeb9130308 ***
Test 13
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 2329 1825 9435 3800... |
correct output |
---|
5701 10000 2329 1825 1825 1825... |
user output |
---|
5701 1000000000 2329 1825 1825... |
Test 14
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 2754 6029 8007 6286... |
correct output |
---|
1423 10000 2754 2754 2754 2754... |
user output |
---|
(empty) |
Test 15
Group: 2
Verdict: ACCEPTED
input |
---|
100000 10000 0 1 2 3 4 5 6 7 8 9 10 11 12 1... |
correct output |
---|
10000 10000 10000 10000 10000 ... |
user output |
---|
10000 10000 10000 10000 10000 ... |
Test 16
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 7560 4634 7044 3853... |
correct output |
---|
9855 10000 7560 4634 4634 3853... |
user output |
---|
9855 1000000000 7560 4634 4634... |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007fff92ae8db8 ***
Test 17
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 7945 6674 3975 3002... |
correct output |
---|
6373 10000 7945 6674 3975 3002... |
user output |
---|
6373 1000000000 7945 6674 3975... |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffea639a658 ***
Test 18
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 2506 6827 6871 8593... |
correct output |
---|
2978 10000 2506 2506 2506 2506... |
user output |
---|
2978 1000000000 2506 2506 2506... |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffcd0061358 ***
Test 19
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100000 10000 1000000000 2769 5036 539 4409 ... |
correct output |
---|
2249 10000 2769 2769 539 539 5... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': free(): invalid pointer: 0x00007ffc0ca15908 ***
Test 20
Group: 2
Verdict: ACCEPTED
input |
---|
100000 10000 0 1 2 3 4 5 6 7 8 9 10 11 12 1... |
correct output |
---|
10000 10000 10000 10000 10000 ... |
user output |
---|
10000 10000 10000 10000 10000 ... |