Submission #566255

# Submission time Handle Problem Language Result Execution time Memory
566255 2022-05-22T07:57:41 Z sofapuden Ancient Books (IOI17_books) C++14
0 / 100
1 ms 304 KB
#include "books.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll minimum_walk(vector<int> p, int s) {
	ll su = 0;
	int mx = 0;
	int n = p.size();
	vector<int> vis(n,0);
	ll ans = 0;
	for(int i = 0; i < n; ++i){
		ans+=abs(i-p[i]);
		if(!vis[i]){
			ans+=2;
			while(!vis[i]){
				vis[i] = 1;
				i = p[i];
			}
		}
	}
	return ans-2;
}

Compilation message

books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:9:5: warning: unused variable 'su' [-Wunused-variable]
    9 |  ll su = 0;
      |     ^~
books.cpp:10:6: warning: unused variable 'mx' [-Wunused-variable]
   10 |  int mx = 0;
      |      ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Incorrect 1 ms 212 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 0 ms 304 KB Output is correct
2 Incorrect 1 ms 212 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 0 ms 304 KB Output is correct
2 Incorrect 1 ms 212 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 212 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 0 ms 304 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -