답안 #762087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762087 2023-06-20T18:48:09 Z coloboxx 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,sse2,sse3,ssse3,sse4,lzcnt,popcnt")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define ll long long
#define point pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define show(x) cerr << (#x) << " = " << x << '\n'
#define print(x) if (1) {cerr << (#x) << " = "; for (auto it : x) \
      cerr << it << ' '; cerr << '\n';}
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0)
 
const int N = 1 << 19;
const int S = 1e7 + 64;
const int INF = 2e9 + 64;
const ll MAX = 2e18 + 64;
const int LOG = 21;
const int MOD = 1e9 + 7; //998244353;
const int P = 79;
 
using namespace std;

// #include "gondola.h"

int f = -1;

int valid(int n, int a[]) {
      unordered_set<int> st;

      for (int i = 0; i < n; ++i)
            st.insert(a[i]);

      for (int i = 0; i < n; ++i) {
            if (a[i] <= n) {
                  f = (n - a[i] % n + 1) % n;
                  break; 
            }
      }

      if (st.size() < n)
            return 0;

      if (f == -1)
            return 1;

      for (int i = 0; i < n; ++i)
            if (a[i] <= n && a[i] != (i - f + n) % n + 1)
                  return 0;

      return 1;
}

int replacement(int n, int a[], int res[]) {
      if (!valid(n, a))
            return 0;

      if (f == -1)
            f = 0;

      vector<int> ans(N);
      for (int i = 0; i < n; ++i)
            if (a[i] > n)
                  ans[a[i]] = (i - f + n) % n + 1;

      int len = 0;
      for (int i = 0; i < N; ++i)
            if (ans[i]) res[len] = ans[i], ++len;
      return len;
}

int countReplacement(int n, int a[]) {
      return 0;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:46:21: warning: comparison of integer expressions of different signedness: 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |       if (st.size() < n)
      |           ~~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccAqoTtl.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status