Submission #42954

# Submission time Handle Problem Language Result Execution time Memory
42954 2018-03-06T20:58:01 Z MatheusLealV Ancient Books (IOI17_books) C++14
0 / 100
3 ms 480 KB
#include <bits/stdc++.h>
#define N 501
using namespace std;
typedef long long ll;

int n, s, ans[1000050];


ll minimum_walk(vector<int> v, int s_)
{
	ll sum = 0, last = 0;

	n = v.size(), s = s_;

	int pos = 0;

	while(true)
	{
		int nop = 0;

		for(int i = 0; i < n; i++)
		{
			if(v[i] != i) nop ++;
		}

		if(!nop) break;

		if(v[pos] == pos)
		{
			pos ++;

			sum ++;

			continue;
		}

		int sv = pos;

		cout<<"FROM "<<pos<<" TO "<<v[pos]<<"\n";

		sum += abs(v[pos] - pos);

		pos = v[pos];

		last = pos;

		v[sv] = sv; 
	}

	return sum + last;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 480 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB secret mismatch
2 Halted 0 ms 0 KB -