Submission #528869

#TimeUsernameProblemLanguageResultExecution timeMemory
528869Alex_tz307곤돌라 (IOI14_gondola)C++17
55 / 100
18 ms2088 KiB
#include<bits/stdc++.h>
#include "gondola.h"
 
using namespace std;
 
int valid(int n, int a[]) {
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      pos = i;
      break;
    }
  }
  for (int x = 1; x <= n; ++x) {
    if (a[pos] != x) {
      return 0;
    }
    pos += 1;
    if (pos == n) {
      pos = 0;
    }
  }
  return 1;
}
 
void maxSelf(int &x, int y) {
  if (x < y) {
    x = y;
  }
}

int replacement(int n, int a[], int sol[]) {
  vector<int> v(n);
  iota(v.begin(), v.end(), 1);
  for (int i = 0; i < n; ++i) {
    if (a[i] <= n) {
      int x = a[i];
      for (int rep = 0; rep < n; ++rep) {
        v[i] = x;
        x += 1;
        if (x == n + 1) {
          x = 1;
        }
        i += 1;
        if (i == n) {
          i = 0;
        }
      }
      break;
    }
  }
  int N = 0;
  for (int i = 0; i < n; ++i) {
    maxSelf(N, a[i]);
  }
  vector<int> w(N + 1);
  for (int i = 0; i < n; ++i) {
    w[a[i]] = v[i];
  }
  int len = 0, x = n + 1;
  for (int i = 1; i <= N; ++i) {
    if (w[i]) {
      while (w[i] < i) {
        sol[len++] = w[i];
        w[i] = x;
        x += 1;
      }
    }
  }
  return len;
}
 
int countReplacement(int n, int gondolaSeq[]){
	
}

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:75:1: warning: no return statement in function returning non-void [-Wreturn-type]
   75 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...