CSES - Datatähti 2019 loppu - Results
Submission details
Task:Auringonlasku
Sender:Matias Järvenpää
Submission time:2019-01-17 16:59:46 +0200
Language:C++
Status:READY
Result:51
Feedback
groupverdictscore
#1ACCEPTED16
#2ACCEPTED35
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1details
#2ACCEPTED0.04 s1details
#3ACCEPTED0.02 s1details
#4ACCEPTED0.02 s1details
#5ACCEPTED0.03 s1details
#6ACCEPTED0.02 s1details
#7ACCEPTED0.02 s1details
#8ACCEPTED0.03 s1details
#9ACCEPTED0.03 s1details
#10ACCEPTED0.04 s1details
#11ACCEPTED0.03 s1details
#12ACCEPTED0.02 s1details
#13ACCEPTED0.02 s1details
#14ACCEPTED0.01 s1details
#15ACCEPTED0.02 s1details
#16ACCEPTED0.03 s1details
#17ACCEPTED0.02 s1details
#18ACCEPTED0.02 s2details
#19ACCEPTED0.13 s2details
#20ACCEPTED0.58 s2details
#21ACCEPTED0.10 s2details
#22ACCEPTED0.12 s2details
#23ACCEPTED0.10 s2details
#24ACCEPTED0.14 s2details
#25ACCEPTED0.10 s2details
#26ACCEPTED0.15 s2details
#27ACCEPTED0.14 s2details
#28ACCEPTED0.02 s2details
#29ACCEPTED0.12 s2details
#30ACCEPTED0.11 s2details
#31ACCEPTED0.14 s2details
#32ACCEPTED0.02 s3details
#33ACCEPTED0.22 s3details
#34ACCEPTED0.22 s3details
#35--3details
#36ACCEPTED0.11 s3details
#37ACCEPTED0.18 s3details
#38ACCEPTED0.12 s3details
#39ACCEPTED0.23 s3details
#40--3details
#41ACCEPTED0.22 s3details
#42--3details
#43ACCEPTED0.24 s3details
#44--3details
#45--3details
#46ACCEPTED0.09 s3details
#47--3details
#48ACCEPTED0.11 s3details
#49ACCEPTED0.09 s3details
#50ACCEPTED0.12 s3details
#51ACCEPTED0.24 s3details
#52--3details
#53--3details
#54ACCEPTED0.17 s3details

Code

#include <bits/stdc++.h>
#include <stdint.h>
using namespace std;

uint32_t n,q;
uint32_t t[100000];

uint32_t puu[1<<18];
uint32_t size;
bool e[1000000];

void muuta(uint32_t index, uint32_t val){
  puu[index] = val;
  for(index /= 2; index > 0; index/=2){
    puu[index] = max(puu[index*2],puu[index*2+1]);
  }
}

