Submission #767308

# Submission time Handle Problem Language Result Execution time Memory
767308 2023-06-26T15:25:00 Z raysh07 Ancient Books (IOI17_books) C++17
0 / 100
1 ms 296 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

long long minimum_walk(vector<int> a, int s) {
	if (s != 0) return 0;
	
	long long ans = 0;
	int n = a.size();
	vector <bool> solved(n, false);
	int cnt = 0;
	int x = s;
	for (int i = 0; i < n; i++){
	    if (a[i] == i) {
	        solved[i] = true;
	        cnt++;
	    }
	}
	while (cnt < n){
	 //   cout << s << " " << ans << "\n";
	    if (solved[s]){
	        s++;
	        ans++;
	        continue;
	    }
	    
	    int ok = abs(a[s] - s);
	 //   cout << ok << "\n";
	    ans += ok;
	    solved[s] = true;
	    cnt++;
	    s = a[s];
	}
	ans += abs(x - s);
	
	return ans;
}

// int main(){
//     int n, s; cin >> n >> s;
//     vector <int> a(n);
//     for (auto &x : a) cin >> x;
    
//     cout << minimum_walk(a, s) << "\n";
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Incorrect 1 ms 212 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Incorrect 1 ms 212 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Incorrect 1 ms 212 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 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -