Submission #292741

# Submission time Handle Problem Language Result Execution time Memory
292741 2020-09-07T12:44:00 Z Saboon Ancient Books (IOI17_books) C++17
0 / 100
1 ms 384 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;

bool visited[maxn], root[maxn];

long long minimum_walk(vector<int> p, int s){
	int n = p.size();
	set<int> S;
	ll answer = 0;
	for (int i = 0; i < n-1; i++){
        S.insert(p[i]);
        if (!S.empty() and *S.begin() == i)
            S.erase(S.begin());
        answer += 2*S.size();
	}
	int tmp = 0;
	for (int i = 0; i < n; i++){
        if (!visited[i] and p[i] != i){
            tmp = i;
            int x = i;
            while (!visited[x]){
                visited[x] = 1;
                x = p[x];
            }
        }
	}
	answer += 2*tmp;
	return answer;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '8', found: '12'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '8', found: '12'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '8', found: '12'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '3304', found: '996994'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '8', found: '12'
4 Halted 0 ms 0 KB -