uint32_t isompi(uint32_t index){
  uint32_t val = puu[index];
  if(e[index]){
    return size;
  }
  index++;
  while(index > 0){
    if(puu[index] > val){
      while(index < (size/2)){
	if(puu[index*2] > val){
	  index *= 2;
	}
	else{
	  index *= 2;
	  index++;
	}
      }
      break;
    }
    else{
      if(e[index]){
	return size;
      }
      if(index %2 == 1){
	index++;
      }
      else{
	index /= 2;
      }
    }
  }
  return index;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  if((n < 2001) && (q < 2001)){
    for(uint32_t i=0; i<n; i++){
    cin >> t[i];
  }
  for(uint32_t i=0; i<q; i++){
    uint32_t a,b;
    cin >> a >> b;
    uint32_t m = 0;
    uint32_t ans = 0;
    for(uint32_t i2=a-1; i2<b; i2++){
      if(t[i2] > m){
	m = t[i2];
	ans++;
      }
    }
    cout << ans << "\n";
  }
  return 0;
  }
   size = 1;
  while(size < n){
    size *= 2;
  }
  size *= 2;
  for(uint32_t i=0; i<size; i++){
    e[i] = 0;
  }
   for(uint32_t i=2; i<size; i*=2){
    e[i-1] = 1;
  }
 
  for(uint32_t i=0; i<size; i++){
    puu[i] = 0;
  }
  for(uint32_t i=0; i<n; i++){
    cin >> t[i];
    muuta(i+size/2,t[i]);
  }
  for(uint32_t i=0; i<q; i++){
    uint32_t a,b;
    cin >> a >> b;
    uint32_t ans = 1;
    uint32_t w = isompi(a-1+size/2);
    while((w <= (b-1+size/2))){
      // cout << w << " " ;
      ans++;
      w = isompi(w);
    }
    //  cout << "\n";
    cout << ans << "\n";
  }
  
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

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

correct output
1
3
1

user output
1
3
1

Test 2

Group: 1

Verdict: ACCEPTED

input
1 1
1
1 1

correct output
1

user output
1

Test 3

Group: 1

Verdict: ACCEPTED

input
2 3
1 1000000000
1 1
2 2
1 2

correct output
1
1
2

user output
1
1
2

Test 4

Group: 1

Verdict: ACCEPTED

input
2 3
1000000000 1
1 1
2 2
1 2

correct output
1
1
1

user output
1
1
1

Test 5

Group: 1

Verdict: ACCEPTED

input
2000 2000
387547790 498212511 224378606 ...

correct output
14
10
10
3
7
...

user output
14
10
10
3
7
...

Test 6

Group: 1

Verdict: ACCEPTED

input
2000 2000
13604803 27447643 34139694 383...

correct output
198
43
38
58
50
...

user output
198
43
38
58
50
...

Test 7

Group: 1

Verdict: ACCEPTED

input
2000 2000
387547790 498212511 224378606 ...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 8

Group: 1

Verdict: ACCEPTED

input
2000 2000
409666302 646936685 583741760 ...

correct output
8
9
12
8
11
...

user output
8
9
12
8
11
...

Test 9

Group: 1

Verdict: ACCEPTED

input
2000 2000
1000000000 1000000000 10000000...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 10

Group: 1

Verdict: ACCEPTED

input
2000 2000
785263 793567 1573404 1750090 ...

correct output
2000
2000
2000
2000
2000
...

user output
2000
2000
2000
2000
2000
...

Test 11

Group: 1

Verdict: ACCEPTED

input
2000 2000
785263 793567 1573404 1750090 ...

correct output
1960
1947
1963
1942
1944
...

user output
1960
1947
1963
1942
1944
...

Test 12

Group: 1

Verdict: ACCEPTED

input
1999 2000
129087461 494922181 482953911 ...

correct output
10
6
6
7
7
...

user output
10
6
6
7
7
...

Test 13

Group: 1

Verdict: ACCEPTED

input
2000 2000
409666302 646936685 583741760 ...

correct output
8
7
6
7
7
...

user output
8
7
6
7
7
...

Test 14

Group: 1

Verdict: ACCEPTED

input
2000 2000
44989 1437234 1640005 1765235 ...

correct output
1233
1389
1026
150
796
...

user output
1233
1389
1026
150
796
...

Test 15

Group: 1

Verdict: ACCEPTED

input
2000 2000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
988
994
981
979
973
...

user output
988
994
981
979
973
...

Test 16

Group: 1

Verdict: ACCEPTED

input
2000 2000
1999 2000 1997 1998 1995 1996 ...

correct output
1
2
1
1
2
...

user output
1
2
1
1
2
...

Test 17

Group: 1

Verdict: ACCEPTED

input
2000 2000
2 1 4 3 5 4 5 2 3 1 2 1 4 3 5 ...

correct output
2
1
1
2
3
...

user output
2
1
1
2
3
...

Test 18

Group: 2

Verdict: ACCEPTED

input
1 1
1
1 1

correct output
1

user output
1

Test 19

Group: 2

Verdict: ACCEPTED

input
100000 200000
32 22 35 59 37 2 5 5 79 53 22 ...

correct output
4
9
6
5
4
...

user output
4
9
6
5
4
...

Test 20

Group: 2

Verdict: ACCEPTED

input
100000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
89
35
59
25
12
...

user output
89
35
59
25
12
...

Test 21

Group: 2

Verdict: ACCEPTED

input
100000 200000
32 22 35 59 37 2 5 5 79 53 22 ...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 22

Group: 2

Verdict: ACCEPTED

input
100000 200000
72 58 92 12 32 29 55 87 6 49 5...

correct output
5
7
5
6
2
...

user output
5
7
5
6
2
...

Test 23

Group: 2

Verdict: ACCEPTED

input
100000 200000
100 100 100 100 100 100 100 10...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 24

Group: 2

Verdict: ACCEPTED

input
100000 200000
72 58 92 12 32 29 55 87 6 49 5...

correct output
4
7
6
7
4
...

user output
4
7
6
7
4
...

Test 25

Group: 2

Verdict: ACCEPTED

input
100000 200000
72 58 92 12 32 29 55 87 6 49 5...

correct output
5
5
5
5
5
...

user output
5
5
5
5
5
...

Test 26

Group: 2

Verdict: ACCEPTED

input
99999 200000
20 47 84 90 88 63 39 16 74 19 ...

correct output
5
7
6
3
3
...

user output
5
7
6
3
3
...

Test 27

Group: 2

Verdict: ACCEPTED

input
100000 200000
72 58 92 12 32 29 55 87 6 49 5...

correct output
6
4
9
2
5
...

user output
6
4
9
2
5
...

Test 28

Group: 2

Verdict: ACCEPTED

input
5 1
4 1 5 6 9
1 3

correct output
2

user output
2

Test 29

Group: 2

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
44
4
27
46
29
...

user output
44
4
27
46
29
...

Test 30

Group: 2

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 5 4 5 2 3 1 2 1 4 3 5 ...

correct output
3
3
3
3
2
...

user output
3
3
3
3
2
...

Test 31

Group: 2

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
39
10
37
20
43
...

user output
39
10
37
20
43
...

Test 32

Group: 3

Verdict: ACCEPTED

input
1 1
1
1 1

correct output
1

user output
1

Test 33

Group: 3

Verdict: ACCEPTED

input
100000 200000
994198482 687493351 579440176 ...

correct output
8
6
8
10
5
...

user output
8
6
8
10
5
...

Test 34

Group: 3

Verdict: ACCEPTED

input
100000 200000
138644593 592364551 919805093 ...

correct output
10
11
13
7
12
...

user output
10
11
13
7
12
...

Test 35

Group: 3

Verdict:

input
100000 200000
10770 195579 349462 442791 450...

correct output
2468
1986
2632
129
4010
...

user output
(empty)

Test 36

Group: 3

Verdict: ACCEPTED

input
100000 200000
994198482 687493351 579440176 ...

correct output
1
2
1
2
1
...

user output
1
2
1
2
1
...

Test 37

Group: 3

Verdict: ACCEPTED

input
100000 200000
398809514 622635167 133376912 ...

correct output
15
13
16
11
17
...

user output
15
13
16
11
17
...

Test 38

Group: 3

Verdict: ACCEPTED

input
100000 200000
1000000000 1000000000 10000000...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 39

Group: 3

Verdict: ACCEPTED

input
100000 200000
398809514 622635167 133376912 ...

correct output
10
16
7
18
10
...

user output
10
16
7
18
10
...

Test 40

Group: 3

Verdict:

input
100000 200000
11465 15800 19042 19282 20348 ...

correct output
99542
99728
99391
99890
99716
...

user output
(empty)

Test 41

Group: 3

Verdict: ACCEPTED

input
99999 200000
587542096 890780320 258438313 ...

correct output
8
6
11
11
17
...

user output
8
6
11
11
17
...

Test 42

Group: 3

Verdict:

input
100000 200000
11283 24634 28852 37453 37625 ...

correct output
100000
100000
100000
100000
100000
...

user output
(empty)

Test 43

Group: 3

Verdict: ACCEPTED

input
100000 200000
398809514 622635167 133376912 ...

correct output
13
13
10
15
15
...

user output
13
13
10
15
15
...

Test 44

Group: 3

Verdict:

input
100000 200000
11465 15800 19042 19282 20348 ...

correct output
36112
6013
51073
8123
82052
...

user output
(empty)

Test 45

Group: 3

Verdict:

input
100000 200000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
99407
99529
99590
99589
99679
...

user output
(empty)

Test 46

Group: 3

Verdict: ACCEPTED

input
100000 200000
100000 99999 99998 99997 99996...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Test 47

Group: 3

Verdict:

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
49946
49703
49786
49864
49720
...

user output
(empty)

Test 48

Group: 3

Verdict: ACCEPTED

input
100000 200000
99999 100000 99997 99998 99995...

correct output
2
1
2
2
1
...

user output
2
1
2
2
1
...

Test 49

Group: 3

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 5 4 5 2 3 1 2 1 4 3 5 ...

correct output
3
3
3
3
2
...

user output
3
3
3
3
2
...

Test 50

Group: 3

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
19
23
2
21
4
...

user output
19
23
2
21
4
...

Test 51

Group: 3

Verdict: ACCEPTED

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
112
237
49
141
57
...

user output
112
237
49
141
57
...

Test 52

Group: 3

Verdict:

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
2457
2199
2351
2450
2475
...

user output
(empty)

Test 53

Group: 3

Verdict:

input
100000 200000
2 1 4 3 6 5 8 7 10 9 12 11 14 ...

correct output
24841
24973
24865
24823
24969
...

user output
(empty)

Test 54

Group: 3

Verdict: ACCEPTED

input
100000 200000
49999 50000 49997 49998 49995 ...

correct output
210
1
2
2
1
...

user output
210
1
2
2
1
...