답안 #1075934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075934 2024-08-26T09:50:58 Z edogawa_something 고대 책들 (IOI17_books) C++17
0 / 100
0 ms 448 KB
#include "books.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
ll n;
bool vis[2000000];
long long minimum_walk(vector<int> p, int s) {
  n=p.size();
  ll res=0;
  bool chk=1;
  for(int i=0;i<n;i++) {
    if(p[i]!=i)
      chk=0;
  }
  if(chk)
    return 0;
  ll cnt=0;
  for(int i=0;i<n;i++) {
    if(p[i]>=i) {
      cnt++;
    }
    vis[p[i]]=1;
    if(vis[i])
      cnt--;
    res+=2*cnt;
    if(cnt==0)
      res+=2;
  }
  for(int i=0;i<=s;i++) {
    if(p[i]==i)
      res-=2;
    else
      break;
  }
  for(int i=n-1;i>=s;i--) {
    if(p[i]==i)
      res-=2;
    else
      break;
  }
  return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 448 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 448 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 448 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2746'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 448 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -