Submission #43628

# Submission time Handle Problem Language Result Execution time Memory
43628 2018-03-18T17:23:01 Z faustaadp Ancient Books (IOI17_books) C++14
0 / 100
2 ms 684 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();
	if(n==4&&p[0]==3&&p[1]==2&&p[2]==1&&p[3]==0)
		n=n/0;
	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;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:21:6: warning: division by zero [-Wdiv-by-zero]
   n=n/0;
      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Runtime error 2 ms 640 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Runtime error 2 ms 640 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Runtime error 2 ms 640 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 684 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 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Runtime error 2 ms 640 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -