Submission #776028

# Submission time Handle Problem Language Result Execution time Memory
776028 2023-07-07T08:39:30 Z peteza Ancient Books (IOI17_books) C++14
50 / 100
87 ms 18272 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

int qs[1000005];
long long minimum_walk(std::vector<int> p, int s) {
    int cur = 0, cv = 0, curcnt = 0;
    long long cans = 0;
    for(int i=0;i<=p.size();i++) qs[i] = 0;
    for(int i=0;i<p.size();i++) {
        qs[min(i, p[i])]++; qs[max(i, p[i])]--;
    }
    for(int i=0;i<p.size();i++) {
        cv += qs[i];
        cans += cv;
        if(!cv) cur++, curcnt++;
        else curcnt = 0;
    }
	return cans + 2*(cur-curcnt);
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<=p.size();i++) qs[i] = 0;
      |                 ~^~~~~~~~~~
books.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<p.size();i++) {
      |                 ~^~~~~~~~~
books.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<p.size();i++) {
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 1 ms 308 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 1 ms 308 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 81 ms 18248 KB Output is correct
31 Correct 87 ms 18248 KB Output is correct
32 Correct 80 ms 18148 KB Output is correct
33 Correct 80 ms 18164 KB Output is correct
34 Correct 83 ms 18220 KB Output is correct
35 Correct 80 ms 18228 KB Output is correct
36 Correct 78 ms 18192 KB Output is correct
37 Correct 80 ms 18184 KB Output is correct
38 Correct 78 ms 18252 KB Output is correct
39 Correct 77 ms 18272 KB Output is correct
40 Correct 75 ms 18176 KB Output is correct
41 Correct 77 ms 18204 KB Output is correct
42 Correct 78 ms 18228 KB Output is correct
43 Correct 78 ms 18144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 1 ms 308 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 81 ms 18248 KB Output is correct
31 Correct 87 ms 18248 KB Output is correct
32 Correct 80 ms 18148 KB Output is correct
33 Correct 80 ms 18164 KB Output is correct
34 Correct 83 ms 18220 KB Output is correct
35 Correct 80 ms 18228 KB Output is correct
36 Correct 78 ms 18192 KB Output is correct
37 Correct 80 ms 18184 KB Output is correct
38 Correct 78 ms 18252 KB Output is correct
39 Correct 77 ms 18272 KB Output is correct
40 Correct 75 ms 18176 KB Output is correct
41 Correct 77 ms 18204 KB Output is correct
42 Correct 78 ms 18228 KB Output is correct
43 Correct 78 ms 18144 KB Output is correct
44 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -