Submission #289291

# Submission time Handle Problem Language Result Execution time Memory
289291 2020-09-02T14:14:02 Z Touubs Ancient Books (IOI17_books) C++17
0 / 100
2000 ms 256 KB
#include "books.h"
#include <bits/stdc++.h>

long long minimum_walk(std::vector<int> p, int s) {
    std::vector<bool> visited(p.size());
    long long res = 0;
    int maxVis = 0;
    int i;
    for (i = 0; i < p.size() && p[i] == i && i < s; i++);
    int top = p.size() - 1;
    for (; i <= top; i++) {
	if (maxVis < i) res+=2;
	res += abs(p[i] - i);
	maxVis = std::max(maxVis, p[i]);
    }
    for (int i = p.size() - 1; i > 0 && p[i] == i && i > s; res -= 2);
    return res;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (i = 0; i < p.size() && p[i] == i && i < s; i++);
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Execution timed out 2093 ms 256 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Execution timed out 2093 ms 256 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Execution timed out 2093 ms 256 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 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 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Execution timed out 2093 ms 256 KB Time limit exceeded
6 Halted 0 ms 0 KB -