답안 #139153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139153 2019-07-31T10:12:07 Z triplem5ds 고대 책들 (IOI17_books) C++14
0 / 100
2 ms 256 KB
#include<bits/stdc++.h>
#include "books.h"
using namespace std;
int cnt;
int solve(int idx, int picked, vector < int > &v){
	if (picked == -1 && v[idx] != idx){
		picked = v[idx];
		v[idx] = -1;
	}
	if (picked == idx){
		swap(v[idx], picked);
	}
	if(idx == v[idx])
    cnt++;
  if(cnt == v.size())
    return 0;
	if (picked > idx || picked == -1)
		return solve(idx + 1, picked, v) + 1;
	else
		return solve(idx - 1, picked, v) + 1;
}
long long minimum_walk(std::vector<int> v, int s) {
	return solve(s, -1, v);
	return 0;
}

Compilation message

books.cpp: In function 'int solve(int, int, std::vector<int>&)':
books.cpp:15:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(cnt == v.size())
      ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '3304', found: '1177'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -