답안 #39735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39735 2018-01-18T03:35:33 Z deletend 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <gondola.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int valid(int n, int inputSeq[]) {
  int d = 0, z = -1;
  map<int, int> mp;
  rep(i, 0, n) {
    if(mp[inputSeq[i]]) return 0;
    mp[inputSeq[i]] = 1;
    if(inputSeq[i] <= n) {
      if(z > inputSeq[i]) {
        if(d) return 0;
        else d = 1;
      }else if(z != -1) {
        if(z != inputSeq[i]) return 0;
      }
      z = inputSeq[i];
    }
    z++;
  }
  return 1;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
  int a[100001] = {};
  int kr;
  int mx = 0;
  rep(i, 0, n) {
    if(gondolaSeq[i] <= n) {
      kr = gondolaSeq[i];
      rep(j, 0, n) {
        a[i + j % n] = kr;
        kr++;
      }
    }else {
      continue;
    }
    break;
  }
  map<int, int> mp;
  rep(i, 0, n) {
    mx = max(mx, gondolaSeq[i]);
    mp[gondolaSeq[i]] = 1;
  }
  rep(i, 0, n) {
    if(gondolaSeq[i] > n) {
      replacementSeq[gondolaSeq[i] - n] = a[i];
    }
  }
  int ri = 0;
  rep(i, n, mx) {
    if(!mp[i]) {
      while(replacementSeq[ri]) ri++;
      replacement[ri] = i;
    }
  }
  return n - v.size();
}

int countReplacement(int n, int inputSeq[]) {
  if(!valid(n, inputSeq)) return 0;
  int r[100001];
  if(replacement(n, inputSeq, r) <= n) return 1;

  vector<int> v;
  int no = 0;
  rep(i, 0, n) {
    if(inputSeq[i] > n) v.pb(i);
    else no++;
  }
  return 1;
}
//
// int main() {
//   int n;
//   cin >> n;
//
//   int c[10], h[10], p[10];
//   rep(i, 0, n) cin >> c[i];
//   rep(i, 1, n) cin >> h[i] >> p[i];
//   cout << findSample(n, c, h, p) << endl;
// }

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:69:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
       replacement[ri] = i;
                     ^
gondola.cpp:69:23: error: assignment of read-only location '*(replacement + ((sizetype)ri))'
       replacement[ri] = i;
                       ^
gondola.cpp:69:23: error: cannot convert 'int' to 'int(int, int*, int*)' in assignment
gondola.cpp:72:14: error: 'v' was not declared in this scope
   return n - v.size();
              ^