Submission #47184

# Submission time Handle Problem Language Result Execution time Memory
47184 2018-04-28T17:26:58 Z PowerOfNinjaGo Ancient Books (IOI17_books) C++17
0 / 100
2 ms 548 KB
//Power Of Ninja Go
#include <bits/stdc++.h>
#ifdef atom
	#include "grader.cpp"
#else
	#include "books.h"
#endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
int n;
const int maxn = 1e6+5;
vector<int> p;
int a[maxn], b[maxn];
bool vis[maxn];
int cnt = 0;
void dfs(int u)
{
	if(vis[u]) return;
	vis[u] = true;
	a[cnt] = min(u, a[cnt]);
	b[cnt] = max(u, b[cnt]);
	dfs(p[u]);
}
long long minimum_walk(std::vector<int> P, int s)
{
	p = P;
	n = P.size();
	for(int i = 0; i< n; i++)
	{
		if(vis[i]) continue;
		dfs(i); cnt++;
	}
	int ed = 0;
	ll res = 0;
	for(int i = 0; i< cnt; i++)
	{
		if(ed< a[i])
		{
			res += 2*(a[i]-ed);
			ed = a[i];
		}
		res += 2*(b[i]-a[i]);
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '6', found: '10'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '6', found: '10'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '6', found: '10'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 548 KB 3rd lines differ - on the 1st token, expected: '3304', found: '725892'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '6', found: '10'
3 Halted 0 ms 0 KB -