Submission #289221

# Submission time Handle Problem Language Result Execution time Memory
289221 2020-09-02T13:16:31 Z wdjpng Ancient Books (IOI17_books) C++17
0 / 100
1 ms 256 KB
#include <bits/stdc++.h>
#include "books.h"

#define rep(i,n) for(int i = 0; i < n; i++)
#define lint long long
using namespace std;
vector<int>P;
vector<bool>vis;
int dfs(int v)
{
	if(vis[v]) return 0;
	vis[v]=true;
	return abs(v - P[v]) + dfs(P[v]);
}

long long minimum_walk(std::vector<int> p, int s) {
	int n = p.size();
	vis.resize(n);
	P=p;
	int count=0;
	int numComp=0;
	rep(i, n)
	{
		if(vis[i]){continue;}
		numComp++;
		count+=dfs(i);
	}

	return count+2*(numComp-1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 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: '4186'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -