CSES - Datatähti Open 2017 - Results
Submission details
Task:Mex value
Sender:Bekmyrat
Submission time:2017-01-22 14:08:40 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.18 s1details
#20.18 s1details
#30.16 s1details
#40.18 s1details
#5ACCEPTED0.04 s1details
#60.17 s1details
#70.21 s1details
#80.17 s1details
#90.19 s1details
#10ACCEPTED0.05 s1details
#110.24 s2details
#120.22 s2details
#130.25 s2details
#140.24 s2details
#15ACCEPTED0.10 s2details
#160.23 s2details
#170.23 s2details
#180.21 s2details
#190.18 s2details
#20ACCEPTED0.10 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:70:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
                       ^
input/code.cpp:73:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
                     ^

Code

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

#define N 100005

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, k;
int v[N], q[N], T[4*N];

void build(int l, int r, int node)
{
	if (l == r) {
		T[node] = l;
		return;
	}
	
	build(l, (l+r)/2, node*2);
	build((l+r)/2+1, r, node*2+1);
	
	T[node] = min(T[node*2], T[node*2+1]);
}

void upd(int x, int y, int l, int r, int node)
{
	if (l == r) {
		T[node] = y;
		return;
	}
	
	if (x <= (l+r)/2)
		upd(x, y, l, (l+r)/2, node*2);
	else
		upd(x, y, (l+r)/2+1, r, node*2+1);
	
	T[node] = min(T[node*2], T[node*2+1]);
}

int main()
{
	scanf("%d%d", &n, &k);
	
	FOR (i, 1, n)
		scanf("%d", &v[i]);
	
	build(0, n, 1);
	
	FOR (i, 1, k) {
		if (v[i] > n)
			continue;
			
		q[v[i]]++;
		if (q[v[i]] == 1)
			upd(v[i], inf, 0, n, 1);
	}
	
	printf("%d ", T[1]);
	FOR (i, k+1, n) {
		if (q[v[i-k]] == 1)
			upd(v[i-k], v[i-k], 0, n, 1);
		q[v[i-k]]--;
		
		if (v[i] > n)
			continue;
			
		q[v[i]]++;
		if (q[v[i]] == 1)
			upd(v[i], inf, 0, n, 1);
		printf("%d ", T[1]);
	}
}

Test details

Test 1

Group: 1

Verdict:

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)

Test 2

Group: 1

Verdict:

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)

Test 3

Group: 1

Verdict:

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:

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)

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:

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)

Test 7

Group: 1

Verdict:

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)

Test 8

Group: 1

Verdict:

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)

Test 9

Group: 1

Verdict:

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:

input
100000 10000
1000000000 4786 3512 3285 1919...

correct output
9547 10000 4786 3512 3285 1919...

user output
(empty)

Test 12

Group: 2

Verdict:

input
100000 10000
1000000000 7981 3955 790 45 34...

correct output
7657 10000 7981 3955 790 45 45...

user output
(empty)

Test 13

Group: 2

Verdict:

input
100000 10000
1000000000 2329 1825 9435 3800...

correct output
5701 10000 2329 1825 1825 1825...

user output
(empty)

Test 14

Group: 2

Verdict:

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:

input
100000 10000
1000000000 7560 4634 7044 3853...

correct output
9855 10000 7560 4634 4634 3853...

user output
(empty)

Test 17

Group: 2

Verdict:

input
100000 10000
1000000000 7945 6674 3975 3002...

correct output
6373 10000 7945 6674 3975 3002...

user output
(empty)

Test 18

Group: 2

Verdict:

input
100000 10000
1000000000 2506 6827 6871 8593...

correct output
2978 10000 2506 2506 2506 2506...

user output
(empty)

Test 19

Group: 2

Verdict:

input
100000 10000
1000000000 2769 5036 539 4409 ...

correct output
2249 10000 2769 2769 539 539 5...

user output
(empty)

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 ...