Submission #43626

# Submission time Handle Problem Language Result Execution time Memory
43626 2018-03-18T17:14:01 Z faustaadp Ancient Books (IOI17_books) C++14
0 / 100
2 ms 692 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
#include "books.h"
ll n,i,nx[101010],has,tam;
bool b[101010];
void dfs(ll aa)
{
	b[aa]=1;
	if(!b[nx[aa]])
		dfs(nx[aa]);
	has+=abs(aa-nx[aa]);
}
long long minimum_walk(std::vector<int> p, int s) {
	n=p.size();
	for(i=0;i<n;i++)
	{
		if(p[i]==i)
			b[i]=1;
		else
			nx[i]=p[i];
	}
	for(i=0;i<n;i++)
	{
		if(!b[i])
		{
			dfs(i);
			tam=i*2;
		}
	}
	return has+tam;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Incorrect 2 ms 560 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Incorrect 2 ms 560 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Incorrect 2 ms 560 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 692 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Incorrect 2 ms 560 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -