Submission #199688

# Submission time Handle Problem Language Result Execution time Memory
199688 2020-02-02T20:30:02 Z MladenP Ancient Books (IOI17_books) C++17
0 / 100
6 ms 504 KB
#include "books.h"
#include<bits/stdc++.h>
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
#define NL(x) " \n"[(x)]
#define lld long long
#define pil pair<int,lld>
#define pli pair<lld,int>
#define pll pair<lld,lld>
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 1000010
int N, posl, pos[MAXN], a[MAXN];
void dfs(int node) {
    pos[node] = true;
    if(!pos[a[node]]) dfs(a[node]);
}
long long minimum_walk(std::vector<int> p, int s) {
    lld rez = 0;
    N = sz(p);
    for(int i = 0; i < N; i++) a[i] = p[i], rez += abs(p[i]-i);
    for(int i = 0; i < N; i++) {
        if(!pos[i]) {
            posl = i;
            dfs(i);
        }
    }
    rez += 2*posl;
	return rez;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 6 ms 376 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 5 ms 376 KB Output is correct
2 Incorrect 6 ms 376 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 5 ms 376 KB Output is correct
2 Incorrect 6 ms 376 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 6 ms 504 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 6 ms 376 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -