Submission #387819

#TimeUsernameProblemLanguageResultExecution timeMemory
387819MilosMilutinovicGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
/**
 *    author:  milos
 *    created: 09.04.2021 10:49:32       
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int valid(int n, vector<int> a) {
  set<int> s(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    a[i] %= n;
    if (a[i] == 0) {
      a[i] = n;
    }
  }
  if (s.size() != n) {
    return 0;
  }
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] < a[i - 1]) {
      cnt++;  
    }
  }
  return (cnt <= 1 ? 1 : 0);
}

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, std::vector<int>)':
gondola.cpp:17:16: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |   if (s.size() != n) {
      |       ~~~~~~~~~^~~~
/tmp/ccgZJrfw.o: In function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status